end of the day commit. settings for autoAr ARE NOT getting saved.

This commit is contained in:
Tamius Han 2018-03-13 00:36:10 +01:00
parent 13a928b90e
commit 51f2df930d
4 changed files with 72 additions and 19 deletions

View File

@ -147,6 +147,8 @@ function _uwbg_rcvmsg(message, sender, sendResponse){
config.site.arStatus = SitesConf.getArStatus(BgVars.currentSite); config.site.arStatus = SitesConf.getArStatus(BgVars.currentSite);
config.mode = Settings.extensionMode; config.mode = Settings.extensionMode;
config.arMode = Settings.arDetect.mode;
config.arTimerPlaying = Settings.arDetect.timer_playing;
if(Debug.debug) if(Debug.debug)
console.log("[uw-bg::_uwbg_rcvmsg] Keybinds.getKeybinds() returned this:", Keybinds.getKeybinds()); 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"){ else if(message.cmd == "enable-for-site"){
SitesConf.updateSite(BgVars.currentSite, {status: message.option, statusEmbedded: message.option}); 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"});
}
} }

View File

@ -54,11 +54,6 @@
"js/conf/Status.js", "js/conf/Status.js",
"js/conf/ExtensionConf.js", "js/conf/ExtensionConf.js",
"js/modules/PageInfo.js",
"js/modules/ArDetect.js",
"js/modules/Resizer.js",
"js/conf/Keybinds.js", "js/conf/Keybinds.js",
"js/uw-bg.js" "js/uw-bg.js"

View File

@ -8,6 +8,7 @@ var Menu = {};
Menu.general = document.getElementById("extension-mode"); Menu.general = document.getElementById("extension-mode");
Menu.thisSite = document.getElementById("settings-for-current-site"); Menu.thisSite = document.getElementById("settings-for-current-site");
Menu.arSettings = document.getElementById("aspect-ratio-settings"); Menu.arSettings = document.getElementById("aspect-ratio-settings");
Menu.autoAr = document.getElementById("autoar-basic-settings");
Menu.cssHacks = document.getElementById("css-hacks-settings"); Menu.cssHacks = document.getElementById("css-hacks-settings");
Menu.about = document.getElementById("panel-about"); Menu.about = document.getElementById("panel-about");
@ -17,6 +18,7 @@ MenuTab.thisSite = document.getElementById("_menu_this_site");
MenuTab.arSettings = document.getElementById("_menu_aspectratio"); MenuTab.arSettings = document.getElementById("_menu_aspectratio");
MenuTab.cssHacks = document.getElementById("_menu_hacks"); MenuTab.cssHacks = document.getElementById("_menu_hacks");
MenuTab.about = document.getElementById("_menu_about"); MenuTab.about = document.getElementById("_menu_about");
MenuTab.autoAr = document.getElementById("_menu_autoar");
var ArPanel = {} var ArPanel = {}
ArPanel.alignment = {}; ArPanel.alignment = {};
@ -173,6 +175,8 @@ function loadConfig(config){
document.getElementById("extensionEnabledCurrentSite_followGlobal").setAttribute("checked","checked"); 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: // process video alignment:
if(config.videoAlignment){ if(config.videoAlignment){
@ -305,6 +309,7 @@ function showArctlButtons(){
// } // }
} }
function toggleSite(option){ function toggleSite(option){
if(Debug.debug) if(Debug.debug)
console.log("[popup::toggleSite] toggling extension 'should I work' status to", option, "on current site"); 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")){ else if(e.target.classList.contains("_menu_about")){
openMenu("about"); openMenu("about");
} }
else if(e.target.classList.contains("_menu_autoar")){
openMenu("autoAr");
}
// don't send commands // don't send commands
return; 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 = {}; var command = {};
if(e.target.classList.contains("_autoar_temp-disable")){ if(e.target.classList.contains("_autoAr_enabled")){
command = {cmd: "stop-autoar", sender: "popup", receiver: "uwbg"}; 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")){ else if(e.target.classList.contains("_save_autoAr_frequency")){
command = {cmd: "disable-autoar", sender: "popup", receiver: "uwbg"}; 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")){ if(e.target.classList.contains("_align")){

View File

@ -162,6 +162,9 @@
<div id="_menu_this_site" class="menu-item _menu_this_site"> <div id="_menu_this_site" class="menu-item _menu_this_site">
Settings for this site Settings for this site
</div> </div>
<div id="_menu_autoar" class="menu-item _menu_autoar">
Automatic aspect ratio detection (auto-ar)
</div>
<div id="_menu_aspectratio" class="menu-item selected _menu_aspectratio"> <div id="_menu_aspectratio" class="menu-item selected _menu_aspectratio">
Letterbox removal and alignment Letterbox removal and alignment
</div> </div>
@ -206,7 +209,11 @@
</div> </div>
<div id="autoar-basic-settings" class="suboption hidden"> <div id="autoar-basic-settings" class="suboption hidden">
Automatic aspect ratio mode detection. <div class="warning"><p>Due to technical reasons, the check frequency has been temporarily-ish decreased to 1 check per second.</p><small><p>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 (<i>way</i> north) if your browser has been opened for a while.</p><p>Keeping check frequency low will make the problem go away (mostly), but aspect ratio corrections will be delayed a bit.</p></small></div>
<p><input type="checkbox" id="_checkbox_autoArEnabled" class="_autoAr_enabled _autoAr"> Enable automatic aspect ratio detection?</p>
<p>Checks per second: <input id="_input_autoAr_frequency" class="_autoAr_frequency _autoAr" type="number" min="1" max="999"><span class="button _save_autoAr_frequency _autoAr">Save</div></p>
</div> </div>
<div id="aspect-ratio-settings" class="suboption hidden"> <div id="aspect-ratio-settings" class="suboption hidden">