aboutsummaryrefslogtreecommitdiff
path: root/emcclib.js
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2013-03-31 09:58:45 +0000
committerSimon Tatham <anakin@pobox.com>2013-03-31 09:58:45 +0000
commit3e39f6b80b2b6e4308e2d3a9fa436cbbb9d9b621 (patch)
tree6d9a1d171f66e02216d35874ce2f17d241efb721 /emcclib.js
parent1264bccf4053d06d106d37b60516f7d27bfc8420 (diff)
downloadpuzzles-3e39f6b80b2b6e4308e2d3a9fa436cbbb9d9b621.zip
puzzles-3e39f6b80b2b6e4308e2d3a9fa436cbbb9d9b621.tar.gz
puzzles-3e39f6b80b2b6e4308e2d3a9fa436cbbb9d9b621.tar.bz2
puzzles-3e39f6b80b2b6e4308e2d3a9fa436cbbb9d9b621.tar.xz
Stop using the dangerously unescaped 'innerHTML' for <option>
contents; use document.createTextNode like I do everywhere else. [originally from svn r9787]
Diffstat (limited to 'emcclib.js')
-rw-r--r--emcclib.js16
1 files changed, 7 insertions, 9 deletions
diff --git a/emcclib.js b/emcclib.js
index 51c8f93..cc6df28 100644
--- a/emcclib.js
+++ b/emcclib.js
@@ -64,8 +64,8 @@ mergeInto(LibraryManager.library, {
*/
js_add_preset: function(ptr) {
var option = document.createElement("option");
- option.value = Pointer_stringify(ptr);
- option.innerHTML = Pointer_stringify(ptr);
+ option.value = gametypeoptions.length;
+ option.appendChild(document.createTextNode(Pointer_stringify(ptr)));
gametypeselector.appendChild(option);
gametypeoptions.push(option);
},
@@ -77,14 +77,12 @@ mergeInto(LibraryManager.library, {
* dropdown.
*/
js_get_selected_preset: function() {
- var val = 0;
for (var i in gametypeoptions) {
if (gametypeoptions[i].selected) {
- val = i;
- break;
+ return gametypeoptions[i].value;
}
}
- return val;
+ return 0;
},
/*
@@ -592,8 +590,8 @@ mergeInto(LibraryManager.library, {
var options = [];
for (var i in items) {
var option = document.createElement("option");
- option.value = items[i];
- option.innerHTML = items[i];
+ option.value = i;
+ option.appendChild(document.createTextNode(items[i]));
if (i == initvalue) option.selected = true;
dropdown.appendChild(option);
options.push(option);
@@ -605,7 +603,7 @@ mergeInto(LibraryManager.library, {
var val = 0;
for (var i in options) {
if (options[i].selected) {
- val = i;
+ val = options[i].value;
break;
}
}