-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
options in separated page and context menu
- Loading branch information
1 parent
7260e8a
commit cfa7375
Showing
18 changed files
with
389 additions
and
271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/** @license | ||
DJSON Viewer and Formatter | MIT License | ||
Copyright 2017 Dario De Santis | ||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
of the Software, and to permit persons to whom the Software is furnished to do | ||
so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
*/ | ||
|
||
(function () { | ||
|
||
"use strict"; | ||
|
||
// theme | ||
var supportedThemes = ["default", "monokai", "xcode", "solarized", "darkorange", "halewa"]; | ||
var theme = localStorage.getItem("theme"); | ||
var themeChooserSelect = document.getElementById("themeChooserSelectContainer"); | ||
themeChooserSelect= themeChooserSelect.firstElementChild; | ||
supportedThemes.forEach(function (themeName) { | ||
var option = document.createElement('option'); | ||
option.value = themeName; | ||
option.innerText = themeName; | ||
if(theme && theme == themeName){ | ||
option.selected = 'selected'; | ||
document.getElementById("themeChooserPreview").setAttribute('data-theme', themeName); | ||
} | ||
themeChooserSelect.appendChild(option); | ||
}); | ||
|
||
themeChooserSelect.addEventListener('change', function () { | ||
var selectedTheme = this.options[this.selectedIndex].value; | ||
themeChooserPreview.setAttribute('data-theme', selectedTheme); | ||
localStorage.setItem("theme", selectedTheme); | ||
}); | ||
|
||
|
||
// context menu | ||
var contextMenuCheckbox = document.getElementById("contextMenuCheckbox"); | ||
var contextMenu = localStorage.getItem("contextMenu"); | ||
if(contextMenu && contextMenu === "true"){ | ||
contextMenuCheckbox.checked = true; | ||
} | ||
contextMenuCheckbox.addEventListener('click', function () { | ||
var port = chrome.extension.connect({name: 'djson'}); | ||
if(contextMenuCheckbox.checked) { | ||
port.postMessage({type: "ENABLE CONTEXT MENU"}); | ||
} else { | ||
port.postMessage({type: "DISABLE CONTEXT MENU"}); | ||
} | ||
}); | ||
|
||
// start JSON collapsed | ||
var startCollapsedCheckbox = document.getElementById("startCollapsedCheckbox"); | ||
var startCollapsed = localStorage.getItem("startCollapsed"); | ||
if(startCollapsed && startCollapsed === "true"){ | ||
startCollapsedCheckbox.checked = true; | ||
} | ||
startCollapsedCheckbox.addEventListener('click', function () { | ||
if(startCollapsedCheckbox.checked) { | ||
localStorage.setItem("startCollapsed", true); | ||
} else { | ||
localStorage.removeItem("startCollapsed") | ||
} | ||
}); | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Options</title> | ||
<link rel="stylesheet" href="css/content.css"> | ||
</head> | ||
<body id="optionScreen"> | ||
<h1>Options</h1> | ||
<hr> | ||
<h2>Theme</h2> | ||
<div id="themeChooserContainer"> | ||
<div id="themeChooserSelectContainer"> | ||
<select></select> | ||
(It will be applied only after the reload of the json) | ||
</div> | ||
<div id="themeChooserPreview"> | ||
<pre><span class="b">{</span><br> "<span class="key">number</span>": <span class="n">0.4</span>,<br> "<span class="key">string</span>": <span class="s">"DJSON"</span>,<br> "<span class="key">url</span>": <span class="a">"https://github.com/dardesantis/DJSON-Viewer"</span><br><span class="b">}</span></pre> | ||
</div> | ||
</div> | ||
|
||
<h2>Preferences</h2> | ||
<input id="contextMenuCheckbox" type="checkbox" name="context"> Enable Context Menu | ||
<br> | ||
<input id="startCollapsedCheckbox" type="checkbox" name="collapsed"> Load JSON as Collapsed (slower) | ||
|
||
<script type="application/javascript" src="js/options.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.