|
|
@ -40,21 +40,21 @@ transparent 76%,transparent\
|
|
|
|
)';
|
|
|
|
)';
|
|
|
|
|
|
|
|
|
|
|
|
var updateSubframeDemo = function() {
|
|
|
|
var updateSubframeDemo = function() {
|
|
|
|
var demo = $('#subframe-color-demo');
|
|
|
|
var demo = uDom('#subframe-color-demo');
|
|
|
|
var color = $('#subframe-color').val();
|
|
|
|
var color = uDom('#subframe-color').val();
|
|
|
|
demo.css('border-color', color);
|
|
|
|
demo.css('border-color', color);
|
|
|
|
var re = new RegExp('\{\{color\}\}', 'g');
|
|
|
|
var re = new RegExp('\{\{color\}\}', 'g');
|
|
|
|
demo.css('background-image', subframeDemoBackgroundImage.replace(re, color));
|
|
|
|
demo.css('background-image', subframeDemoBackgroundImage.replace(re, color));
|
|
|
|
demo.css('opacity', (parseInt($('#subframe-opacity').val(), 10) / 100).toFixed(1));
|
|
|
|
demo.css('opacity', (parseInt(uDom('#subframe-opacity').val(), 10) / 100).toFixed(1));
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var onSubframeColorChanged = function() {
|
|
|
|
var onSubframeColorChanged = function() {
|
|
|
|
var color = $('#subframe-color').val();
|
|
|
|
var color = uDom('#subframe-color').val();
|
|
|
|
if ( color === '' ) {
|
|
|
|
if ( color === '' ) {
|
|
|
|
$('#subframe-color').val(color);
|
|
|
|
uDom('#subframe-color').val(color);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
changeUserSettings('subframeColor', color);
|
|
|
|
changeUserSettings('subframeColor', color);
|
|
|
|
var opacity = parseInt($('#subframe-opacity').val(), 10);
|
|
|
|
var opacity = parseInt(uDom('#subframe-opacity').val(), 10);
|
|
|
|
if ( Number.isNaN(opacity) ) {
|
|
|
|
if ( Number.isNaN(opacity) ) {
|
|
|
|
opacity = 100;
|
|
|
|
opacity = 100;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -83,42 +83,42 @@ function prepareToDie() {
|
|
|
|
var installEventHandlers = function() {
|
|
|
|
var installEventHandlers = function() {
|
|
|
|
// `data-range` allows to add/remove bool properties without
|
|
|
|
// `data-range` allows to add/remove bool properties without
|
|
|
|
// changing code.
|
|
|
|
// changing code.
|
|
|
|
$('input[data-range="bool"]').on('change', function() {
|
|
|
|
uDom('input[data-range="bool"]').on('change', function() {
|
|
|
|
changeUserSettings(this.id, this.checked);
|
|
|
|
changeUserSettings(this.id, this.checked);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$('input[name="displayTextSize"]').on('change', function(){
|
|
|
|
uDom('input[name="displayTextSize"]').on('change', function(){
|
|
|
|
changeUserSettings('displayTextSize', $(this).attr('value'));
|
|
|
|
changeUserSettings('displayTextSize', this.value);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$('#smart-auto-reload').on('change', function(){
|
|
|
|
uDom('#smart-auto-reload').on('change', function(){
|
|
|
|
changeUserSettings('smartAutoReload', this.value);
|
|
|
|
changeUserSettings('smartAutoReload', this.value);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$('#subframe-color').on('change', function(){ onSubframeColorChanged(); });
|
|
|
|
uDom('#subframe-color').on('change', function(){ onSubframeColorChanged(); });
|
|
|
|
$('#subframe-opacity').on('change', function(){ onSubframeColorChanged(); });
|
|
|
|
uDom('#subframe-opacity').on('change', function(){ onSubframeColorChanged(); });
|
|
|
|
|
|
|
|
|
|
|
|
// https://github.com/gorhill/httpswitchboard/issues/197
|
|
|
|
// https://github.com/gorhill/httpswitchboard/issues/197
|
|
|
|
$(window).one('beforeunload', prepareToDie);
|
|
|
|
uDom(window).on('beforeunload', prepareToDie);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************************************/
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
$(function() {
|
|
|
|
uDom.onLoad(function() {
|
|
|
|
var onUserSettingsReceived = function(userSettings) {
|
|
|
|
var onUserSettingsReceived = function(userSettings) {
|
|
|
|
// Cache copy
|
|
|
|
// Cache copy
|
|
|
|
cachedUserSettings = userSettings;
|
|
|
|
cachedUserSettings = userSettings;
|
|
|
|
|
|
|
|
|
|
|
|
// `data-range` allows to add/remove bool properties without
|
|
|
|
// `data-range` allows to add/remove bool properties without
|
|
|
|
// changing code.
|
|
|
|
// changing code.
|
|
|
|
$('input[data-range="bool"]').each(function() {
|
|
|
|
uDom('input[data-range="bool"]').toArray().forEach(function(elem) {
|
|
|
|
this.checked = userSettings[this.id] === true;
|
|
|
|
elem.checked = userSettings[elem.id] === true;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$('input[name="displayTextSize"]').attr('checked', function(){
|
|
|
|
uDom('input[name="displayTextSize"]').toArray().forEach(function(elem) {
|
|
|
|
return $(this).attr('value') === userSettings.displayTextSize;
|
|
|
|
elem.checked = elem.value === userSettings.displayTextSize;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$('#smart-auto-reload').val(userSettings.smartAutoReload);
|
|
|
|
uDom('#smart-auto-reload').val(userSettings.smartAutoReload);
|
|
|
|
$('#subframe-color').val(userSettings.subframeColor);
|
|
|
|
uDom('#subframe-color').val(userSettings.subframeColor);
|
|
|
|
$('#subframe-opacity').val(userSettings.subframeOpacity);
|
|
|
|
uDom('#subframe-opacity').val(userSettings.subframeOpacity);
|
|
|
|
updateSubframeDemo();
|
|
|
|
updateSubframeDemo();
|
|
|
|
|
|
|
|
|
|
|
|
installEventHandlers();
|
|
|
|
installEventHandlers();
|
|
|
|