-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoptions.html
198 lines (183 loc) · 8.48 KB
/
options.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<!DOCTYPE html>
<html>
<head>
<title>Options</title>
<script type="text/javascript">
function $(id, d){ return (d || document).getElementById(id); }
NodeList.prototype.forEach = function(callback){
for(var i=0,l=this.length;i<l;i++)
if(this.item(i)) callback(this.item(i));
};
NodeList.prototype.first = function(predicate){
for(var i=0,l=this.length;i<l;i++)
if(this.item(i) && predicate(this.item(i))) return this.item(i);
return null;
};
var currentOptions;
function save(obj) {
chrome.extension.sendRequest({"name": "xmlviewer.setOptions", "data": obj}, function(response){});
}
function load(callback){
chrome.extension.sendRequest({"name": "xmlviewer.getOptions"}, callback);
}
function handleSettingsChange(event){
save(get());
}
function get(){
var templateNameItem = document.querySelectorAll('input[name="template_name"]').first(function(item){return item.checked;});
var colorSchemeNameItem = document.querySelectorAll('input[name="color_scheme_name"]').first(function(item){return item.checked;});
var startCollapsedItem = $('start_nodes_collapsed');
return {
'templateName' : (templateNameItem)?templateNameItem.value:"standard",
'colorSchemeName' : (colorSchemeNameItem)?colorSchemeNameItem.value:"standard",
'startCollapsed' : (startCollapsedItem)?startCollapsedItem.checked:true
};
}
function handleOnLoad(){
load(function(response){
//Show selected option
($('template_name_'+response.templateName) || {}).checked = true;
($('color_scheme_name_'+response.colorSchemeName) || {}).checked = true;
($('start_nodes_collapsed') || {}).checked = response.startCollapsed;
//Attach event handlers
var items = document.querySelectorAll('input[name="template_name"]');
items.forEach(function(item){ if(!item.disabled) item.addEventListener('click', handleSettingsChange, false); });
var items = document.querySelectorAll('input[name="color_scheme_name"]');
items.forEach(function(item){ if(!item.disabled) item.addEventListener('click', handleSettingsChange, false); });
$('start_nodes_collapsed').addEventListener('click', handleSettingsChange, false);
});
}
</script>
<style>
body{
margin: 0.5em;
font-family: DejaVu Sans Mono, Menlo, Consolas, Courier New, Lucida Console, serif;
background-color:WhiteSmoke;
}
ol{
margin:0.5em 0;
-webkit-padding-start:0.5em;
list-style-type: none;
}
fieldset{
border-radius: 3px;
border:0;
-webkit-box-shadow: 0px 1px 3px gray;
white-space:nowrap;
width:0%;
margin-left:auto;
margin-right:auto;
background-color:white;
margin-bottom:1.75em;
min-width:525px;
}
input[type="radio"]{
cursor:pointer;
}
label{
cursor:pointer;
margin-left:2px;
}
label.disabled{
color:gray;
}
header{
white-space:nowrap;
margin-bottom:2em;
background-color:white;
padding:5px;
-webkit-box-shadow: 0px 1px 3px gray;
}
header h1{
display:inline;
padding:0.5em;
vertical-align:middle;
font-weight:normal;
font-size:1.33em;
text-shadow:0px 0px 1px gray;
}
header img{
display:inline;
vertical-align:middle;
}
legend{
border-radius: 0 0 2px 2px;
background-color:white;
-webkit-box-shadow: 0px 2px 2px gray;
background-color:WhiteSmoke;
padding:3px 6px;
font-size:0.90em;
}
li{
border-radius: 3px;
padding-right: 3px;
border:1px solid white;
}
li:hover{
background-color: #FFFFCC;
border:1px solid yellow;
}
</style>
<style>
.standard-tag-start { color:DarkRed; }
.standard-tag-content { color:black; }
.standard-start-bracket { color:blue; }
.standard-end-bracket { color:blue; }
.standard-tag-end:not(.standard-tag-start) { color:DarkRed; }
.standard-attribute-set, .standard-attribute-set * { color:DarkRed; }
.standard-attribute-value { color:blue; }
</style>
<style>
.reduced-tag-start { color:DarkRed; }
.reduced-tag-content { color:black; }
.reduced-start-bracket { color:blue; }
.reduced-end-bracket { color:#CCCCFF; }
.reduced-tag-end:not(.reduced-tag-start) { color:#E8CCCC; }
.reduced-attribute-set, .reduced-attribute-set * { color:DarkRed; }
.reduced-attribute-value { color:blue; }
</style>
<style>
.color-scheme-firefox-example .tag-start { color:purple; font-weight:bold; }
.color-scheme-firefox-example .tag-content { color:black; font-weight:normal; }
.color-scheme-firefox-example .start-bracket { color:black; font-weight:normal; }
.color-scheme-firefox-example .end-bracket { color:black; font-weight:normal; }
.color-scheme-firefox-example .tag-end:not(.tag-start) { color:purple; font-weight:bold; }
.color-scheme-firefox-example .attribute-set, .color-scheme-firefox-example .attribute-set * { color:black; font-weight:normal; }
.color-scheme-firefox-example .attribute-name { color:black; font-weight:bold; }
.color-scheme-firefox-example .attribute-value { color:blue; }
</style>
</head>
<body onload="handleOnLoad()">
<header><img src="icon48.png" /><h1>XML Viewer Options</h1></header>
<fieldset>
<legend>XML Format</legend>
<ol>
<li><input type="radio" name="template_name" value="standard" id="template_name_standard" checked="checked"/><label for="template_name_standard">Standard <span class="example"><span class="standard-tag-start"><span class="standard-start-bracket"><</span>item <span class="standard-attribute-set"><span class="standard-attribute-name">partNum</span>="<span class="standard-attribute-value">872-AA</span>"</span><span class="standard-start-bracket">></span></span><span class="standard-tag-content">Lawnmower</span><span class="standard-tag-end"><span class="standard-end-bracket"></</span>item<span class="standard-end-bracket">></span></span></span></label></li>
<li><input type="radio" name="template_name" value="reduced" id="template_name_reduced" /><label for="template_name_reduced">Reduced <span class="example"><span class="reduced-tag-start">item <span class="reduced-attribute-set"><span class="reduced-attribute-name">partNum</span>="<span class="reduced-attribute-value">872-AA</span>"</span><span class="reduced-start-bracket">></span></span><span class="reduced-tag-content">Lawnmower</span><span class="reduced-tag-end"><span class="reduced-end-bracket"><</span></span></span></label></li>
<li><input type="radio" name="template_name" value="custom" id="template_name_custom" disabled="disabled"/><label for="template_name_custom" class="disabled">Custom (Not Implemented)</label></li>
</ol>
</fieldset>
<fieldset>
<legend>Color Scheme</legend>
<ol>
<li><input type="radio" name="color_scheme_name" value="standard" id="color_scheme_name_standard" checked="checked"/><label for="color_scheme_name_standard">Standard <span class="example"><span class="standard-tag-start"><span class="standard-start-bracket"><</span>item <span class="standard-attribute-set"><span class="standard-attribute-name">partNum</span>="<span class="standard-attribute-value">872-AA</span>"</span><span class="standard-start-bracket">></span></span><span class="standard-tag-content">Lawnmower</span><span class="standard-tag-end"><span class="standard-end-bracket"></</span>item<span class="standard-end-bracket">></span></span></span></label></li>
<li><input type="radio" name="color_scheme_name" value="firefox" id="color_scheme_name_firefox" /><label for="color_scheme_name_firefox">Firefox <span class="color-scheme-firefox-example"><span class="tag-start"><span class="start-bracket"><</span>item <span class="attribute-set"><span class="attribute-name">partNum</span>="<span class="attribute-value">872-AA</span>"</span><span class="start-bracket">></span></span><span class="tag-content">Lawnmower</span><span class="tag-end"><span class="end-bracket"></</span>item<span class="end-bracket">></span></span></span></label></li>
<li><input type="radio" name="color_scheme_name" value="custom" id="color_scheme_name_custom" disabled="disabled"/><label for="color_scheme_name_custom" class="disabled">Custom (Not Implemented)</label></li>
</ol>
</fieldset>
<fieldset>
<legend>Document</legend>
<ol>
<li><input type="checkbox" name="start_nodes_collapsed" value="start_nodes_collapsed" id="start_nodes_collapsed" checked="checked"/><label for="start_nodes_collapsed">Start with all nodes collapsed</label></li>
</ol>
</fieldset>
<fieldset>
<legend>Keyboard & Mouse Commands</legend>
<ol>
<li><span style="color:blue">Shift</span>+<span style="color:blue">0</span> Toggle all nodes</li>
<li><span style="color:blue">Shift</span>+<span style="color:blue">1</span>..<span style="color:blue">9</span> Toggle all nodes on level 1..9</li>
<li><span style="color:blue">Shift</span>+<span style="color:blue">Click</span> Toggle current node and all children</li>
</ol>
</fieldset>
</body>
</html>