From 51f2df930da6054125ab2f119e32ab729e073a9d Mon Sep 17 00:00:00 2001
From: Tamius Han
Date: Tue, 13 Mar 2018 00:36:10 +0100
Subject: [PATCH] end of the day commit. settings for autoAr ARE NOT getting
saved.
---
js/uw-bg.js | 23 ++++++++++++++++++
manifest.json | 5 ----
res/popup/js/popup.js | 54 ++++++++++++++++++++++++++++++++-----------
res/popup/popup.html | 9 +++++++-
4 files changed, 72 insertions(+), 19 deletions(-)
diff --git a/js/uw-bg.js b/js/uw-bg.js
index dddc40f..c2e96c3 100644
--- a/js/uw-bg.js
+++ b/js/uw-bg.js
@@ -147,6 +147,8 @@ function _uwbg_rcvmsg(message, sender, sendResponse){
config.site.arStatus = SitesConf.getArStatus(BgVars.currentSite);
config.mode = Settings.extensionMode;
+ config.arMode = Settings.arDetect.mode;
+ config.arTimerPlaying = Settings.arDetect.timer_playing;
if(Debug.debug)
console.log("[uw-bg::_uwbg_rcvmsg] Keybinds.getKeybinds() returned this:", Keybinds.getKeybinds());
@@ -195,6 +197,27 @@ function _uwbg_rcvmsg(message, sender, sendResponse){
else if(message.cmd == "enable-for-site"){
SitesConf.updateSite(BgVars.currentSite, {status: message.option, statusEmbedded: message.option});
}
+ else if(message.cmd == "enable-autoar"){
+ Settings.arDetect.mode = "blacklist";
+ Settings.save();
+ Comms.sendToAll({cmd: "reload-settings", sender: "uwbg"})
+ }
+ else if(message.cmd == "disable-autoar"){
+ Settings.arDetect.mode = "disabled";
+ Settings.save();
+ Comms.sendToAll({cmd: "reload-settings", sender: "uwbg"});
+ }
+ else if(message.cmd = "autoar-set-timer-playing"){
+ var timeout = message.timeout;
+
+ if(timeout < 1)
+ timeout = 1;
+ if(timeout > 999)
+ timeout = 999;
+
+ Settings.arDetect.timer_playing = timeout;
+ Comms.sendToAll({cmd: "reload-settings", sender: "uwbg"});
+ }
}
diff --git a/manifest.json b/manifest.json
index 07d20a9..2fcfa8b 100644
--- a/manifest.json
+++ b/manifest.json
@@ -54,11 +54,6 @@
"js/conf/Status.js",
"js/conf/ExtensionConf.js",
-
- "js/modules/PageInfo.js",
- "js/modules/ArDetect.js",
- "js/modules/Resizer.js",
-
"js/conf/Keybinds.js",
"js/uw-bg.js"
diff --git a/res/popup/js/popup.js b/res/popup/js/popup.js
index 3ceaadc..5d3e107 100644
--- a/res/popup/js/popup.js
+++ b/res/popup/js/popup.js
@@ -8,6 +8,7 @@ var Menu = {};
Menu.general = document.getElementById("extension-mode");
Menu.thisSite = document.getElementById("settings-for-current-site");
Menu.arSettings = document.getElementById("aspect-ratio-settings");
+Menu.autoAr = document.getElementById("autoar-basic-settings");
Menu.cssHacks = document.getElementById("css-hacks-settings");
Menu.about = document.getElementById("panel-about");
@@ -17,6 +18,7 @@ MenuTab.thisSite = document.getElementById("_menu_this_site");
MenuTab.arSettings = document.getElementById("_menu_aspectratio");
MenuTab.cssHacks = document.getElementById("_menu_hacks");
MenuTab.about = document.getElementById("_menu_about");
+MenuTab.autoAr = document.getElementById("_menu_autoar");
var ArPanel = {}
ArPanel.alignment = {};
@@ -173,6 +175,8 @@ function loadConfig(config){
document.getElementById("extensionEnabledCurrentSite_followGlobal").setAttribute("checked","checked");
}
+ document.getElementById("_checkbox_autoArEnabled").checked = config.arMode == "blacklist";
+ document.getElementById("_input_autoAr_frequency").value = config.arTimeoutPlaying;
// process video alignment:
if(config.videoAlignment){
@@ -305,6 +309,7 @@ function showArctlButtons(){
// }
}
+
function toggleSite(option){
if(Debug.debug)
console.log("[popup::toggleSite] toggling extension 'should I work' status to", option, "on current site");
@@ -340,6 +345,9 @@ document.addEventListener("click", (e) => {
else if(e.target.classList.contains("_menu_about")){
openMenu("about");
}
+ else if(e.target.classList.contains("_menu_autoar")){
+ openMenu("autoAr");
+ }
// don't send commands
return;
@@ -396,22 +404,42 @@ document.addEventListener("click", (e) => {
}
}
- if(e.target.classList.contains("_autoar")){
+ if(e.target.classList.contains("_autoAr")){
+// var command = {};
+// if(e.target.classList.contains("_autoar_temp-disable")){
+// command = {cmd: "stop-autoar", sender: "popup", receiver: "uwbg"};
+// }
+// else if(e.target.classList.contains("_autoar_disable")){
+// command = {cmd: "disable-autoar", sender: "popup", receiver: "uwbg"};
+// }
+// else if(e.target.classList.contains("_autoar_enable")){
+// command = {cmd: "enable-autoar", sender: "popup", receiver: "uwbg"};
+// }
+// else{
+// command = {cmd: "force-ar", newAr: "auto", sender: "popup", receiver: "uwbg"};
+// }
+// _arctl_onclick(command);
+// return command;
var command = {};
- if(e.target.classList.contains("_autoar_temp-disable")){
- command = {cmd: "stop-autoar", sender: "popup", receiver: "uwbg"};
+ if(e.target.classList.contains("_autoAr_enabled")){
+ var arStatus = document.getElementById("_checkbox_autoArEnabled").checked;
+ if(arStatus){
+ Comms.sendToAll({cmd: "disable-autoar", sender: "popup", receiver: "uwbg"});
+ Comms.sendToAll({cmd: "stop-autoar", sender: "popup", receiver: "uwbg"});
+ }
+ else{
+ Comms.sendToAll({cmd: "enable-autoar", sender: "popup", receiver: "uwbg"});
+ Comms.sendToAll({cmd: "force-ar", newAr: "auto", sender: "popup", receiver: "uwbg"});
+ }
+ return;
}
- else if(e.target.classList.contains("_autoar_disable")){
- command = {cmd: "disable-autoar", sender: "popup", receiver: "uwbg"};
+ else if(e.target.classList.contains("_save_autoAr_frequency")){
+ var value = parseInt(document.getElementById("_input_autoAr_frequency").value);
+ if(! isNaN(value)){
+ var timeout = parseInt(1000 / value);
+ command = {cmd: "autoar-set-timer-playing", timeout: timeout, sender: "popup", receiver: "uwbg"};
+ }
}
- else if(e.target.classList.contains("_autoar_enable")){
- command = {cmd: "enable-autoar", sender: "popup", receiver: "uwbg"};
- }
- else{
- command = {cmd: "force-ar", newAr: "auto", sender: "popup", receiver: "uwbg"};
- }
- _arctl_onclick(command);
- return command;
}
if(e.target.classList.contains("_align")){
diff --git a/res/popup/popup.html b/res/popup/popup.html
index fca4c0d..3b3ad1f 100644
--- a/res/popup/popup.html
+++ b/res/popup/popup.html
@@ -162,6 +162,9 @@
+
@@ -206,7 +209,11 @@
- Automatic aspect ratio mode detection.
+
Due to technical reasons, the check frequency has been temporarily-ish decreased to 1 check per second.
Raising that number back to 30 will make sure the extension corrects aspect ratio as soon as change is detected. Doing so will also raise RAM usage to 30-500 MB if you opened your browser 5 seconds ago, north of 1 GB (way north) if your browser has been opened for a while.
Keeping check frequency low will make the problem go away (mostly), but aspect ratio corrections will be delayed a bit.
+
+
Enable automatic aspect ratio detection?
+
Checks per second: Save
+