summaryrefslogtreecommitdiff
path: root/daemon/jskitmanager.cpp
diff options
context:
space:
mode:
authorAndrew Branson <andrew.branson@cern.ch>2015-09-21 23:58:29 +0200
committerAndrew Branson <andrew.branson@cern.ch>2015-09-21 23:58:29 +0200
commit8123900781037703d54730a6032b09745c69007f (patch)
treec72a0e446cb075ade41dd199a3d6822fa153e139 /daemon/jskitmanager.cpp
parente2c1fb71995cd799e83b7644140750454a3b5900 (diff)
Support JS timers
Add support for set and clear Intervals and Timeouts for Javascript apps. The QT JS engine doesn't support them natively.
Diffstat (limited to 'daemon/jskitmanager.cpp')
-rw-r--r--daemon/jskitmanager.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/daemon/jskitmanager.cpp b/daemon/jskitmanager.cpp
index 2da1986..a24ab10 100644
--- a/daemon/jskitmanager.cpp
+++ b/daemon/jskitmanager.cpp
@@ -155,8 +155,12 @@ void JSKitManager::startJsApp()
// Shims for compatibility...
QJSValue result = _engine->evaluate(
- "function XMLHttpRequest() { return Pebble.createXMLHttpRequest(); }\n"
- );
+ "function XMLHttpRequest() { return Pebble.createXMLHttpRequest(); }\n\
+ function setInterval(func, time) { return Pebble.setInterval(func, time); }\n\
+ function clearInterval(id) { Pebble.clearInterval(id); }\n\
+ function setTimeout(func, time) { return Pebble.setTimeout(func, time); }\n\
+ function clearTimeout(id) { Pebble.clearTimeout(id); }\n\
+ ");
Q_ASSERT(!result.isError());
// Polyfills...