summaryrefslogtreecommitdiff
path: root/web/public/js
diff options
context:
space:
mode:
authorJochen Topf <jochen@topf.org>2014-05-16 20:22:14 +0200
committerJochen Topf <jochen@topf.org>2014-05-16 20:22:14 +0200
commit92730cc8ca987fc83a03e8a143b9b9667d21f412 (patch)
treee95ad266099b9390b82273836de38c2336e08ca7 /web/public/js
parent34a695cc9c8006adae4979603f7d202c4f08f9ef (diff)
downloadtaginfo-92730cc8ca987fc83a03e8a143b9b9667d21f412.tar
taginfo-92730cc8ca987fc83a03e8a143b9b9667d21f412.tar.gz
Disable adding items to comparison list that are already in there.
Diffstat (limited to 'web/public/js')
-rw-r--r--web/public/js/taginfo.js26
1 files changed, 23 insertions, 3 deletions
diff --git a/web/public/js/taginfo.js b/web/public/js/taginfo.js
index 8925e20..2348293 100644
--- a/web/public/js/taginfo.js
+++ b/web/public/js/taginfo.js
@@ -590,11 +590,18 @@ function set_comparison_list(list) {
jQuery.cookie('taginfo_comparison_list', list, { expires: 1, path: '/' });
}
-function comparison_list_update() {
+function comparison_list_update(key, value) {
var l = get_comparison_list().length;
+
var cl = jQuery('#list option:first').html();
cl = cl.replace(/([0-9]+)/, String(l));
jQuery('#list option:first').html(cl);
+
+ if (comparison_list_contains(get_comparison_list(), key, value)) {
+ jQuery('#list option:eq(1)').attr('style', 'color: #e0e0e0');
+ } else {
+ jQuery('#list option:eq(1)').attr('style', '');
+ }
if (l == 0) {
jQuery('#list option:eq(2)').attr('style', 'color: #e0e0e0');
} else {
@@ -605,6 +612,7 @@ function comparison_list_update() {
} else {
jQuery('#list option:eq(3)').attr('style', '');
}
+
jQuery('#list').val('title').change();
}
@@ -636,13 +644,25 @@ function comparison_list_url(list) {
}
}
+function comparison_list_contains(list, key, value) {
+ var contains = false;
+
+ jQuery.each(list, function(index, item) {
+ if (item[0] == key && item[1] == value) {
+ contains = true;
+ }
+ });
+
+ return contains;
+}
+
function comparison_list_change(key, value) {
var list = get_comparison_list(),
command = jQuery('#list').val();
if (command == 'title') {
return true;
- } else if (command == 'add') {
+ } else if (command == 'add' && !comparison_list_contains(list, key, value)) {
list.push([key, value]);
set_comparison_list(list);
} else if (command == 'clear') {
@@ -651,7 +671,7 @@ function comparison_list_change(key, value) {
window.location = comparison_list_url(list);
}
- comparison_list_update();
+ comparison_list_update(key, value);
return false;
}