diff --git a/CTFd/static/admin/js/chalboard.js b/CTFd/static/admin/js/chalboard.js
index 3f30690e..7c74d0ce 100644
--- a/CTFd/static/admin/js/chalboard.js
+++ b/CTFd/static/admin/js/chalboard.js
@@ -1,3 +1,15 @@
+//http://stackoverflow.com/a/7616484
+String.prototype.hashCode = function() {
+ var hash = 0, i, chr, len;
+ if (this.length == 0) return hash;
+ for (i = 0, len = this.length; i < len; i++) {
+ chr = this.charCodeAt(i);
+ hash = ((hash << 5) - hash) + chr;
+ hash |= 0; // Convert to 32bit integer
+ }
+ return hash;
+};
+
function loadchal(id) {
// $('#chal *').show()
// $('#chal > h1').hide()
@@ -130,7 +142,7 @@ function loadchals(){
for (var i = challenges['game'].length - 1; i >= 0; i--) {
if ($.inArray(challenges['game'][i].category, categories) == -1) {
categories.push(challenges['game'][i].category)
- $('#challenges').append($('
' + challenges['game'][i].category + ' |
'))
+ $('#challenges').append($('' + challenges['game'][i].category + ' |
'))
}
};
@@ -140,7 +152,7 @@ function loadchals(){
};
for (var i = 0; i <= challenges['game'].length - 1; i++) {
- $('#' + challenges['game'][i].category.replace(/ /g,"-")).append($(''));
+ $('#' + challenges['game'][i].category.replace(/ /g,"-").hashCode()).append($(''));
};
$('#challenges button').click(function (e) {
diff --git a/CTFd/static/js/chalboard.js b/CTFd/static/js/chalboard.js
index 90287e0c..1e14b330 100644
--- a/CTFd/static/js/chalboard.js
+++ b/CTFd/static/js/chalboard.js
@@ -13,6 +13,18 @@ function htmlentities(string) {
return $('').text(string).html();
}
+//http://stackoverflow.com/a/7616484
+String.prototype.hashCode = function() {
+ var hash = 0, i, chr, len;
+ if (this.length == 0) return hash;
+ for (i = 0, len = this.length; i < len; i++) {
+ chr = this.charCodeAt(i);
+ hash = ((hash << 5) - hash) + chr;
+ hash |= 0; // Convert to 32bit integer
+ }
+ return hash;
+};
+
var challenges;
function loadchal(id) {
@@ -189,12 +201,12 @@ function loadchals() {
challenges['game'][i].solves = 0
if ($.inArray(challenges['game'][i].category, categories) == -1) {
categories.push(challenges['game'][i].category)
- $('#challenges').append($('' + challenges['game'][i].category + ' |
'))
+ $('#challenges').append($('' + challenges['game'][i].category + ' |
'))
}
};
for (var i = 0; i <= challenges['game'].length - 1; i++) {
- $('#' + challenges['game'][i].category.replace(/ /g,"-")).append($(''));
+ $('#' + challenges['game'][i].category.replace(/ /g,"-").hashCode()).append($(''));
};
updatesolves()
marktoomanyattempts()