r111066 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111065‎ | r111066 | r111067 >
Date:19:02, 9 February 2012
Author:kipcool
Status:deferred
Tags:
Comment:
- Search terms in bold in the comboboxes
- explang parameter stays when changing between view / edit / history
Modified paths:
  • /trunk/extensions/Wikidata/OmegaWiki/resources/omegawiki-ajax.js (modified) (history)
  • /trunk/extensions/Wikidata/OmegaWiki/resources/suggest.js (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikidata/OmegaWiki/resources/omegawiki-ajax.js
@@ -11,6 +11,17 @@
1212 }, function(){ //On Hover Out
1313 $(this).parent().find("ul.wd-dropdownlist").hide();
1414 });
 15+
 16+ // sticky explang
 17+ var explangUrl = document.URL.match( /explang=\d+/gi ) ;
 18+ if ( explangUrl!=null ) {
 19+ var explangNb = explangUrl[0].replace("explang=","") ;
 20+ $("#ca-edit, #ca-history, #ca-view").find("a").attr( "href", function(i, val) {
 21+ var bigoudi = '&' ;
 22+ if ( val.match( /\?/gi ) == null ) bigoudi = '?' ;
 23+ return val + bigoudi + 'explang=' + explangNb ;
 24+ });
 25+ }
1526 }); // jQuery
1627
1728 //TODO: convert the functions below to jQuery...
Index: trunk/extensions/Wikidata/OmegaWiki/resources/suggest.js
@@ -81,6 +81,27 @@
8282 //alert(http.responseText);
8383 if (http.responseText != '') {
8484 newTable.innerHTML = leftTrim(http.responseText);
 85+
 86+ // put the searched text in bold within the returned string
 87+ if ( suggestTextVal != "" ) {
 88+ var langnames = newTable.getElementsByTagName('td') ;
 89+ var searchTxt = new String ( suggestTextVal ) ;
 90+ // normalizeText removes diacritics (cf. omegawiki-ajax.js)
 91+ searchTxt = normalizeText ( searchTxt.toLowerCase() ) ;
 92+
 93+ for ( i=0 ; i < langnames.length ; i++ ) {
 94+ var searchInTxt = normalizeText ( langnames[i].innerHTML.toLowerCase() ) ;
 95+ var position = searchInTxt.indexOf( searchTxt );
 96+ if ( position >= 0 ) {
 97+ langnames[i].innerHTML = langnames[i].innerHTML.substr(0,position)
 98+ + "<b>"
 99+ + langnames[i].innerHTML.substr( position, searchTxt.length)
 100+ + "</b>"
 101+ + langnames[i].innerHTML.substr( position + searchTxt.length ) ;
 102+ }
 103+ }
 104+ }
 105+
85106 table.parentNode.replaceChild(newTable.firstChild, table);
86107 }
87108 suggestText.className = "";
@@ -226,9 +247,12 @@
227248 for (var i = 0; i < displayLabelColumnIndices.length; i++) {
228249 var columnValue = suggestRow.getElementsByTagName('td')[displayLabelColumnIndices[i]].innerHTML;
229250
230 - if (columnValue != "")
 251+ if (columnValue != "") {
 252+ columnValue = columnValue.replace ("<b>","");
 253+ columnValue = columnValue.replace ("</b>","");
231254 labels.push(columnValue);
232 - }
 255+ }
 256+ }
233257
234258 var idColumns = 1;
235259

Status & tagging log