emscripten

Adam D. Ruppe destructionator at gmail.com
Wed Dec 15 13:58:35 PST 2010


David Nadlinger:
> You are confusing the web application and the data it operates on here

The thing is a web application is built on top of its data, almost
literally. Javascript manipulates an HTML document, and you need
to give it one to get started, even if it is an empty document.

If you give the javascript a usable HTML document as its starting
point, you can have your app with scripts available, and still have
the document when the scripts aren't available.

Let me do an example app, hopefully it won't be butchered too
much in transport.

Output this from your server side program:
<table>
<caption>Thread Participants</caption>
<tr>
   <td>Adam</td><td>Ruppe</td>
</tr>
<tr>
   <td>David</td><td>Nadlinger</td>
</tr>
</table>


If you go to that page in any browser, from Lynx up, you have a usable table of
data to look at.

Now add editing.js to it:

=====
function makeEditable() {
    var input = document.createElement("input");
    input.value = this.innerHTML;
    this.onclick = null;
    input.onblur = function() {
         post("/update-cell", { "row" : getRow(this), "column" : getColumn(this),
"value" : input.value }, function(response) {

              this.onclick = makeEditable;
              this.innerHTML = response;
         });
    }

    this.innerHTML = "";
    this.appendChild(input);
}

window.onload = function() {
  var items = document.getElementsByTagName("td");
  for(var a = 0; a < items.length; a++) {
     var item = items[a];
     item.onclick = makeEditable;
  }
}

=======

Now, if you do have a browser with scripting capabilities, this runs through the
already usable document and makes it more usable, by adding the inline editing
capability. It's now a primitive web app, while still being a usable web page to
browsers without all the fancy capabilities.

(Note that I wrote this on the fly here, without testing. I don't know if it would
actually run correctly or not. Another thing that sucks about the browser
platform... it's not complex code, but I have no confidence in it without testing
across them all.)



This is all I'm asking for with the "works in Lynx" thing. Start with a regular
webpage and build up. You are still on the web, still accessible from all these
browsers. You should at least follow the basic html standards well enough so they
aren't completely screwed and left behind.

How much do you build up? I say not too much, since before long you'll hit a wall
where the browser just sucks too much. But that's a separate concern from graceful
degradation.

Remember, the practical benefit to this isn't working for Lynx users, but for the
~20% of today's market with noscript installed, or stuck on IE6, or on
underpowered mobile phones, etc.

Or if you take a step up, depending on HTML5 stuff even locks out IE7 and some
IE8, Firefox, and Opera users. But if your site is still built on a solid
foundation, they won't be left behind either.


More information about the Digitalmars-d mailing list