Przeglądaj źródła

check type fo settings variables first

dev
Kyle 10 miesięcy temu
rodzic
commit
fea79d1d9b
2 zmienionych plików z 11 dodań i 7 usunięć
  1. +6
    -4
      js/index.js
  2. +5
    -3
      js/options.js

+ 6
- 4
js/index.js Wyświetl plik

@@ -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 Wyświetl plik

@@ -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]


Ładowanie…
Anuluj
Zapisz