r93458 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r93457‎ | r93458 | r93459 >
Date:13:15, 29 July 2011
Author:devayon
Status:deferred
Tags:
Comment:
refactored JSconform to coding convention
Modified paths:
  • /trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticMediaWiki/specials/AskSpecial/SMW_QueryUIHelper.php
@@ -181,13 +181,13 @@
182182 }
183183 $javascript_autocomplete_text = <<<END
184184 <script type="text/javascript">
185 -function split(val) {
 185+function smw_split(val) {
186186 return val.split('\\n');
187187 }
188 -function extractLast(term) {
189 - return split(term).pop();
 188+function smw_extractLast(term) {
 189+ return smw_split(term).pop();
190190 }
191 -function escapeQuestion(term){
 191+function smw_escapeQuestion(term){
192192 if (term.substring(0, 1) == "?") {
193193 return term.substring(1);
194194 } else {
@@ -198,7 +198,7 @@
199199 jQuery.noConflict();
200200 /* extending jQuery functions for custom highligting */
201201 jQuery.ui.autocomplete.prototype._renderItem = function( ul, item) {
202 - var term_without_q = escapeQuestion(extractLast(this.term));
 202+ var term_without_q = smw_escapeQuestion(smw_extractLast(this.term));
203203 var re = new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + term_without_q.replace("/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi", "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi");
204204 var loc = item.label.search(re);
205205 if (loc >= 0) {
@@ -331,7 +331,9 @@
332332 */
333333 protected function getQueryFormBox( $errors = '' ) {
334334 $result = '';
335 - $result = Html::element( 'textarea', array( 'name' => 'q', 'id' => 'querybox', 'rows' => '6' ), $this->uiCore->getQueryString() );
 335+ $result = Html::element( 'textarea', array( 'name' => 'q', 'id' => 'querybox',
 336+ 'rows' => '1'),
 337+ $this->uiCore->getQueryString() );
336338 // TODO:enable/disable on checking for errors; perhaps show error messages right below the box
337339 return $result;
338340 }
@@ -745,7 +747,7 @@
746748 jQuery.getJSON(url, 'search='+request.term, function(data){
747749 //remove the namespace prefix 'Property:' from returned data and add prefix '?'
748750 for(i=0;i<data[1].length;i++) data[1][i]="?"+data[1][i].substr(data[1][i].indexOf(':')+1);
749 - response(jQuery.ui.autocomplete.filter(data[1], escapeQuestion(extractLast(request.term))));
 751+ response(jQuery.ui.autocomplete.filter(data[1], smw_escapeQuestion(smw_extractLast(request.term))));
750752 });
751753 },
752754 focus: function() {
@@ -753,7 +755,7 @@
754756 return false;
755757 },
756758 select: function(event, ui) {
757 - var terms = split( this.value );
 759+ var terms = smw_split( this.value );
758760 // remove the current input
759761 terms.pop();
760762 // add the selected item