MikeCoder /
MJsonViewer
| 1 | ////////////////////////////////////////////////////////////////////////////////////// |
||
| 2 | // Copyright © 2017 TangDongxin |
||
| 3 | // |
||
| 4 | // Permission is hereby granted, free of charge, to any person obtaining |
||
| 5 | // a copy of this software and associated documentation files (the "Software"), |
||
| 6 | // to deal in the Software without restriction, including without limitation |
||
| 7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, |
||
| 8 | // and/or sell copies of the Software, and to permit persons to whom the |
||
| 9 | // Software is furnished to do so, subject to the following conditions: |
||
| 10 | // |
||
| 11 | // The above copyright notice and this permission notice shall be included |
||
| 12 | // in all copies or substantial portions of the Software. |
||
| 13 | // |
||
| 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
||
| 15 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
||
| 16 | // OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
||
| 17 | // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
||
| 18 | // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, |
||
| 19 | // TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE |
||
| 20 | // OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
||
| 21 | ////////////////////////////////////////////////////////////////////////////////////// |
||
| 22 | |||
| 23 | function setPreviewColor(result) { |
||
| 24 | console.log("load Color"); |
||
|
0 ignored issues
–
show
Debugging Code
introduced
by
Loading history...
|
|||
| 25 | document.getElementById("fontLabel").style.fontFamily = result.fontStyle || "Consolas"; |
||
| 26 | document.querySelector("#bgColorLabel").style.backgroundColor = result.bgColor || "#FDF6E3"; |
||
| 27 | document.querySelector("#intColorLabel").style.color = result.intColor || "#657A81"; |
||
| 28 | document.querySelector("#strColorLabel").style.color = result.strColor || "#2AA198"; |
||
| 29 | document.querySelector("#keyColorLabel").style.color = result.keyColor || "#B58900"; |
||
| 30 | document.querySelector("#defaultColorLabel").style.color = result.defaultColor || "#586E75"; |
||
| 31 | |||
| 32 | document.querySelector("#strictOnly").checked = result.strictOnly || false; |
||
| 33 | document.querySelector("#hideDetails").checked = result.hideDetails || false; |
||
| 34 | } |
||
| 35 | |||
| 36 | function onError(error) { |
||
| 37 | console.log(`Error: ${error}`); |
||
|
0 ignored issues
–
show
|
|||
| 38 | } |
||
| 39 | |||
| 40 | function saveOptions(e) { |
||
| 41 | e.preventDefault(); |
||
| 42 | browser.storage.local.set({ |
||
|
0 ignored issues
–
show
The variable
browser seems to be never declared. If this is a global, consider adding a /** global: browser */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. Loading history...
|
|||
| 43 | bgColor: document.querySelector("#bgColor").value, |
||
| 44 | intColor: document.querySelector("#intColor").value, |
||
| 45 | strColor: document.querySelector("#strColor").value, |
||
| 46 | keyColor: document.querySelector("#keyColor").value, |
||
| 47 | defaultColor: document.querySelector("#defaultColor").value, |
||
| 48 | fontStyle: document.querySelector("#fontStyle").value, |
||
| 49 | |||
| 50 | strictOnly: document.querySelector("#strictOnly").checked, |
||
| 51 | hideDetails: document.querySelector("#hideDetails").checked |
||
| 52 | }); |
||
| 53 | alert("Success"); |
||
| 54 | browser.storage.local.get().then(setCurrentChoice, onError); |
||
| 55 | } |
||
| 56 | |||
| 57 | function setCurrentChoice(result) { |
||
| 58 | console.log(result); |
||
|
0 ignored issues
–
show
|
|||
| 59 | document.querySelector("#bgColor").value = result.bgColor || "#FDF6E3"; |
||
| 60 | document.querySelector("#intColor").value = result.intColor || "#657A81"; |
||
| 61 | document.querySelector("#strColor").value = result.strColor || "#2AA198"; |
||
| 62 | document.querySelector("#keyColor").value = result.keyColor || "#B58900"; |
||
| 63 | document.querySelector("#defaultColor").value = result.defaultColor || "#586E75"; |
||
| 64 | document.querySelector("#fontStyle").value = result.fontStyle || "Consolas"; |
||
| 65 | |||
| 66 | document.querySelector("#strictOnly").checked = result.strictOnly || false; |
||
| 67 | document.querySelector("#hideDetails").checked = result.hideDetails || false; |
||
| 68 | |||
| 69 | setPreviewColor(result); |
||
| 70 | } |
||
| 71 | |||
| 72 | function restoreOptions() { |
||
| 73 | browser.storage.local.get().then(setCurrentChoice, onError); |
||
|
0 ignored issues
–
show
The variable
browser seems to be never declared. If this is a global, consider adding a /** global: browser */ comment.
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed. To learn more about declaring variables in Javascript, see the MDN. Loading history...
|
|||
| 74 | } |
||
| 75 | |||
| 76 | document.addEventListener("DOMContentLoaded", restoreOptions); |
||
| 77 | document.querySelector("form").addEventListener("submit", saveOptions); |
||
| 78 |