From 21a138029d285b0b9c4f19d90df64462be40847c Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 30 Jul 2015 23:34:33 +0300 Subject: [PATCH 1/3] Fix database upgrade routine --- storage.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storage.js b/storage.js index 5826f0f3..f05cc1bd 100644 --- a/storage.js +++ b/storage.js @@ -69,7 +69,7 @@ function dbV14(d, error, done) { function dbV15(d, error, done) { d.changeVersion(d.version, '1.5', function (t) { t.executeSql('ALTER TABLE styles ADD COLUMN originalMd5 TEXT NULL;'); - }, error, function() { dbV15(d, error, done)}); + }, error, function() { done(d); }); } function enableStyle(id, enabled) { From a9ff8c14f30e84b252914dc6f4676492119a0df0 Mon Sep 17 00:00:00 2001 From: tophf Date: Fri, 7 Aug 2015 16:48:17 +0300 Subject: [PATCH 2/3] Fix jsonEquals() bug: actually compare the properties --- manage.js | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/manage.js b/manage.js index 2814ba6e..8c35cbb8 100644 --- a/manage.js +++ b/manage.js @@ -389,38 +389,31 @@ function codeIsEqual(a, b) { } function jsonEquals(a, b, property) { - var type = getType(a[property]); - var typeB = getType(b[property]); - if (type != typeB) { + var aProp = a[property], typeA = getType(aProp); + var bProp = b[property], typeB = getType(bProp); + if (typeA != typeB) { // consider empty arrays equivalent to lack of property - if ((type == "undefined" || (type == "array" && a[property].length == 0)) && (typeB == "undefined" || (typeB == "array" && b[property].length == 0))) { + if ((typeA == "undefined" || (typeA == "array" && aProp.length == 0)) && (typeB == "undefined" || (typeB == "array" && bProp.length == 0))) { return true; } return false; } - if (type == "undefined") { + if (typeA == "undefined") { return true; } - if (type == "array") { - if (a[property].length != b[property].length) { + if (typeA == "array") { + if (aProp.length != bProp.length) { return false; } - for (var i = 0; i < a.length; i++) { - var found = false; - for (var j = 0; j < b.length; j++) { - if (a[i] == b[j]) { - found = true; - break; - } - } - if (!found) { + for (var i = 0; i < aProp.length; i++) { + if (bProp.indexOf(aProp[i]) == -1) { return false; } } return true; } - if (type == "string") { - return a[property] == b[property]; + if (typeA == "string") { + return aProp == bProp; } } From d2441213ef8dd0a83475027b28541c50f8e5fd20 Mon Sep 17 00:00:00 2001 From: tophf Date: Fri, 28 Aug 2015 19:41:44 +0300 Subject: [PATCH 3/3] Don't use css calc with vw as it fails on Chrome 31 * Also makes showCodeMirrorPopup() size stylable --- edit.html | 8 ++++++++ edit.js | 5 ++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/edit.html b/edit.html index 32c037b1..8e06dc9d 100644 --- a/edit.html +++ b/edit.html @@ -243,6 +243,14 @@ padding: 0.5rem; z-index: 99; } + #help-popup.big { + max-width: 100%; + left: 3rem; + } + #help-popup.big .CodeMirror { + min-height: 2rem; + height: 70vh; + } #help-popup .title { font-weight: bold; background-color: rgba(0,0,0,0.05); diff --git a/edit.js b/edit.js index e15cf5ff..fb11c477 100644 --- a/edit.js +++ b/edit.js @@ -1529,7 +1529,7 @@ function showLintHelp() { function showHelp(title, text) { var div = document.getElementById("help-popup"); - div.style.cssText = ""; + div.classList.remove("big"); div.querySelector(".contents").innerHTML = text; div.querySelector(".title").innerHTML = title; @@ -1552,7 +1552,7 @@ function showHelp(title, text) { function showCodeMirrorPopup(title, html, options) { var popup = showHelp(title, html); - popup.style.width = popup.style.maxWidth = "calc(100vw - 7rem)"; + popup.classList.add("big"); popup.codebox = CodeMirror(popup.querySelector(".contents"), shallowMerge(options, { mode: "css", @@ -1567,7 +1567,6 @@ function showCodeMirrorPopup(title, html, options) { keyMap: prefs.getPref("editor.keyMap") })); popup.codebox.focus(); - popup.codebox.setSize(null, "70vh"); popup.codebox.on("focus", function() { hotkeyRerouter.setState(false) }); popup.codebox.on("blur", function() { hotkeyRerouter.setState(true) }); return popup;