From f41bb44b89841184ac8a5da9d3b7dfe7ba51db44 Mon Sep 17 00:00:00 2001 From: zimocode Date: Mon, 1 Jul 2019 20:28:10 +0800 Subject: [PATCH 1/5] new mini-apps: convert case --- _locales/en/messages.json | 9 ++++++++ _locales/zh_CN/messages.json | 9 ++++++++ change.log | 7 ++++++ css/inject/convertcase.css | 12 ++++++++++ js/background.js | 7 ++++-- js/inject/convertcase.js | 43 ++++++++++++++++++++++++++++++++++++ manifest.json | 2 +- 7 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 css/inject/convertcase.css create mode 100644 js/inject/convertcase.js diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 527d8c0..0e28d89 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1484,5 +1484,14 @@ }, "pxmovie":{ "message":"Poxiao Movie recent update" + }, + "convertcase":{ + "message":"Convert Case" + }, + "btn_upper":{ + "message":"UPPER CASE" + }, + "btn_lower":{ + "message":"LOWER CASE" } } \ No newline at end of file diff --git a/_locales/zh_CN/messages.json b/_locales/zh_CN/messages.json index d32e160..bb9e0f7 100644 --- a/_locales/zh_CN/messages.json +++ b/_locales/zh_CN/messages.json @@ -1453,5 +1453,14 @@ }, "pxmovie":{ "message":"破晓电影最近更新" + }, + "convertcase":{ + "message":"大小写字母转换" + }, + "btn_upper":{ + "message":"大写" + }, + "btn_lower":{ + "message":"小写" } } \ No newline at end of file diff --git a/change.log b/change.log index e274481..748c3a8 100644 --- a/change.log +++ b/change.log @@ -1,5 +1,12 @@ { "log": [ + { + "ver":"6.3.770.882", + "date":"2019.07.01", + "content":[ + "new mini-apps: convert case" + ] + }, { "ver":"6.3.770.881", "date":"2019.06.30", diff --git a/css/inject/convertcase.css b/css/inject/convertcase.css new file mode 100644 index 0000000..63b4cd0 --- /dev/null +++ b/css/inject/convertcase.css @@ -0,0 +1,12 @@ +smartup.su_apps#su_apps_convertcase .su_convertcase_box{ + text-align: center; + padding: 8px; +} +smartup.su_apps#su_apps_convertcase textarea{ + width: 240px; + height: 60px; +} +smartup.su_apps#su_apps_convertcase button{ + display: inline-block; + margin: 8px; +} \ No newline at end of file diff --git a/js/background.js b/js/background.js index 4542619..fcaa988 100644 --- a/js/background.js +++ b/js/background.js @@ -2318,7 +2318,10 @@ var sub={ }, //mini apps - + convertcase:function(){ + var _appname="convertcase"; + sub.insertTest(_appname); + }, pxmovie:function(){ var _appname="pxmovie"; sub.insertTest(_appname); @@ -2441,7 +2444,7 @@ var sub={ var _appname="appslist"; sub.initAppconf(_appname); var _obj={} - _obj.apps=["rss","tablist","random","extmgm","recentbk","recentht","recentclosed","synced","base64","qr","numc","speaker","jslist","lottery"]; + _obj.apps=["rss","tablist","random","extmgm","recentbk","recentht","recentclosed","synced","base64","qr","numc","speaker","jslist","lottery","convertcase"]; chrome.tabs.saveAsPDF?_obj.apps.push("savepdf"):null; sub.cons[_appname]=_obj; sub.insertTest(_appname); diff --git a/js/inject/convertcase.js b/js/inject/convertcase.js new file mode 100644 index 0000000..b72a58b --- /dev/null +++ b/js/inject/convertcase.js @@ -0,0 +1,43 @@ +console.log("convertcase"); +sue.apps.convertcase={ + cons:{}, + initUI:function(){ + let appInfo={ + appName:"convertcase", + headTitle:"convertcase", + headCloseBtn:true + } + sue.apps.init(); + var dom=sue.apps.initBox(appInfo); + dom.id="su_apps_"+appInfo.appName; + sue.apps[appInfo.appName].dom=dom; + sue.apps.initPos(dom); + + let theAppBox=sue.apps.domCreate("div",{setName:["className"],setValue:["su_convertcase_box"]}); + dom.querySelector(".su_main").appendChild(theAppBox); + + let _boxIn=sue.apps.domCreate("textarea",{setName:["id"],setValue:["convertcase_textarea_in"]}), + _btnU=sue.apps.domCreate("button",{setName:["id"],setValue:["convertcase_btn_upper"]},null,null,null,sue.apps.i18n("btn_upper")), + _btnL=sue.apps.domCreate("button",{setName:["id"],setValue:["convertcase_btn_lower"]},null,null,null,sue.apps.i18n("btn_lower")), + _boxOut=sue.apps.domCreate("textarea",{setName:["id"],setValue:["convertcase_textarea_out"]}); + + theAppBox.appendChild(_boxIn); + theAppBox.appendChild(sue.apps.domCreate("br")); + theAppBox.appendChild(_btnU); + theAppBox.appendChild(_btnL); + theAppBox.appendChild(sue.apps.domCreate("br")); + theAppBox.appendChild(_boxOut); + dom.addEventListener("click",this.handleEvent,false); + }, + handleEvent:function(e){ + switch(e.type){ + case"click": + if(e.target.id=="convertcase_btn_upper"){ + sue.apps.convertcase.dom.querySelector("#convertcase_textarea_out").value=sue.apps.convertcase.dom.querySelector("#convertcase_textarea_in").value.toUpperCase(); + }else if(e.target.id=="convertcase_btn_lower"){ + sue.apps.convertcase.dom.querySelector("#convertcase_textarea_out").value=sue.apps.convertcase.dom.querySelector("#convertcase_textarea_in").value.toLowerCase(); + } + } + } +} +sue.apps.convertcase.initUI(); diff --git a/manifest.json b/manifest.json index 23d43f8..1b79332 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "minimum_chrome_version": "22", "name": "smartUp Gestures(Beta)", "short_name":"smartUp", - "version": "6.3.744.881", + "version": "6.3.744.882", "description": "__MSG_ext_des__", "default_locale": "en", "author":"zimo", From 6863276686747a94f49c2c103d7b5d37dad5a094 Mon Sep 17 00:00:00 2001 From: zimocode Date: Fri, 5 Jul 2019 21:30:33 +0800 Subject: [PATCH 2/5] new mini-apps: auto reload 0 --- _locales/en/messages.json | 9 +++++ css/apps_basic.css | 3 +- css/inject/autoreload.css | 41 ++++++++++++++++++++++ js/actions.js | 2 ++ js/background.js | 23 ++++++++++-- js/inject/autoreload.js | 74 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 149 insertions(+), 3 deletions(-) create mode 100644 css/inject/autoreload.css create mode 100644 js/inject/autoreload.js diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 0e28d89..1c5f5e4 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1493,5 +1493,14 @@ }, "btn_lower":{ "message":"LOWER CASE" + }, + "btn_start":{ + "message":"START" + }, + "autoreload":{ + "message":"Auto Reload" + }, + "autoreload_interval":{ + "message":"Reload intervals in seconds:" } } \ No newline at end of file diff --git a/css/apps_basic.css b/css/apps_basic.css index 7d4bf59..b1283d6 100644 --- a/css/apps_basic.css +++ b/css/apps_basic.css @@ -28,7 +28,8 @@ smartup.su_apps a{ } -smartup.su_apps input[type=text]{ +smartup.su_apps input[type=text], +smartup.su_apps input[type=number]{ border: 1px solid #d0d9ff; height: 26px; border-radius: 3px; diff --git a/css/inject/autoreload.css b/css/inject/autoreload.css new file mode 100644 index 0000000..e39244e --- /dev/null +++ b/css/inject/autoreload.css @@ -0,0 +1,41 @@ +smartup.su_apps#su_apps_autoreload .su_autoreload_box{ + width: 320px; + padding: 8px; + text-align: center; +} +smartup.su_apps#su_apps_autoreload .su_autoreload_box::after{ + content: ""; + clear: both; +} +smartup.su_apps#su_apps_autoreload input[type=number]{ + height: 20px; + width: 80px; + padding: 0; + margin: 4px 0 6px 0; +} +smartup.su_apps#su_apps_autoreload #divleft{ + float: left; + padding-right: 8px; + border-right: 1px solid #cccccc54; + margin-bottom: 8px; +} +smartup.su_apps#su_apps_autoreload #btnbox{ + margin: 8px 0; +} +smartup.su_apps#su_apps_autoreload #countdownbox{ + border: 1px solid red; + height: 64px; + width: 64px; + border-radius: 50%; + float: right; + line-height: 64px; + position: absolute; + top: 32px; + right: 16px; +} +smartup.su_apps#su_apps_autoreload #desbox{ + clear: both; + text-align: left; + font-size: 12px; + color: #777; +} \ No newline at end of file diff --git a/js/actions.js b/js/actions.js index 88c6c0e..eeab390 100644 --- a/js/actions.js +++ b/js/actions.js @@ -94,6 +94,8 @@ let actions={ {name:"jslist"}, {name:"savepdf"}, {name:"lottery"}, + {name:"convertcase"}, + {name:"autoreload"}, {name:"appslist"} /*{name:"gmail"}, {name:"ary"}, diff --git a/js/background.js b/js/background.js index fcaa988..8f1959d 100644 --- a/js/background.js +++ b/js/background.js @@ -2318,6 +2318,10 @@ var sub={ }, //mini apps + autoreload:function(){ + var _appname="autoreload"; + sub.insertTest(_appname); + }, convertcase:function(){ var _appname="convertcase"; sub.insertTest(_appname); @@ -2444,7 +2448,7 @@ var sub={ var _appname="appslist"; sub.initAppconf(_appname); var _obj={} - _obj.apps=["rss","tablist","random","extmgm","recentbk","recentht","recentclosed","synced","base64","qr","numc","speaker","jslist","lottery","convertcase"]; + _obj.apps=["rss","tablist","random","extmgm","recentbk","recentht","recentclosed","synced","base64","qr","numc","speaker","jslist","lottery","convertcase","autoreload"]; chrome.tabs.saveAsPDF?_obj.apps.push("savepdf"):null; sub.cons[_appname]=_obj; sub.insertTest(_appname); @@ -3698,6 +3702,19 @@ var sub={ sub.apps[message.app][message.action](message,sendResponse); }, apps:{ + autoreload:{ + reload:function(message,sender,sendResponse){ + if(message.value.type=="start"){ + if(!sub.cons.autoreload){sub.cons.autoreload={}} + window.clearInterval(sub.cons.autoreload[sender.tab.id]); + sub.cons.autoreload[sender.tab.id]=window.setInterval(function(){ + chrome.tabs.reload(sender.tab.id); + },message.value.interval*1000) + }else{ + window.clearInterval(sub.cons.autoreload[sender.tab.id]); + } + } + }, rss:{ getMessage:function(message,sender,sendResponse){ console.log(message); @@ -4182,7 +4199,9 @@ chrome.tabs.onUpdated.addListener(function(tabId,changeInfo,tab){ } }); } - +}) +chrome.tabs.onRemoved.addListener(function(tabId){ + (sub.cons.autoreload&&sub.cons.autoreload[tabId])?window.clearInterval(sub.cons.autoreload[tabId]):null; }) chrome.runtime.onMessageExternal.addListener(function(message,sender,sendResponse){ sub.funOnMessage(message,sender,sendResponse); diff --git a/js/inject/autoreload.js b/js/inject/autoreload.js new file mode 100644 index 0000000..938590b --- /dev/null +++ b/js/inject/autoreload.js @@ -0,0 +1,74 @@ +console.log("autoreload"); +sue.apps.autoreload={ + cons:{}, + initUI:function(){ + let appInfo={ + appName:"autoreload", + headTitle:"autoreload", + headCloseBtn:true, + menu:[ + {src:"/image/options.png",title:"app_tip_opt",className:"menu_item menu_item_opt"} + ], + options:[ + {type:"checkbox",label:"n_closebox",name:"n_closebox",checked:true} + ] + } + sue.apps.init(); + var dom=sue.apps.initBox(appInfo); + dom.id="su_apps_"+appInfo.appName; + sue.apps[appInfo.appName].dom=dom; + sue.apps.initPos(dom); + + let theAppBox=sue.apps.domCreate("div",{setName:["className"],setValue:["su_autoreload_box"]}); + dom.querySelector(".su_main").appendChild(theAppBox); + + let _textDes=sue.apps.domCreate("div",null,null,"text-align:left;",null,sue.apps.i18n("autoreload_interval")), + _text=sue.apps.domCreate("input",{setName:["id","type","min","value"],setValue:["interval","number","1","10"]}), + + _divCache=sue.apps.domCreate("div",null,null,"text-align:left;"), + _checkCache=sue.apps.domCreate("input",{setName:["id","type"],setValue:["autoreload_cache","checkbox"]}), + _labelCache=sue.apps.domCreate("label",{setName:["for"],setValue:["autoreload_cache"]},null,null,null,"Bypass cache."), + + _btn=sue.apps.domCreate("div",{setName:["id"],setValue:["btnbox"]}), + _btnStart=sue.apps.domCreate("button",{setName:["className","id"],setValue:["btn","start"]},null,null,null,sue.apps.i18n("btn_start")), + _btnStop=sue.apps.domCreate("button",{setName:["className","id"],setValue:["btn","stop"]},null,null,null,sue.apps.i18n("btn_stop")), + + _des=sue.apps.domCreate("div",{setName:["id"],setValue:["desbox"]},null,null,null,"*"+"Click the button 'STOP' or close current tab to disable the auto reload"), + + _countdownBox=sue.apps.domCreate("div",{setName:["id"],setValue:["countdownbox"]}), + _countdown=sue.apps.domCreate("span",{setName:["id"],setValue:["countdown"]},null,null,null,"0"), + _divLeft=sue.apps.domCreate("div",{setName:["id"],setValue:["divleft"]}); + _divLeft.appendChild(_textDes); + _divLeft.appendChild(_text); + + _divCache.appendChild(_checkCache); + _divCache.appendChild(_labelCache); + _divLeft.appendChild(_divCache); + + _btn.appendChild(_btnStart); + _btn.appendChild(_btnStop); + _divLeft.appendChild(_btn); + + theAppBox.appendChild(_divLeft); + + _countdownBox.appendChild(_countdown); + theAppBox.appendChild(_countdownBox); + theAppBox.appendChild(_des); + + dom.addEventListener("click",this.handleEvent,false); + }, + handleEvent:function(e){ + switch(e.type){ + case"click": + if(e.target.classList.contains("btn")){ + chrome.runtime.sendMessage({type:"appsAction",app:"autoreload",action:"reload",value:{type:e.target.id,interval:sue.apps.autoreload.dom.querySelector("#interval").value}}) + } + } + } +} +// chrome.runtime.sendMessage({type:"apps_getvalue",apptype:"appslist"},function(response){ +// sue.apps.appslist.config=response.config; +// sue.apps.appslist.apps=response.value.apps; +// sue.apps.appslist.initUI(); +// }) +sue.apps.autoreload.initUI(); From 53b046f42662c6b453b747841485219dbf27cb8e Mon Sep 17 00:00:00 2001 From: zimocode Date: Thu, 11 Jul 2019 22:24:41 +0800 Subject: [PATCH 3/5] new mini-apps: auto reload 1 --- js/background.js | 30 ++++++++++++++++++++++++++---- manifest.json | 4 ++-- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/js/background.js b/js/background.js index 8f1959d..f1d49b6 100644 --- a/js/background.js +++ b/js/background.js @@ -3705,11 +3705,29 @@ var sub={ autoreload:{ reload:function(message,sender,sendResponse){ if(message.value.type=="start"){ - if(!sub.cons.autoreload){sub.cons.autoreload={}} - window.clearInterval(sub.cons.autoreload[sender.tab.id]); - sub.cons.autoreload[sender.tab.id]=window.setInterval(function(){ + if(!sub.cons.autoreload){ + sub.cons.autoreload={}; + sub.cons.autoreload[sender.tab.id]={}; + } + window.clearInterval(sub.cons.autoreload[sender.tab.id].timer); + + sub.cons.autoreload[sender.tab.id].interval=message.value.interval; + sub.cons.autoreload[sender.tab.id].countDown=window.setInterval(function(){ + sub.cons.autoreload[sender.tab.id].interval--; + chrome.browserAction.setBadgeText({text:sub.cons.autoreload[sender.tab.id].interval.toString(),tabId:sender.tab.id}); + },1000) + sub.cons.autoreload[sender.tab.id].timer=window.setInterval(function(){ chrome.tabs.reload(sender.tab.id); + sub.cons.autoreload[sender.tab.id].interval=message.value.interval; + sub.cons.autoreload[sender.tab.id].countDown=window.setInterval(function(){ + sub.cons.autoreload[sender.tab.id].interval--; + chrome.browserAction.setBadgeText({text:sub.cons.autoreload[sender.tab.id].interval.toString(),tabId:sender.tab.id}); + },1000) + //sub.cons.autoreload[sender.tab.id].interval=message.value.interval; },message.value.interval*1000) + + + }else{ window.clearInterval(sub.cons.autoreload[sender.tab.id]); } @@ -4201,7 +4219,11 @@ chrome.tabs.onUpdated.addListener(function(tabId,changeInfo,tab){ } }) chrome.tabs.onRemoved.addListener(function(tabId){ - (sub.cons.autoreload&&sub.cons.autoreload[tabId])?window.clearInterval(sub.cons.autoreload[tabId]):null; + if(sub.cons.autoreload&&sub.cons.autoreload[tabId]){ + window.clearInterval(sub.cons.autoreload[tabId].timer); + window.clearInterval(sub.cons.autoreload[tabId].countDown); + } + //(sub.cons.autoreload&&sub.cons.autoreload[tabId])?window.clearInterval(sub.cons.autoreload[tabId]):null; }) chrome.runtime.onMessageExternal.addListener(function(message,sender,sendResponse){ sub.funOnMessage(message,sender,sendResponse); diff --git a/manifest.json b/manifest.json index 1b79332..1843dd9 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "minimum_chrome_version": "22", "name": "smartUp Gestures(Beta)", "short_name":"smartUp", - "version": "6.3.744.882", + "version": "6.3.744.883", "description": "__MSG_ext_des__", "default_locale": "en", "author":"zimo", @@ -43,5 +43,5 @@ ], "incognito": "split", "permissions": ["tabs","","notifications","storage","contextMenus","tts"], - "optional_permissions": ["downloads","downloads.shelf","clipboardRead","clipboardWrite","bookmarks","history","management","sessions","pageCapture","background","browserSettings"] + "optional_permissions": ["downloads","downloads.shelf","clipboardRead","clipboardWrite","bookmarks","history","management","sessions","pageCapture","background"] } \ No newline at end of file From c23be048ec16ddda24dcf4083266d435ad1d1ba8 Mon Sep 17 00:00:00 2001 From: zimocode Date: Sun, 14 Jul 2019 11:11:26 +0800 Subject: [PATCH 4/5] new mini-apps: auto reload. --- _locales/en/messages.json | 6 ++++ _locales/zh_CN/messages.json | 15 ++++++++ change.log | 6 ++-- css/inject/autoreload.css | 23 ++++++++----- js/background.js | 51 +++++++++++++++++---------- js/inject/autoreload.js | 67 ++++++++++++++++++++++++------------ manifest.json | 2 +- manifest_note | 2 +- 8 files changed, 119 insertions(+), 53 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 1c5f5e4..467112a 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -1502,5 +1502,11 @@ }, "autoreload_interval":{ "message":"Reload intervals in seconds:" + }, + "autoreload_cache":{ + "message":"Bypass cache" + }, + "autoreload_icon":{ + "message":"Show countdown on icon" } } \ No newline at end of file diff --git a/_locales/zh_CN/messages.json b/_locales/zh_CN/messages.json index bb9e0f7..ce2f0fd 100644 --- a/_locales/zh_CN/messages.json +++ b/_locales/zh_CN/messages.json @@ -1462,5 +1462,20 @@ }, "btn_lower":{ "message":"小写" + }, + "btn_start":{ + "message":"开始" + }, + "autoreload":{ + "message":"自动刷新" + }, + "autoreload_interval":{ + "message":"刷新间隔时间(秒):" + }, + "autoreload_cache":{ + "message":"忽略本地缓存" + }, + "autoreload_icon":{ + "message":"在扩展图标上显示刷新倒计时" } } \ No newline at end of file diff --git a/change.log b/change.log index 748c3a8..6c16ac1 100644 --- a/change.log +++ b/change.log @@ -1,10 +1,10 @@ { "log": [ { - "ver":"6.3.770.882", - "date":"2019.07.01", + "ver":"6.3.873.886", + "date":"2019.07.14", "content":[ - "new mini-apps: convert case" + "new mini-apps: convert case, auto reload." ] }, { diff --git a/css/inject/autoreload.css b/css/inject/autoreload.css index e39244e..f7c1b62 100644 --- a/css/inject/autoreload.css +++ b/css/inject/autoreload.css @@ -1,5 +1,5 @@ smartup.su_apps#su_apps_autoreload .su_autoreload_box{ - width: 320px; + width: 360px; padding: 8px; text-align: center; } @@ -13,27 +13,34 @@ smartup.su_apps#su_apps_autoreload input[type=number]{ padding: 0; margin: 4px 0 6px 0; } -smartup.su_apps#su_apps_autoreload #divleft{ - float: left; +smartup.su_apps#su_apps_autoreload #su_autoreload_divleft{ + /*float: left;*/ + margin-right: 85px; padding-right: 8px; border-right: 1px solid #cccccc54; margin-bottom: 8px; } -smartup.su_apps#su_apps_autoreload #btnbox{ +smartup.su_apps#su_apps_autoreload #su_autoreload_interval{ + padding-left: 8px; +} +smartup.su_apps#su_apps_autoreload #su_autoreload_btnbox{ margin: 8px 0; } -smartup.su_apps#su_apps_autoreload #countdownbox{ - border: 1px solid red; +smartup.su_apps#su_apps_autoreload #su_autoreload_countdownbox{ + /*border: 1px solid red;*/ height: 64px; width: 64px; border-radius: 50%; - float: right; + /*float: right;*/ line-height: 64px; position: absolute; top: 32px; right: 16px; + background-color: #597afc; + color: #fff; + font-weight: bold; } -smartup.su_apps#su_apps_autoreload #desbox{ +smartup.su_apps#su_apps_autoreload #su_autoreload_desbox{ clear: both; text-align: left; font-size: 12px; diff --git a/js/background.js b/js/background.js index f1d49b6..1bba7c3 100644 --- a/js/background.js +++ b/js/background.js @@ -2320,6 +2320,7 @@ var sub={ //mini apps autoreload:function(){ var _appname="autoreload"; + sub.initAppconf(_appname); sub.insertTest(_appname); }, convertcase:function(){ @@ -3708,29 +3709,43 @@ var sub={ if(!sub.cons.autoreload){ sub.cons.autoreload={}; sub.cons.autoreload[sender.tab.id]={}; + }else if(!sub.cons.autoreload[sender.tab.id]){ + sub.cons.autoreload[sender.tab.id]={}; } - window.clearInterval(sub.cons.autoreload[sender.tab.id].timer); - - sub.cons.autoreload[sender.tab.id].interval=message.value.interval; - sub.cons.autoreload[sender.tab.id].countDown=window.setInterval(function(){ - sub.cons.autoreload[sender.tab.id].interval--; - chrome.browserAction.setBadgeText({text:sub.cons.autoreload[sender.tab.id].interval.toString(),tabId:sender.tab.id}); - },1000) - sub.cons.autoreload[sender.tab.id].timer=window.setInterval(function(){ - chrome.tabs.reload(sender.tab.id); - sub.cons.autoreload[sender.tab.id].interval=message.value.interval; + this.clear(message,sender,sendResponse); + sub.cons.autoreload[sender.tab.id].timeRemain=message.value.interval; + sub.cons.autoreload[sender.tab.id].iconCountdown=message.value.iconCountdown; + sub.cons.autoreload[sender.tab.id].bypassCache=message.value.bypassCache; + + if(sub.cons.autoreload[sender.tab.id].iconCountdown){ + chrome.browserAction.setBadgeText({text:sub.cons.autoreload[sender.tab.id].timeRemain.toString(),tabId:sender.tab.id}); + sub.cons.autoreload[sender.tab.id].countDown=window.setInterval(function(){ + sub.cons.autoreload[sender.tab.id].timeRemain--; + chrome.browserAction.setBadgeText({text:sub.cons.autoreload[sender.tab.id].timeRemain.toString(),tabId:sender.tab.id}); + },1000); + }else{ sub.cons.autoreload[sender.tab.id].countDown=window.setInterval(function(){ - sub.cons.autoreload[sender.tab.id].interval--; - chrome.browserAction.setBadgeText({text:sub.cons.autoreload[sender.tab.id].interval.toString(),tabId:sender.tab.id}); - },1000) - //sub.cons.autoreload[sender.tab.id].interval=message.value.interval; + sub.cons.autoreload[sender.tab.id].timeRemain--; + },1000) + } + sub.cons.autoreload[sender.tab.id].timer=window.setInterval(function(){ + chrome.tabs.reload(sender.tab.id,{bypassCache:sub.cons.autoreload[sender.tab.id].bypassCache}); + sub.cons.autoreload[sender.tab.id].timeRemain=message.value.interval+1; },message.value.interval*1000) - - - }else{ - window.clearInterval(sub.cons.autoreload[sender.tab.id]); + this.clear(message,sender,sendResponse); } + }, + clear:function(message,sender,sendResponse){ + if(sub.cons.autoreload&&sub.cons.autoreload[sender.tab.id]){ + window.clearInterval(sub.cons.autoreload[sender.tab.id].timer); + window.clearInterval(sub.cons.autoreload[sender.tab.id].countDown); + sub.cons.autoreload[sender.tab.id].timeRemain=0; + } + chrome.browserAction.setBadgeText({text:"",tabId:sender.tab.id}); + }, + getConf:function(message,sender,sendResponse){ + sendResponse({config:config.apps[message.app],value:sub.cons[message.app],tabId:sender.tab.id}); } }, rss:{ diff --git a/js/inject/autoreload.js b/js/inject/autoreload.js index 938590b..9194d9a 100644 --- a/js/inject/autoreload.js +++ b/js/inject/autoreload.js @@ -5,13 +5,7 @@ sue.apps.autoreload={ let appInfo={ appName:"autoreload", headTitle:"autoreload", - headCloseBtn:true, - menu:[ - {src:"/image/options.png",title:"app_tip_opt",className:"menu_item menu_item_opt"} - ], - options:[ - {type:"checkbox",label:"n_closebox",name:"n_closebox",checked:true} - ] + headCloseBtn:true } sue.apps.init(); var dom=sue.apps.initBox(appInfo); @@ -23,21 +17,24 @@ sue.apps.autoreload={ dom.querySelector(".su_main").appendChild(theAppBox); let _textDes=sue.apps.domCreate("div",null,null,"text-align:left;",null,sue.apps.i18n("autoreload_interval")), - _text=sue.apps.domCreate("input",{setName:["id","type","min","value"],setValue:["interval","number","1","10"]}), + _text=sue.apps.domCreate("input",{setName:["id","type","min","value"],setValue:["su_autoreload_interval","number","1","10"]}), _divCache=sue.apps.domCreate("div",null,null,"text-align:left;"), - _checkCache=sue.apps.domCreate("input",{setName:["id","type"],setValue:["autoreload_cache","checkbox"]}), - _labelCache=sue.apps.domCreate("label",{setName:["for"],setValue:["autoreload_cache"]},null,null,null,"Bypass cache."), + _checkCache=sue.apps.domCreate("input",{setName:["id","type","checked"],setValue:["su_autoreload_cache","checkbox",false]}), + _labelCache=sue.apps.domCreate("label",{setName:["for"],setValue:["su_autoreload_cache"]},null,null,null,sue.apps.i18n("autoreload_cache")), + _divIcon=sue.apps.domCreate("div",null,null,"text-align:left;"), + _checkIcon=sue.apps.domCreate("input",{setName:["id","type","checked"],setValue:["su_autoreload_icon","checkbox",true]}), + _labelIcon=sue.apps.domCreate("label",{setName:["for"],setValue:["su_autoreload_icon"]},null,null,null,sue.apps.i18n("autoreload_icon")), - _btn=sue.apps.domCreate("div",{setName:["id"],setValue:["btnbox"]}), + _btn=sue.apps.domCreate("div",{setName:["id"],setValue:["su_autoreload_btnbox"]}), _btnStart=sue.apps.domCreate("button",{setName:["className","id"],setValue:["btn","start"]},null,null,null,sue.apps.i18n("btn_start")), _btnStop=sue.apps.domCreate("button",{setName:["className","id"],setValue:["btn","stop"]},null,null,null,sue.apps.i18n("btn_stop")), - _des=sue.apps.domCreate("div",{setName:["id"],setValue:["desbox"]},null,null,null,"*"+"Click the button 'STOP' or close current tab to disable the auto reload"), + _des=sue.apps.domCreate("div",{setName:["id"],setValue:["su_autoreload_desbox"]},null,null,null,"*"+"Click the button 'STOP' or close current tab to disable the auto reload"), - _countdownBox=sue.apps.domCreate("div",{setName:["id"],setValue:["countdownbox"]}), - _countdown=sue.apps.domCreate("span",{setName:["id"],setValue:["countdown"]},null,null,null,"0"), - _divLeft=sue.apps.domCreate("div",{setName:["id"],setValue:["divleft"]}); + _countdownBox=sue.apps.domCreate("div",{setName:["id"],setValue:["su_autoreload_countdownbox"]}), + _countdown=sue.apps.domCreate("span",{setName:["id"],setValue:["su_autoreload_countdown"]},null,null,null,"0"), + _divLeft=sue.apps.domCreate("div",{setName:["id"],setValue:["su_autoreload_divleft"]}); _divLeft.appendChild(_textDes); _divLeft.appendChild(_text); @@ -45,6 +42,10 @@ sue.apps.autoreload={ _divCache.appendChild(_labelCache); _divLeft.appendChild(_divCache); + _divIcon.appendChild(_checkIcon); + _divIcon.appendChild(_labelIcon); + _divLeft.appendChild(_divIcon); + _btn.appendChild(_btnStart); _btn.appendChild(_btnStop); _divLeft.appendChild(_btn); @@ -55,20 +56,42 @@ sue.apps.autoreload={ theAppBox.appendChild(_countdownBox); theAppBox.appendChild(_des); + if(sue.apps.autoreload.value&&sue.apps.autoreload.tabId&&sue.apps.autoreload.value[sue.apps.autoreload.tabId]&&sue.apps.autoreload.value[sue.apps.autoreload.tabId].timeRemain){ + sue.apps.autoreload.timeRemain=sue.apps.autoreload.value[sue.apps.autoreload.tabId].timeRemain-1; + sue.apps.autoreload.timerOn(); + } dom.addEventListener("click",this.handleEvent,false); }, handleEvent:function(e){ switch(e.type){ case"click": if(e.target.classList.contains("btn")){ - chrome.runtime.sendMessage({type:"appsAction",app:"autoreload",action:"reload",value:{type:e.target.id,interval:sue.apps.autoreload.dom.querySelector("#interval").value}}) + chrome.runtime.sendMessage({type:"appsAction",app:"autoreload",action:"reload",value:{type:e.target.id,interval:parseInt(sue.apps.autoreload.dom.querySelector("#su_autoreload_interval").value),iconCountdown:sue.apps.autoreload.dom.querySelector("#su_autoreload_icon").checked,bypassCache:sue.apps.autoreload.dom.querySelector("#su_autoreload_cache").checked}}); + if(e.target.id=="start"){ + sue.apps.autoreload.timerClear(); + sue.apps.autoreload.timeRemain=parseInt(sue.apps.autoreload.dom.querySelector("#su_autoreload_interval").value); + sue.apps.autoreload.timerOn(); + }else{ + sue.apps.autoreload.timerClear(); + } } } + }, + timerOn:function(){ + let _countdown=sue.apps.autoreload.dom.querySelector("#su_autoreload_countdown"); + _countdown.textContent=sue.apps.autoreload.timeRemain; + sue.apps.autoreload.timer=window.setInterval(function(){ + sue.apps.autoreload.timeRemain--; + _countdown.textContent=sue.apps.autoreload.timeRemain; + },1000) + }, + timerClear:function(){ + window.clearInterval(sue.apps.autoreload.timer); } } -// chrome.runtime.sendMessage({type:"apps_getvalue",apptype:"appslist"},function(response){ -// sue.apps.appslist.config=response.config; -// sue.apps.appslist.apps=response.value.apps; -// sue.apps.appslist.initUI(); -// }) -sue.apps.autoreload.initUI(); +chrome.runtime.sendMessage({type:"appsAction",app:"autoreload",action:"getConf"},function(response){ + sue.apps.autoreload.config=response.config; + sue.apps.autoreload.value=response.value; + sue.apps.autoreload.tabId=response.tabId; + sue.apps.autoreload.initUI(); +}) diff --git a/manifest.json b/manifest.json index 1843dd9..80fa8c3 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "minimum_chrome_version": "22", "name": "smartUp Gestures(Beta)", "short_name":"smartUp", - "version": "6.3.744.883", + "version": "6.3.873.886", "description": "__MSG_ext_des__", "default_locale": "en", "author":"zimo", diff --git a/manifest_note b/manifest_note index 5f1676f..d83e0e2 100644 --- a/manifest_note +++ b/manifest_note @@ -2,7 +2,7 @@ //chrome "incognito": "split", "permissions": ["tabs","","notifications","storage","contextMenus","tts"], -"optional_permissions": ["downloads","downloads.shelf","clipboardRead","clipboardWrite","bookmarks","history","management","sessions","pageCapture","background","browserSettings"] +"optional_permissions": ["downloads","downloads.shelf","clipboardRead","clipboardWrite","bookmarks","history","management","sessions","pageCapture","background"] //firefox "permissions": ["tabs","","notifications","storage","contextMenus","tts","downloads","downloads.shelf","clipboardRead","clipboardWrite","bookmarks","history","management","sessions","pageCapture","background"], From 1879007887eaccf8d9cbefb81650c3742bff95bb Mon Sep 17 00:00:00 2001 From: zimocode Date: Sat, 27 Jul 2019 14:44:17 +0800 Subject: [PATCH 5/5] fix bugs: Can't add super drag for links and images --- _locales/en/messages.json | 4 ++-- _locales/it/messages.json | 4 ++-- _locales/ru/messages.json | 4 ++-- _locales/zh_CN/messages.json | 4 ++-- _locales/zh_TW/messages.json | 4 ++-- change.log | 7 ++++--- js/background.js | 1 - js/inject/pxmovie.js | 2 +- js/options.js | 9 ++++++++- manifest.json | 2 +- 10 files changed, 24 insertions(+), 17 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 467112a..3f72e15 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -918,10 +918,10 @@ "message": "This is a bunch of test text, select the text and drag to draw the line, and then select the action you need." }, "test_ldrg": { - "message": " This is a test link, drag the link and draw lines, and select action you need. " + "message": "This is a test link, drag the link and draw lines, and select action you need." }, "test_idrg": { - "message": "This is a test image, drag the image and draw the line, and then select the action you need: " + "message": "This is a test image, drag the image and draw the line, and then select the action you need: " }, "tip_actionname": { "message": "Customization action name" diff --git a/_locales/it/messages.json b/_locales/it/messages.json index 05830d2..2e69682 100644 --- a/_locales/it/messages.json +++ b/_locales/it/messages.json @@ -918,10 +918,10 @@ "message": "Questo è un testo d'esempio. Selezionare il testo e trascinare per tratteggiare la linea, e selezionare l'azione richiesta." }, "test_ldrg": { - "message": " Questo è un link d'esempio, trascinare il link e tratteggiare linee, e selezionare l'azione richiesta." + "message": "Questo è un link d'esempio, trascinare il link e tratteggiare linee, e selezionare l'azione richiesta." }, "test_idrg": { - "message": "Questa è un'immagine d'esempio. Trascinare l'immagine e tratteggiare la linea, e selezionare l'azione richiesta: " + "message": "Questa è un'immagine d'esempio. Trascinare l'immagine e tratteggiare la linea, e selezionare l'azione richiesta:" }, "tip_actionname": { "message": "Nome azione personalizzata" diff --git a/_locales/ru/messages.json b/_locales/ru/messages.json index 4226ca8..98e8b15 100644 --- a/_locales/ru/messages.json +++ b/_locales/ru/messages.json @@ -918,10 +918,10 @@ "message": "Это тестовый текст, выделите текст и потяните его, чтобы нарисовать линию, а затем выберите нужное действие." }, "test_ldrg": { - "message": " Это тестовая ссылка, перетащите ссылку и нарисуйте линию, а затем выберите нужное действие. " + "message": "Это тестовая ссылка, перетащите ссылку и нарисуйте линию, а затем выберите нужное действие." }, "test_idrg": { - "message": "Перетащите тестовую картинку нарисовав линию и затем выберите нужное действие. " + "message": "Перетащите тестовую картинку нарисовав линию и затем выберите нужное действие." }, "tip_actionname": { "message": "Настройки названия действия" diff --git a/_locales/zh_CN/messages.json b/_locales/zh_CN/messages.json index ce2f0fd..3087b7c 100644 --- a/_locales/zh_CN/messages.json +++ b/_locales/zh_CN/messages.json @@ -915,10 +915,10 @@ "message": "这是一段测试文本,选中文本并拖曳画线,然后选择你所需要的操作即可。" }, "test_ldrg": { - "message": "这是一个测试链接,拖动此链接并画线,然后选择你所需要的操作。" + "message": "这是一个测试链接,拖动此链接并画线,然后选择你所需要的操作。" }, "test_idrg": { - "message": "这是测试用图片,拖动改图片并画线,然后选择所需操作: " + "message": "这是测试用图片,拖动改图片并画线,然后选择所需操作:" }, "tip_actionname": { "message": "使用自定义操作名称" diff --git a/_locales/zh_TW/messages.json b/_locales/zh_TW/messages.json index 2d4fd49..2ceaa48 100644 --- a/_locales/zh_TW/messages.json +++ b/_locales/zh_TW/messages.json @@ -915,10 +915,10 @@ "message": "這是一些測試文字,選擇這些文字並拖曳畫出手勢,然後再選擇你需要的動作。" }, "test_ldrg": { - "message": " 這是測試連結,拖曳此連結並畫出手勢,然後選擇你需要的動作。 " + "message": "這是測試連結,拖曳此連結並畫出手勢,然後選擇你需要的動作。" }, "test_idrg": { - "message": "這是張測試圖片,拖曳此圖片並畫出手勢,然後選擇你需要的動作:" + "message": "這是張測試圖片,拖曳此圖片並畫出手勢,然後選擇你需要的動作:" }, "tip_actionname": { "message": "自定動作名稱" diff --git a/change.log b/change.log index 6c16ac1..37f12c5 100644 --- a/change.log +++ b/change.log @@ -1,10 +1,11 @@ { "log": [ { - "ver":"6.3.873.886", - "date":"2019.07.14", + "ver":"6.4.887.1001", + "date":"2019.07.27", "content":[ - "new mini-apps: convert case, auto reload." + "new mini-apps: convert case, auto reload.", + "fix bugs: Can't add super drag for links and images" ] }, { diff --git a/js/background.js b/js/background.js index 1bba7c3..d3af50b 100644 --- a/js/background.js +++ b/js/background.js @@ -2320,7 +2320,6 @@ var sub={ //mini apps autoreload:function(){ var _appname="autoreload"; - sub.initAppconf(_appname); sub.insertTest(_appname); }, convertcase:function(){ diff --git a/js/inject/pxmovie.js b/js/inject/pxmovie.js index 4043687..4c9b58b 100644 --- a/js/inject/pxmovie.js +++ b/js/inject/pxmovie.js @@ -68,7 +68,7 @@ sue.apps.pxmovie={ let _data=dom.querySelector(".data"), _loading=dom.querySelector(".loading"), _name=sue.domCreate("div",{setName:["className"],setValue:["name"]},null,null,null,value.name), - _back=sue.apps.domCreate("button",{setName:["className"],setValue:["back"]},null,"display: inline-block;",null,sue.apps.i18n("back")); + _back=sue.apps.domCreate("button",{setName:["className"],setValue:["back"]},null,"display: inline-block;",null,sue.apps.i18n("btn_back")); _info=sue.apps.domCreate("div",{setName:["className"],setValue:["info"]}); _data.textContent=""; _data.appendChild(_name); diff --git a/js/options.js b/js/options.js index c883734..876eaac 100644 --- a/js/options.js +++ b/js/options.js @@ -2390,6 +2390,13 @@ var suo={ } var testdes=suo.getI18n("test_"+((confArray[0]=="mges"||confArray[0]=="touch")?"mges":confArray[1])); var btnArray=["",suo.getI18n("btn_cancel"),suo.getI18n("btn_done")]; + let testDom=suo.domCreate2("div",{setName:["className"],setValue:["testbox"]},null,null,null,testdes); + if(confArray[1]=="ldrg"){ + testDom.textContent=""; + testDom.appendChild(suo.domCreate2("a",{setName:["href"],setValue:["###"]},null,null,null,suo.getI18n("test_ldrg"))); + }else if(confArray[1]=="idrg"){ + testDom.appendChild(suo.domCreate2("img",{setName:["src"],setValue:["../icon.png"]})); + } var addOBJ=suo.initAPPbox(btnArray,[480,320],suo.getI18n("title_newaction"),"bg"); addOBJ.classList.add("su_app_test"); addOBJ.dataset.confobj=confobj; @@ -2397,7 +2404,7 @@ var suo={ addOBJ.dataset.close="resetdirect"; addOBJ.dataset.actiontype=actionType; addOBJ.querySelectorAll("input[type=button]")[1].className="box_btn box_btn_next"; - addOBJ.querySelector(".box_content").appendChild(suo.domCreate2("div",{setName:["className"],setValue:["testbox"]},null,null,null,testdes)); + addOBJ.querySelector(".box_content").appendChild(testDom); //when adding drag text, set the test text can be drag. if(confArray[1]=="tdrg"){ addOBJ.style.cssText+="-webkit-user-select:text;-moz-user-select:text;user-select:text;"; diff --git a/manifest.json b/manifest.json index 80fa8c3..01034b6 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "minimum_chrome_version": "22", "name": "smartUp Gestures(Beta)", "short_name":"smartUp", - "version": "6.3.873.886", + "version": "6.4.887.1001", "description": "__MSG_ext_des__", "default_locale": "en", "author":"zimo",