r75215 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75214‎ | r75215 | r75216 >
Date:22:30, 22 October 2010
Author:yaron
Status:deferred
Tags:
Comment:
Fixed handling of "\n" delimiter
Modified paths:
  • /trunk/extensions/SemanticForms/libs/SemanticForms.js (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/libs/SemanticForms.js
@@ -56,11 +56,21 @@
5757
5858 /* delimiter != '' means multiple autocomplete */
5959
60 - if (delimiter != null) {
 60+ if (delimiter != null) {
 61+ // Special handling for "\n" - if it's that, change it to an
 62+ // actual newline - otherwise, add a space to the end.
 63+ // This doesn't cover the case of a delimiter that's a newline
 64+ // plus something else, like ".\n" or "\n\n", but in our
 65+ // experience no one has yet needed that.
 66+ if ( delimiter == "\\n" ) {
 67+ delimiter = "\n";
 68+ } else {
 69+ delimiter += " ";
 70+ }
6171
6272 jQuery(document).ready(function(){
6373 function split(val) {
64 - return val.split(delimiter+" ");
 74+ return val.split(delimiter);
6575 }
6676 function extractLast(term) {
6777 return split(term).pop();
@@ -84,7 +94,7 @@
8595 terms.push( ui.item.value );
8696 // add placeholder to get the comma-and-space at the end
8797 terms.push("");
88 - this.value = terms.join(delimiter+" ");
 98+ this.value = terms.join(delimiter);
8999 return false;
90100 }
91101 });
@@ -595,8 +605,7 @@
596606 var field_string = sfgAutocompleteMappings[field_num];
597607 if (field_string) {
598608 var div_id = input_id.replace(/input_/g, 'div_');
599 - var field_values = new Array();
600 - field_values = field_string.split(',');
 609+ var field_values = field_string.split(',');
601610 var delimiter = null;
602611 var data_source = field_values[0];
603612 if (field_values[1] == 'list') {

Status & tagging log