@@ -27,33 +27,33 @@ Elm.worker = function(module, ports) {
27 return init(ElmRuntime.Display.NONE, {}, module, ports || {});
27 return init(ElmRuntime.Display.NONE, {}, module, ports || {});
30−/* OFFSET
30+function init(display, container, module, ports, moduleToReplace) {
31− * Elm's time traveling debugger lets you interrupt the smooth flow of time
31+ // defining state needed for an instance of the Elm RTS
32− * by pausing and continuing program execution. To ensure the user sees a
32+ var inputs = [];
33− * program that moves smoothly through the pause/continue time gap,
34− * we need to adjsut the value of Date.now().
36−Elm.timer = function() {
37− var inducedDelay = 0;
35+ * Elm's time traveling debugger lets you interrupt the smooth flow of time
36+ * by pausing and continuing program execution. To ensure the user sees a
37+ * program that moves smoothly through the pause/continue time gap,
38+ * we need to adjsut the value of Date.now().
39− var now = function() {
40+ var timer = function() {
40− return Date.now() - inducedDelay;
41+ var inducedDelay = 0;
43− var addDelay = function(d) {
43+ var now = function() {
45− inducedDelay += delay;
46− return inducedDelay;
44+ return Date.now() - inducedDelay;
49− return { now : now
47+ var addDelay = function(d) {
50− , addDelay : addDelay
48+ var delay = (d|0);
51− }
49+ inducedDelay += delay;
54−function init(display, container, module, ports, moduleToReplace) {
53+ return { now : now
55− // defining state needed for an instance of the Elm RTS
54+ , addDelay : addDelay
56− var inputs = [];
55+ }
58 var updateInProgress = false;
58 var updateInProgress = false;
59 function notify(id, v) {
59 function notify(id, v) {
@@ -64,7 +64,7 @@ function init(display, container, module, ports, moduleToReplace) {
64 'Definitely report this to <https://github.com/evancz/Elm/issues>\n');
64 'Definitely report this to <https://github.com/evancz/Elm/issues>\n');
66 updateInProgress = true;
66 updateInProgress = true;
67− var timestep = Elm.timer.now();
67+ var timestep = timer.now();
68 for (var i = inputs.length; i--; ) {
68 for (var i = inputs.length; i--; ) {
69 inputs[i].recv(timestep, id, v);
69 inputs[i].recv(timestep, id, v);
@@ -96,6 +96,7 @@ function init(display, container, module, ports, moduleToReplace) {
96 id:ElmRuntime.guid(),
96 id:ElmRuntime.guid(),
97 addListener:addListener,
97 addListener:addListener,
98 inputs:inputs,
98 inputs:inputs,
99 ports: { incoming:ports, outgoing:{}, uses:portUses }
100 ports: { incoming:ports, outgoing:{}, uses:portUses }