mirror of https://github.com/gorhill/uBlock.git
Small code review of a52b07ff6e
This commit is contained in:
parent
f0d5205bd7
commit
97f91f8be9
|
@ -25,16 +25,17 @@
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
(function() { // >>>> Start of private namespace
|
(function() {
|
||||||
|
// >>>> Start of private namespace
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
let messaging = vAPI.messaging;
|
const messaging = vAPI.messaging;
|
||||||
let noopFunc = function(){};
|
const noopFunc = function(){};
|
||||||
|
|
||||||
let beforeHash = '';
|
let beforeHash = '';
|
||||||
|
|
||||||
let cmEditor = new CodeMirror(
|
const cmEditor = new CodeMirror(
|
||||||
document.getElementById('advancedSettings'),
|
document.getElementById('advancedSettings'),
|
||||||
{
|
{
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
|
@ -48,18 +49,18 @@ uBlockDashboard.patchCodeMirrorEditor(cmEditor);
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
let hashFromAdvancedSettings = function(raw) {
|
const hashFromAdvancedSettings = function(raw) {
|
||||||
return raw.trim().replace(/[ \t]+/g, ' ').replace(/\s*[\n\r]+\s*/g, '\n');
|
return raw.trim().replace(/\s*[\n\r]+\s*/g, '\n').replace(/[ \t]+/g, ' ');
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
// This is to give a visual hint that the content of user blacklist has changed.
|
// This is to give a visual hint that the content of user blacklist has changed.
|
||||||
|
|
||||||
let advancedSettingsChanged = (function () {
|
const advancedSettingsChanged = (function () {
|
||||||
let timer = null;
|
let timer = null;
|
||||||
|
|
||||||
let handler = ( ) => {
|
const handler = ( ) => {
|
||||||
timer = null;
|
timer = null;
|
||||||
let changed = hashFromAdvancedSettings(cmEditor.getValue()) !== beforeHash;
|
let changed = hashFromAdvancedSettings(cmEditor.getValue()) !== beforeHash;
|
||||||
uDom.nodeFromId('advancedSettingsApply').disabled = !changed;
|
uDom.nodeFromId('advancedSettingsApply').disabled = !changed;
|
||||||
|
@ -76,8 +77,8 @@ cmEditor.on('changes', advancedSettingsChanged);
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
let renderAdvancedSettings = function(first) {
|
const renderAdvancedSettings = function(first) {
|
||||||
let onRead = function(raw) {
|
const onRead = function(raw) {
|
||||||
beforeHash = hashFromAdvancedSettings(raw);
|
beforeHash = hashFromAdvancedSettings(raw);
|
||||||
let pretty = [],
|
let pretty = [],
|
||||||
whitespaces = ' ',
|
whitespaces = ' ',
|
||||||
|
@ -103,7 +104,7 @@ let renderAdvancedSettings = function(first) {
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
let applyChanges = function() {
|
const applyChanges = function() {
|
||||||
messaging.send(
|
messaging.send(
|
||||||
'dashboard',
|
'dashboard',
|
||||||
{
|
{
|
||||||
|
@ -129,4 +130,5 @@ renderAdvancedSettings(true);
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
})(); // <<<< End of private namespace
|
// <<<< End of private namespace
|
||||||
|
})();
|
||||||
|
|
Loading…
Reference in New Issue