Selaa lähdekoodia

check type fo settings variables first

dev
Kyle 9 kuukautta sitten
vanhempi
commit
fea79d1d9b
2 muutettua tiedostoa jossa 11 lisäystä ja 7 poistoa
  1. +6
    -4
      js/index.js
  2. +5
    -3
      js/options.js

+ 6
- 4
js/index.js Näytä tiedosto

@@ -3,10 +3,12 @@ function restore_options() {
console.log("Loading Settings", result)
var quads = document.getElementsByClassName("quadrant")
var style = document.createElement("style")
if (!(typeof result === 'undefined')) {
if (!(typeof result.links)) result.links = []
if (!(typeof result.colors)) result.colors = []
if (!(typeof result.mode)) result.mode = "light"
if (!(typeof result === "undefined")) {
if (!(typeof result.links === "object")) result.links = []
if (!Array.isArray(result.links)) result.links = []
if (!(typeof result.colors === "object")) result.colors = []
if (!Array.isArray(result.colors)) result.colors = []
if (!(typeof result.mode) === "string") result.mode = "light"
for (i = 0; i < quads.length; i++) {
if (i < result.links.length) {
var link = result.links[i]


+ 5
- 3
js/options.js Näytä tiedosto

@@ -22,9 +22,11 @@ function restore_options() {
var input_links = document.querySelectorAll('input[type="text"]')
var input_colors = document.querySelectorAll('input[type="color"]')
if (!(typeof result === 'undefined')) {
if (!(typeof result.links)) result.links = []
if (!(typeof result.colors)) result.colors = []
if (!(typeof result.mode)) result.mode = "light"
if (!(typeof result.links === "object")) result.links = []
if (!Array.isArray(result.links)) result.links = []
if (!(typeof result.colors === "object")) result.colors = []
if (!Array.isArray(result.colors)) result.colors = []
if (!(typeof result.mode) === "string") result.mode = "light"
for (i = 0; i < input_links.length; i++) {
if (i < result.links.length) {
input_links[i].value = result.links[i]


Ladataan…
Peruuta
Tallenna