From 8123900781037703d54730a6032b09745c69007f Mon Sep 17 00:00:00 2001 From: Andrew Branson Date: Mon, 21 Sep 2015 23:58:29 +0200 Subject: Support JS timers Add support for set and clear Intervals and Timeouts for Javascript apps. The QT JS engine doesn't support them natively. --- daemon/jskitmanager.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'daemon/jskitmanager.cpp') 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... -- cgit v1.2.3