From 8c9cfe238e565088b37d256eb461a01919ef9968 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Sun, 1 Nov 2015 13:42:56 +0100 Subject: Switch to HTML5 doctype + s/acronym/abbr/ + s/ / /e I'd have preferred to stick with XHTML 1.0, but unfortunately browsers won't allow you to use modern Javascript APIs with an older doctype. Note that most pages don't actually validate correctly as HTML5, I'm relying on browsers to be lenient. In either case, I'd like VNDB to stay valid XML (XHTML5, then), and luckily that shouldn't be a problem. --- data/js/misc.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'data/js') diff --git a/data/js/misc.js b/data/js/misc.js index 89572e82..a1e86827 100644 --- a/data/js/misc.js +++ b/data/js/misc.js @@ -210,7 +210,7 @@ if(byId('batchedit')) // mouse-over price information / disclaimer (function(){ if(byId('buynow')) { - var l = byClass(byId('buynow'), 'acronym', 'pricenote'); + var l = byClass(byId('buynow'), 'abbr', 'pricenote'); for(var i=0; i.. + * .. * * Clicking on the above link will cause the image viewer to open * full_image.jpg. The {category} part can be empty or absent. If it is not * empty, next/previous links will show up to point to the other images within * the same category. * - * ivInit() should be called when links with "iv:" tags are dynamically added - * or removed from the DOM. + * ivInit() should be called when links with "data-iv" attributes are + * dynamically added or removed from the DOM. */ // Cache of image categories and the list of associated link objects. Used to @@ -21,10 +21,10 @@ function init() { var l = byName('a'); for(var i=0;i Date: Sun, 1 Nov 2015 14:22:05 +0100 Subject: dropdownsearch.js: Perform search when copy-pasting or dragging text https://vndb.org/t950.103 --- data/js/dropdownsearch.js | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'data/js') diff --git a/data/js/dropdownsearch.js b/data/js/dropdownsearch.js index 35bd1443..e7c42dc0 100644 --- a/data/js/dropdownsearch.js +++ b/data/js/dropdownsearch.js @@ -41,6 +41,7 @@ function box() { function init(obj, url, trfunc, serfunc, retfunc) { obj.setAttribute('autocomplete', 'off'); obj.onkeydown = keydown; + obj.onclick = obj.onchange = obj.oninput = function() { return textchanged(obj); }; obj.onblur = blur; obj.ds_returnFunc = retfunc; obj.ds_trFunc = trfunc; @@ -48,6 +49,7 @@ function init(obj, url, trfunc, serfunc, retfunc) { obj.ds_searchURL = url; obj.ds_selectedId = 0; obj.ds_dosearch = null; + obj.ds_lastVal = obj.value; } function blur() { @@ -65,7 +67,7 @@ function setselected(obj, id) { function setvalue(obj) { if(obj.ds_selectedId != 0) - obj.value = obj.ds_serFunc(byId('ds_box_'+obj.ds_selectedId).ds_itemData, obj); + obj.value = obj.ds_lastVal = obj.ds_serFunc(byId('ds_box_'+obj.ds_selectedId).ds_itemData, obj); if(obj.ds_returnFunc) obj.ds_returnFunc(obj); @@ -110,6 +112,21 @@ function updown(obj, up) { return false; } +function textchanged(obj) { + // Ignore this event if the text hasn't actually changed. + if(obj.ds_lastVal == obj.value) + return true; + obj.ds_lastVal = obj.value; + + // perform search after a timeout + if(obj.ds_dosearch) + clearTimeout(obj.ds_dosearch); + obj.ds_dosearch = setTimeout(function() { + search(obj); + }, 500); + return true; +} + function keydown(ev) { var c = document.layers ? ev.which : document.all ? event.keyCode : ev.keyCode; var obj = this; @@ -123,14 +140,7 @@ function keydown(ev) { if(c == 38 || c == 40) // up / down return updown(obj, c == 38); - // perform search after a timeout - if(obj.ds_dosearch) - clearTimeout(obj.ds_dosearch); - obj.ds_dosearch = setTimeout(function() { - search(obj); - }, 500); - - return true; + return textchanged(obj); } function search(obj) { -- cgit v1.2.3 From bf391c804fbbd6469d2e2892c29f98cc7204d251 Mon Sep 17 00:00:00 2001 From: Yorhel Date: Sun, 1 Nov 2015 14:28:07 +0100 Subject: Use HTML5 'placeholder' attribute for main search box Instead of the JS hack. --- data/js/misc.js | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'data/js') diff --git a/data/js/misc.js b/data/js/misc.js index a1e86827..f41e8140 100644 --- a/data/js/misc.js +++ b/data/js/misc.js @@ -1,18 +1,3 @@ -// search box -byId('sq').onfocus = function () { - if(this.value == mt('_menu_emptysearch')) { - this.value = ''; - this.style.fontStyle = 'normal' - } -}; -byId('sq').onblur = function () { - if(this.value.length < 1) { - this.value = mt('_menu_emptysearch'); - this.style.fontStyle = 'italic' - } -}; - - function ulist_redirect(type, path, formcode, args) { var r = new RegExp('/('+type+'[0-9]+).*$'); location.href = location.href.replace(r, '/$1')+path -- cgit v1.2.3