From: jaekuk, lee Date: Thu, 16 Nov 2017 04:01:43 +0000 (+0900) Subject: Update AppManager & app timer X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e7f3534fdb4e712490722ea12b3fca6802f8f4bf;p=platform%2Fframework%2Fweb%2Fcrosswalk-tizen.git Update AppManager & app timer Change-Id: Id3d9ab73a4a9851024db9e95936bf826f08762c2 Signed-off-by: jaekuk, lee --- diff --git a/wrt/wrt_support/extensions_repo/app_timer/contentscript.js b/wrt/wrt_support/extensions_repo/app_timer/contentscript.js index c27a870..3f877bf 100755 --- a/wrt/wrt_support/extensions_repo/app_timer/contentscript.js +++ b/wrt/wrt_support/extensions_repo/app_timer/contentscript.js @@ -6,8 +6,19 @@ const EXIT_HTML = '\ '; //" -var defaultTime = {hours: 0, minutes: 0, seconds: 10}; -var jsonfile = require('jsonfile') +const TIME_HTML = '\ +
\ +
\ +00 \ +: \ +00 \ +: \ +00 \ +
\ +
'; + +var jsonfile = require('jsonfile'); +var jsonobj = {timerStart: false, time:{hours: 0, minutes: 0, seconds: 0}}; var filepath = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('apps_repo'))+'apps_repo/AppManager/data/timer.json'; var app_id = location.href.split('/'); @@ -19,6 +30,12 @@ port.onMessage.addListener(function(msg) { } else if (msg.background == "timer-update") { console.log('value, '+msg.value.time.hours+' : '+msg.value.time.minutes+' : '+msg.value.time.seconds); + jsonobj.time.hours = msg.value.time.hours; + jsonobj.time.minutes = msg.value.time.minutes; + jsonobj.time.seconds = msg.value.time.seconds; + document.getElementById('hours-digit').innerHTML = jsonobj.time.hours; + document.getElementById('minutes-digit').innerHTML = jsonobj.time.minutes; + document.getElementById('seconds-digit').innerHTML = jsonobj.time.seconds; } else if (msg.background == "timer-finish") { exitPopup(); @@ -34,22 +51,46 @@ jsonfile.readFile(filepath, function(err, obj) { return; } if (obj.timerStart==true) { + console.log('exitPopup: '+window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/'))); + jsonobj = obj; + if (obj.time.hours + obj.time.minutes + obj.time.seconds > 0) { + initialize(); + } + else { + exitPopup(); + } + } +}); - console.log('exitPopup: '+window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/'))); - +window.onbeforeunload = function() { + if (app_id[app_id.length - 2] == 'installer' + || app_id[app_id.length - 2] == 'launcher' + || app_id[app_id.length - 2] == 'extensions_settings' + || app_id[app_id.length - 2] == 'AppManager') { + console.log('Except for '+app_id[app_id.length - 2]); + return; + } + stop(); +} - - defaultTime = obj.time; - initialize(); +window.onkeydown = function(event) { + if (app_id[app_id.length - 2] == 'installer' + || app_id[app_id.length - 2] == 'launcher' + || app_id[app_id.length - 2] == 'extensions_settings' + || app_id[app_id.length - 2] == 'AppManager') { + console.log('Except for '+app_id[app_id.length - 2]); + return; } -}); + if (event.keyCode === 10009){ //esc + stop(); + } +} function exitPopup() { document.body.insertAdjacentHTML('beforeend', EXIT_HTML); + stop(); document.getElementById('exit-img').onclick= function(event) { console.log('exitPopup: '); - reset(); - stop(); var launcher = require('electron').remote.getCurrentWindow(); launcher.close(); }; @@ -61,12 +102,10 @@ function initialize() { } function start() { - var time = defaultTime; - console.log('start, '+time.hours+' : '+time.minutes+' : '+time.seconds); - if (time.hours + time.minutes + time.seconds > 0) { - port.postMessage({contentscript: "timer-setTime", value:defaultTime}); - port.postMessage({contentscript: "timer-start"}); - } + console.log('start, '+jsonobj.time.hours+' : '+jsonobj.time.minutes+' : '+jsonobj.time.seconds); + document.body.insertAdjacentHTML('beforebegin', TIME_HTML); + port.postMessage({contentscript: "timer-setTime", value:jsonobj.time}); + port.postMessage({contentscript: "timer-start"}); } function reset() { @@ -75,11 +114,14 @@ function reset() { function stop() { port.postMessage({contentscript: "timer-stop"}); + jsonfile.writeFile(filepath, jsonobj, function (err) { + console.error(err); + }); } function setTime(time) { console.log('setTime, '+time.defaultTime.hours+' : '+time.defaultTime.minutes+' : '+time.defaultTime.seconds); - defaultTime.hours = time.defaultTime.hours; - defaultTime.minutes = time.defaultTime.minutes; - defaultTime.seconds = time.defaultTime.seconds; + jsonobj.time.hours = time.defaultTime.hours; + jsonobj.time.minutes = time.defaultTime.minutes; + jsonobj.time.seconds = time.defaultTime.seconds; } diff --git a/wrt/wrt_support/extensions_repo/app_timer/style.css b/wrt/wrt_support/extensions_repo/app_timer/style.css index f24b663..20f5417 100755 --- a/wrt/wrt_support/extensions_repo/app_timer/style.css +++ b/wrt/wrt_support/extensions_repo/app_timer/style.css @@ -18,4 +18,28 @@ width: 400px; background-color: rgb(255,255,255); cursor: pointer; -} \ No newline at end of file +} +/*----------------------------------------------------*/ +#time-container { + margin-top: 2%; + margin-left: 2%; + height: auto; + width: 100px; + background: rgb(255,255,255); +} + +#timer-contents { + font-weight: bold; + font-size: 20px; + padding: 5px; + text-align: center; +} + +.colon { + display: inline-block; + vertical-align: top; +} + +.digit { + vertical-align: middle; +} diff --git a/wrt/wrt_support/sample/wgt/AppManager.wgt b/wrt/wrt_support/sample/wgt/AppManager.wgt index b19d908..27f3e8d 100755 Binary files a/wrt/wrt_support/sample/wgt/AppManager.wgt and b/wrt/wrt_support/sample/wgt/AppManager.wgt differ