Browse Source

WebUI: Keep current preference for the title style in a variable

Read persistent value only when required.
adaptive-webui-19844
Gabriele 10 years ago
parent
commit
d7071a81bd
  1. 26
      src/webui/www/public/scripts/client.js

26
src/webui/www/public/scripts/client.js

@ -75,6 +75,11 @@ window.addEvent('load', function () {
height : 300 height : 300
}); });
initializeWindows(); initializeWindows();
var speedInTitle = localStorage.getItem('speed_in_browser_title_bar') == "true";
if (!speedInTitle)
$('speedInBrowserTitleBarLink').firstChild.style.opacity = '0';
var r = 0; var r = 0;
var stateToImg = function (state) { var stateToImg = function (state) {
@ -111,7 +116,7 @@ window.addEvent('load', function () {
$("UpInfos").set('html', "_(U: %1 - T: %2)" $("UpInfos").set('html', "_(U: %1 - T: %2)"
.replace("%1", friendlyUnit(info.up_info_speed, true)) .replace("%1", friendlyUnit(info.up_info_speed, true))
.replace("%2", friendlyUnit(info.up_info_data, false))); .replace("%2", friendlyUnit(info.up_info_data, false)));
if(localStorage.getItem('speed_in_browser_title_bar') == 'true') if (speedInTitle)
document.title = "_(D:%1 U:%2)".replace("%1", friendlyUnit(info.dl_info_speed, true)).replace("%2", friendlyUnit(info.up_info_speed, true)); document.title = "_(D:%1 U:%2)".replace("%1", friendlyUnit(info.dl_info_speed, true)).replace("%2", friendlyUnit(info.up_info_speed, true));
else else
document.title = "_(qBittorrent web User Interface)"; document.title = "_(qBittorrent web User Interface)";
@ -233,20 +238,13 @@ window.addEvent('load', function () {
updateTransferList(); updateTransferList();
}; };
updateSpeedInBrowserTitleBarLinkCheckState = function() { $('speedInBrowserTitleBarLink').addEvent('click', function(e) {
if (localStorage.getItem('speed_in_browser_title_bar') == 'true') speedInTitle = !speedInTitle;
$(speedInBrowserTitleBarLink).firstChild.style.opacity = '1'; localStorage.setItem('speed_in_browser_title_bar', speedInTitle.toString());
if (speedInTitle)
$('speedInBrowserTitleBarLink').firstChild.style.opacity = '1';
else else
$(speedInBrowserTitleBarLink).firstChild.style.opacity = '0'; $('speedInBrowserTitleBarLink').firstChild.style.opacity = '0';
}
updateSpeedInBrowserTitleBarLinkCheckState();
addClickEvent('speedInBrowserTitleBar', function() {
var speed_in_browser_title_bar = localStorage.getItem('speed_in_browser_title_bar');
speed_in_browser_title_bar = speed_in_browser_title_bar == 'true' ? 'false' : 'true';
localStorage.setItem('speed_in_browser_title_bar', speed_in_browser_title_bar);
updateSpeedInBrowserTitleBarLinkCheckState();
updateTransferInfo(); updateTransferInfo();
}); });

Loading…
Cancel
Save