Skip to content

Commit

Permalink
Added a delay before requesting that the document is parsed for triples.
Browse files Browse the repository at this point in the history
  • Loading branch information
msporny committed Dec 15, 2010
1 parent db7bf90 commit af82e52
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
7 changes: 5 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ <h1>The RDFa markup playground.
<div class="row">
<div class="twelvecol last">
<p class="largeprint">
RDFa Live Loop lets you play with HTML+RDFa markup and instantly see
the data that your markup produces.</p>
Live Loop lets you play with
<a href="http://www.youtube.com/watch?v=ldl0m-5zLz4">HTML+RDFa</a> markup and instantly
see the data that your markup produces.</p>
</div>
</div>
<pre id="code-prologue">&lt;html&gt;</pre>
Expand All @@ -49,6 +50,8 @@ <h1>The RDFa markup playground.
<pre id="code-epilogue">&lt;/html&gt;</pre>
</div>

<img id="loading" style="margin: 2px 2px; float: left; display: none;" src="loading.gif" />

<div class="container onblack">
<div class="row">
<div class="twelvecol">
Expand Down
35 changes: 33 additions & 2 deletions live-loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
window.liveloop = window.liveloop || {};
var liveloop = window.liveloop;

liveloop.counter = 1;
liveloop.counterTimeout = null;

liveloop.generateCodePrologue = function()
{
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML+RDFa 1.0//EN\" \"http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:dc=\"http://purl.org/dc/terms/\">\n <head>\n <title>Test Snippet</title>\n </head>\n <body>\n";
Expand Down Expand Up @@ -35,10 +38,38 @@
{
liveloop.setupCodePrologue();
liveloop.setupCodeEpilogue();
$("#code-body").keyup(liveloop.updateTriples);
$("#code-body").keyup(liveloop.checkCounter);
};

liveloop.checkCounter = function(event)
{
if(event)
{
liveloop.counter = 1;
}
else
{
liveloop.counter--;
}

if(liveloop.counter <= 0)
{
$("#loading").hide();
liveloop.updateTriples();
}
else
{
$("#loading").show();
if(liveloop.counterTimeout)
{
clearTimeout(liveloop.counterTimeout);
}
liveloop.counterTimeout = setTimeout(liveloop.checkCounter, 1000);
}
};


liveloop.updateTriples = function(event)
liveloop.updateTriples = function()
{
var rdfaDocument = liveloop.generateCodePrologue() +
$("#code-body").val() + liveloop.generateCodeEpilogue();
Expand Down
Binary file added loading.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit af82e52

Please sign in to comment.