diff options
| author | Tristan Zur <tzur@web.web.ccwn.org> | 2014-03-27 22:27:47 +0100 |
|---|---|---|
| committer | Tristan Zur <tzur@web.web.ccwn.org> | 2014-03-27 22:27:47 +0100 |
| commit | b62676ca5d3d6f6ba3f019ea3f99722e165a98d8 (patch) | |
| tree | 86722cb80f07d4569f90088eeaea2fc2f6e2ef94 /js/dojo-1.6/dojox/string | |
Diffstat (limited to 'js/dojo-1.6/dojox/string')
| -rw-r--r-- | js/dojo-1.6/dojox/string/BidiComplex.js | 324 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/string/BidiComplex.xd.js | 328 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/string/Builder.js | 141 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/string/Builder.xd.js | 145 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/string/README | 39 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/string/sprintf.js | 413 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/string/sprintf.xd.js | 418 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/string/tokenize.js | 49 | ||||
| -rw-r--r-- | js/dojo-1.6/dojox/string/tokenize.xd.js | 53 |
9 files changed, 1910 insertions, 0 deletions
diff --git a/js/dojo-1.6/dojox/string/BidiComplex.js b/js/dojo-1.6/dojox/string/BidiComplex.js new file mode 100644 index 0000000..a0d646e --- /dev/null +++ b/js/dojo-1.6/dojox/string/BidiComplex.js @@ -0,0 +1,324 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+if(!dojo._hasResource["dojox.string.BidiComplex"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.string.BidiComplex"] = true;
+dojo.provide("dojox.string.BidiComplex");
+dojo.experimental("dojox.string.BidiComplex");
+
+// summary:
+// BiDiComplex module handles complex expression issues known when using BiDi characters
+// in File Paths, URLs, E-mail Address, XPATH, etc.
+// this module adds property listeners to the text fields to correct the text representation
+// in both static text and dynamic text during user input.
+
+(function(){
+
+ var _str0 = []; //FIXME: shared reference here among various functions means the functions can't be reused
+
+ dojox.string.BidiComplex.attachInput = function(/*DOMNode*/field, /*String*/pattern){
+ // summary:
+ // Attach key listeners to the INPUT field to accomodate dynamic complex BiDi expressions
+ // field: INPUT DOM node
+ // pattern: Complex Expression Pattern type. One of "FILE_PATH", "URL", "EMAIL", "XPATH"
+
+ field.alt = pattern;
+
+ dojo.connect(field, "onkeydown", this, "_ceKeyDown");
+ dojo.connect(field, "onkeyup", this, "_ceKeyUp");
+
+ dojo.connect(field, "oncut", this, "_ceCutText");
+ dojo.connect(field, "oncopy", this, "_ceCopyText");
+
+ field.value = dojox.string.BidiComplex.createDisplayString(field.value, field.alt);
+ };
+
+ dojox.string.BidiComplex.createDisplayString = function(/*String*/str, /*String*/pattern){
+ // summary:
+ // Create the display string by adding the Unicode direction Markers
+ // pattern: Complex Expression Pattern type. One of "FILE_PATH", "URL", "EMAIL", "XPATH"
+
+ str = dojox.string.BidiComplex.stripSpecialCharacters(str);
+ var segmentsPointers = dojox.string.BidiComplex._parse(str, pattern);
+
+ var buf = '\u202A'/*LRE*/ + str;
+ var shift = 1;
+ dojo.forEach(segmentsPointers, function(n){
+ if(n != null){
+ var preStr = buf.substring(0, n + shift);
+ var postStr = buf.substring(n + shift, buf.length);
+ buf = preStr + '\u200E'/*LRM*/ + postStr;
+ shift++;
+ }
+ });
+ return buf;
+ };
+
+ dojox.string.BidiComplex.stripSpecialCharacters = function(str){
+ // summary:
+ // removes all Unicode directional markers from the string
+
+ return str.replace(/[\u200E\u200F\u202A-\u202E]/g, ""); // String
+ };
+
+ dojox.string.BidiComplex._ceKeyDown = function(event){
+ var elem = dojo.isIE ? event.srcElement : event.target;
+ _str0 = elem.value;
+ };
+
+ dojox.string.BidiComplex._ceKeyUp = function(event){
+ var LRM = '\u200E';
+ var elem = dojo.isIE ? event.srcElement : event.target;
+
+ var str1 = elem.value;
+ var ieKey = event.keyCode;
+
+ if((ieKey == dojo.keys.HOME)
+ || (ieKey == dojo.keys.END)
+ || (ieKey == dojo.keys.SHIFT)){
+ return;
+ }
+
+ var cursorStart, cursorEnd;
+ var selection = dojox.string.BidiComplex._getCaretPos(event, elem);
+ if(selection){
+ cursorStart = selection[0];
+ cursorEnd = selection[1];
+ }
+
+ //Jump over a cursor processing
+ if(dojo.isIE){
+ var cursorStart1 = cursorStart, cursorEnd1 = cursorEnd;
+
+ if(ieKey == dojo.keys.LEFT_ARROW){
+ if((str1.charAt(cursorEnd-1) == LRM)
+ && (cursorStart == cursorEnd)){
+ dojox.string.BidiComplex._setSelectedRange(elem,cursorStart - 1, cursorEnd - 1);
+ }
+ return;
+ }
+
+ if(ieKey == dojo.keys.RIGHT_ARROW){
+ if(str1.charAt(cursorEnd-1) == LRM){
+ cursorEnd1 = cursorEnd + 1;
+ if(cursorStart == cursorEnd){
+ cursorStart1 = cursorStart + 1;
+ }
+ }
+
+ dojox.string.BidiComplex._setSelectedRange(elem, cursorStart1, cursorEnd1);
+ return;
+ }
+ }else{ //Firefox
+ if(ieKey == dojo.keys.LEFT_ARROW){
+ if(str1.charAt(cursorEnd-1) == LRM){
+ dojox.string.BidiComplex._setSelectedRange(elem, cursorStart - 1, cursorEnd - 1);
+ }
+ return;
+ }
+ if(ieKey == dojo.keys.RIGHT_ARROW){
+ if(str1.charAt(cursorEnd-1) == LRM){
+ dojox.string.BidiComplex._setSelectedRange(elem, cursorStart + 1, cursorEnd + 1);
+ }
+ return;
+ }
+ }
+
+ var str2 = dojox.string.BidiComplex.createDisplayString(str1, elem.alt);
+
+ if(str1 != str2)
+ {
+ window.status = str1 + " c=" + cursorEnd;
+ elem.value = str2;
+
+ if((ieKey == dojo.keys.DELETE) && (str2.charAt(cursorEnd)==LRM)){
+ elem.value = str2.substring(0, cursorEnd) + str2.substring(cursorEnd+2, str2.length);
+ }
+
+ if(ieKey == dojo.keys.DELETE){
+ dojox.string.BidiComplex._setSelectedRange(elem,cursorStart,cursorEnd);
+ }else if(ieKey == dojo.keys.BACKSPACE){
+ if((_str0.length >= cursorEnd) && (_str0.charAt(cursorEnd-1)==LRM)){
+ dojox.string.BidiComplex._setSelectedRange(elem, cursorStart - 1, cursorEnd - 1);
+ }else{
+ dojox.string.BidiComplex._setSelectedRange(elem, cursorStart, cursorEnd);
+ }
+ }else if(elem.value.charAt(cursorEnd) != LRM){
+ dojox.string.BidiComplex._setSelectedRange(elem, cursorStart + 1, cursorEnd + 1);
+ }
+ }
+ };
+
+ dojox.string.BidiComplex._processCopy = function(elem, text, isReverse){
+ // summary:
+ // This function strips the unicode directional controls when the text copied to the Clipboard
+
+ if(text == null){
+ if(dojo.isIE){
+ var range = document.selection.createRange();
+ text = range.text;
+ }else{
+ text = elem.value.substring(elem.selectionStart, elem.selectionEnd);
+ }
+ }
+
+ var textToClipboard = dojox.string.BidiComplex.stripSpecialCharacters(text);
+
+ if(dojo.isIE){
+ window.clipboardData.setData("Text", textToClipboard);
+ }
+ return true;
+ };
+
+ dojox.string.BidiComplex._ceCopyText = function(elem){
+ if(dojo.isIE){
+ elem.returnValue = false;
+ }
+ return dojox.string.BidiComplex._processCopy(elem, null, false);
+ };
+
+ dojox.string.BidiComplex._ceCutText = function(elem){
+
+ var ret = dojox.string.BidiComplex._processCopy(elem, null, false);
+ if(!ret){
+ return false;
+ }
+
+ if(dojo.isIE){
+ // curPos = elem.selectionStart;
+ document.selection.clear();
+ }else{
+ var curPos = elem.selectionStart;
+ elem.value = elem.value.substring(0, curPos) + elem.value.substring(elem.selectionEnd);
+ elem.setSelectionRange(curPos, curPos);
+ }
+
+ return true;
+ };
+
+ // is there dijit code to do this?
+ dojox.string.BidiComplex._getCaretPos = function(event, elem){
+ if(dojo.isIE){
+ var position = 0,
+ range = document.selection.createRange().duplicate(),
+ range2 = range.duplicate(),
+ rangeLength = range.text.length;
+
+ if(elem.type == "textarea"){
+ range2.moveToElementText(elem);
+ }else{
+ range2.expand('textedit');
+ }
+ while(range.compareEndPoints('StartToStart', range2) > 0){
+ range.moveStart('character', -1);
+ ++position;
+ }
+
+ return [position, position + rangeLength];
+ }
+
+ return [event.target.selectionStart, event.target.selectionEnd];
+ };
+
+ // is there dijit code to do this?
+ dojox.string.BidiComplex._setSelectedRange = function(elem,selectionStart,selectionEnd){
+ if(dojo.isIE){
+ var range = elem.createTextRange();
+ if(range){
+ if(elem.type == "textarea"){
+ range.moveToElementText(elem);
+ }else{
+ range.expand('textedit');
+ }
+
+ range.collapse();
+ range.moveEnd('character', selectionEnd);
+ range.moveStart('character', selectionStart);
+ range.select();
+ }
+ }else{
+ elem.selectionStart = selectionStart;
+ elem.selectionEnd = selectionEnd;
+ }
+ };
+
+ var _isBidiChar = function(c){
+ return (c >= '\u0030' && c <= '\u0039') || (c > '\u00ff');
+ };
+
+ var _isLatinChar = function(c){
+ return (c >= '\u0041' && c <= '\u005A') || (c >= '\u0061' && c <= '\u007A');
+ };
+
+ var _isCharBeforeBiDiChar = function(buffer, i, previous){
+ while(i > 0){
+ if(i == previous){
+ return false;
+ }
+ i--;
+ if(_isBidiChar(buffer.charAt(i))){
+ return true;
+ }
+ if(_isLatinChar(buffer.charAt(i))){
+ return false;
+ }
+ }
+ return false;
+ };
+
+
+ dojox.string.BidiComplex._parse = function(/*String*/str, /*String*/pattern){
+ var previous = -1, segmentsPointers = [];
+ var delimiters = {
+ FILE_PATH: "/\\:.",
+ URL: "/:.?=&#",
+ XPATH: "/\\:.<>=[]",
+ EMAIL: "<>@.,;"
+ }[pattern];
+
+ switch(pattern){
+ case "FILE_PATH":
+ case "URL":
+ case "XPATH":
+ dojo.forEach(str, function(ch, i){
+ if(delimiters.indexOf(ch) >= 0 && _isCharBeforeBiDiChar(str, i, previous)){
+ previous = i;
+ segmentsPointers.push(i);
+ }
+ });
+ break;
+ case "EMAIL":
+ var inQuotes = false; // FIXME: unused?
+
+ dojo.forEach(str, function(ch, i){
+ if(ch== '\"'){
+ if(_isCharBeforeBiDiChar(str, i, previous)){
+ previous = i;
+ segmentsPointers.push(i);
+ }
+ i++;
+ var i1 = str.indexOf('\"', i);
+ if(i1 >= i){
+ i = i1;
+ }
+ if(_isCharBeforeBiDiChar(str, i, previous)){
+ previous = i;
+ segmentsPointers.push(i);
+ }
+ }
+
+ if(delimiters.indexOf(ch) >= 0 && _isCharBeforeBiDiChar(str, i, previous)){
+ previous = i;
+ segmentsPointers.push(i);
+ }
+ });
+ }
+ return segmentsPointers;
+ };
+})();
+
+}
diff --git a/js/dojo-1.6/dojox/string/BidiComplex.xd.js b/js/dojo-1.6/dojox/string/BidiComplex.xd.js new file mode 100644 index 0000000..1a7cef3 --- /dev/null +++ b/js/dojo-1.6/dojox/string/BidiComplex.xd.js @@ -0,0 +1,328 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+dojo._xdResourceLoaded(function(dojo, dijit, dojox){
+return {depends: [["provide", "dojox.string.BidiComplex"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.string.BidiComplex"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.string.BidiComplex"] = true;
+dojo.provide("dojox.string.BidiComplex");
+dojo.experimental("dojox.string.BidiComplex");
+
+// summary:
+// BiDiComplex module handles complex expression issues known when using BiDi characters
+// in File Paths, URLs, E-mail Address, XPATH, etc.
+// this module adds property listeners to the text fields to correct the text representation
+// in both static text and dynamic text during user input.
+
+(function(){
+
+ var _str0 = []; //FIXME: shared reference here among various functions means the functions can't be reused
+
+ dojox.string.BidiComplex.attachInput = function(/*DOMNode*/field, /*String*/pattern){
+ // summary:
+ // Attach key listeners to the INPUT field to accomodate dynamic complex BiDi expressions
+ // field: INPUT DOM node
+ // pattern: Complex Expression Pattern type. One of "FILE_PATH", "URL", "EMAIL", "XPATH"
+
+ field.alt = pattern;
+
+ dojo.connect(field, "onkeydown", this, "_ceKeyDown");
+ dojo.connect(field, "onkeyup", this, "_ceKeyUp");
+
+ dojo.connect(field, "oncut", this, "_ceCutText");
+ dojo.connect(field, "oncopy", this, "_ceCopyText");
+
+ field.value = dojox.string.BidiComplex.createDisplayString(field.value, field.alt);
+ };
+
+ dojox.string.BidiComplex.createDisplayString = function(/*String*/str, /*String*/pattern){
+ // summary:
+ // Create the display string by adding the Unicode direction Markers
+ // pattern: Complex Expression Pattern type. One of "FILE_PATH", "URL", "EMAIL", "XPATH"
+
+ str = dojox.string.BidiComplex.stripSpecialCharacters(str);
+ var segmentsPointers = dojox.string.BidiComplex._parse(str, pattern);
+
+ var buf = '\u202A'/*LRE*/ + str;
+ var shift = 1;
+ dojo.forEach(segmentsPointers, function(n){
+ if(n != null){
+ var preStr = buf.substring(0, n + shift);
+ var postStr = buf.substring(n + shift, buf.length);
+ buf = preStr + '\u200E'/*LRM*/ + postStr;
+ shift++;
+ }
+ });
+ return buf;
+ };
+
+ dojox.string.BidiComplex.stripSpecialCharacters = function(str){
+ // summary:
+ // removes all Unicode directional markers from the string
+
+ return str.replace(/[\u200E\u200F\u202A-\u202E]/g, ""); // String
+ };
+
+ dojox.string.BidiComplex._ceKeyDown = function(event){
+ var elem = dojo.isIE ? event.srcElement : event.target;
+ _str0 = elem.value;
+ };
+
+ dojox.string.BidiComplex._ceKeyUp = function(event){
+ var LRM = '\u200E';
+ var elem = dojo.isIE ? event.srcElement : event.target;
+
+ var str1 = elem.value;
+ var ieKey = event.keyCode;
+
+ if((ieKey == dojo.keys.HOME)
+ || (ieKey == dojo.keys.END)
+ || (ieKey == dojo.keys.SHIFT)){
+ return;
+ }
+
+ var cursorStart, cursorEnd;
+ var selection = dojox.string.BidiComplex._getCaretPos(event, elem);
+ if(selection){
+ cursorStart = selection[0];
+ cursorEnd = selection[1];
+ }
+
+ //Jump over a cursor processing
+ if(dojo.isIE){
+ var cursorStart1 = cursorStart, cursorEnd1 = cursorEnd;
+
+ if(ieKey == dojo.keys.LEFT_ARROW){
+ if((str1.charAt(cursorEnd-1) == LRM)
+ && (cursorStart == cursorEnd)){
+ dojox.string.BidiComplex._setSelectedRange(elem,cursorStart - 1, cursorEnd - 1);
+ }
+ return;
+ }
+
+ if(ieKey == dojo.keys.RIGHT_ARROW){
+ if(str1.charAt(cursorEnd-1) == LRM){
+ cursorEnd1 = cursorEnd + 1;
+ if(cursorStart == cursorEnd){
+ cursorStart1 = cursorStart + 1;
+ }
+ }
+
+ dojox.string.BidiComplex._setSelectedRange(elem, cursorStart1, cursorEnd1);
+ return;
+ }
+ }else{ //Firefox
+ if(ieKey == dojo.keys.LEFT_ARROW){
+ if(str1.charAt(cursorEnd-1) == LRM){
+ dojox.string.BidiComplex._setSelectedRange(elem, cursorStart - 1, cursorEnd - 1);
+ }
+ return;
+ }
+ if(ieKey == dojo.keys.RIGHT_ARROW){
+ if(str1.charAt(cursorEnd-1) == LRM){
+ dojox.string.BidiComplex._setSelectedRange(elem, cursorStart + 1, cursorEnd + 1);
+ }
+ return;
+ }
+ }
+
+ var str2 = dojox.string.BidiComplex.createDisplayString(str1, elem.alt);
+
+ if(str1 != str2)
+ {
+ window.status = str1 + " c=" + cursorEnd;
+ elem.value = str2;
+
+ if((ieKey == dojo.keys.DELETE) && (str2.charAt(cursorEnd)==LRM)){
+ elem.value = str2.substring(0, cursorEnd) + str2.substring(cursorEnd+2, str2.length);
+ }
+
+ if(ieKey == dojo.keys.DELETE){
+ dojox.string.BidiComplex._setSelectedRange(elem,cursorStart,cursorEnd);
+ }else if(ieKey == dojo.keys.BACKSPACE){
+ if((_str0.length >= cursorEnd) && (_str0.charAt(cursorEnd-1)==LRM)){
+ dojox.string.BidiComplex._setSelectedRange(elem, cursorStart - 1, cursorEnd - 1);
+ }else{
+ dojox.string.BidiComplex._setSelectedRange(elem, cursorStart, cursorEnd);
+ }
+ }else if(elem.value.charAt(cursorEnd) != LRM){
+ dojox.string.BidiComplex._setSelectedRange(elem, cursorStart + 1, cursorEnd + 1);
+ }
+ }
+ };
+
+ dojox.string.BidiComplex._processCopy = function(elem, text, isReverse){
+ // summary:
+ // This function strips the unicode directional controls when the text copied to the Clipboard
+
+ if(text == null){
+ if(dojo.isIE){
+ var range = document.selection.createRange();
+ text = range.text;
+ }else{
+ text = elem.value.substring(elem.selectionStart, elem.selectionEnd);
+ }
+ }
+
+ var textToClipboard = dojox.string.BidiComplex.stripSpecialCharacters(text);
+
+ if(dojo.isIE){
+ window.clipboardData.setData("Text", textToClipboard);
+ }
+ return true;
+ };
+
+ dojox.string.BidiComplex._ceCopyText = function(elem){
+ if(dojo.isIE){
+ elem.returnValue = false;
+ }
+ return dojox.string.BidiComplex._processCopy(elem, null, false);
+ };
+
+ dojox.string.BidiComplex._ceCutText = function(elem){
+
+ var ret = dojox.string.BidiComplex._processCopy(elem, null, false);
+ if(!ret){
+ return false;
+ }
+
+ if(dojo.isIE){
+ // curPos = elem.selectionStart;
+ document.selection.clear();
+ }else{
+ var curPos = elem.selectionStart;
+ elem.value = elem.value.substring(0, curPos) + elem.value.substring(elem.selectionEnd);
+ elem.setSelectionRange(curPos, curPos);
+ }
+
+ return true;
+ };
+
+ // is there dijit code to do this?
+ dojox.string.BidiComplex._getCaretPos = function(event, elem){
+ if(dojo.isIE){
+ var position = 0,
+ range = document.selection.createRange().duplicate(),
+ range2 = range.duplicate(),
+ rangeLength = range.text.length;
+
+ if(elem.type == "textarea"){
+ range2.moveToElementText(elem);
+ }else{
+ range2.expand('textedit');
+ }
+ while(range.compareEndPoints('StartToStart', range2) > 0){
+ range.moveStart('character', -1);
+ ++position;
+ }
+
+ return [position, position + rangeLength];
+ }
+
+ return [event.target.selectionStart, event.target.selectionEnd];
+ };
+
+ // is there dijit code to do this?
+ dojox.string.BidiComplex._setSelectedRange = function(elem,selectionStart,selectionEnd){
+ if(dojo.isIE){
+ var range = elem.createTextRange();
+ if(range){
+ if(elem.type == "textarea"){
+ range.moveToElementText(elem);
+ }else{
+ range.expand('textedit');
+ }
+
+ range.collapse();
+ range.moveEnd('character', selectionEnd);
+ range.moveStart('character', selectionStart);
+ range.select();
+ }
+ }else{
+ elem.selectionStart = selectionStart;
+ elem.selectionEnd = selectionEnd;
+ }
+ };
+
+ var _isBidiChar = function(c){
+ return (c >= '\u0030' && c <= '\u0039') || (c > '\u00ff');
+ };
+
+ var _isLatinChar = function(c){
+ return (c >= '\u0041' && c <= '\u005A') || (c >= '\u0061' && c <= '\u007A');
+ };
+
+ var _isCharBeforeBiDiChar = function(buffer, i, previous){
+ while(i > 0){
+ if(i == previous){
+ return false;
+ }
+ i--;
+ if(_isBidiChar(buffer.charAt(i))){
+ return true;
+ }
+ if(_isLatinChar(buffer.charAt(i))){
+ return false;
+ }
+ }
+ return false;
+ };
+
+
+ dojox.string.BidiComplex._parse = function(/*String*/str, /*String*/pattern){
+ var previous = -1, segmentsPointers = [];
+ var delimiters = {
+ FILE_PATH: "/\\:.",
+ URL: "/:.?=&#",
+ XPATH: "/\\:.<>=[]",
+ EMAIL: "<>@.,;"
+ }[pattern];
+
+ switch(pattern){
+ case "FILE_PATH":
+ case "URL":
+ case "XPATH":
+ dojo.forEach(str, function(ch, i){
+ if(delimiters.indexOf(ch) >= 0 && _isCharBeforeBiDiChar(str, i, previous)){
+ previous = i;
+ segmentsPointers.push(i);
+ }
+ });
+ break;
+ case "EMAIL":
+ var inQuotes = false; // FIXME: unused?
+
+ dojo.forEach(str, function(ch, i){
+ if(ch== '\"'){
+ if(_isCharBeforeBiDiChar(str, i, previous)){
+ previous = i;
+ segmentsPointers.push(i);
+ }
+ i++;
+ var i1 = str.indexOf('\"', i);
+ if(i1 >= i){
+ i = i1;
+ }
+ if(_isCharBeforeBiDiChar(str, i, previous)){
+ previous = i;
+ segmentsPointers.push(i);
+ }
+ }
+
+ if(delimiters.indexOf(ch) >= 0 && _isCharBeforeBiDiChar(str, i, previous)){
+ previous = i;
+ segmentsPointers.push(i);
+ }
+ });
+ }
+ return segmentsPointers;
+ };
+})();
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/string/Builder.js b/js/dojo-1.6/dojox/string/Builder.js new file mode 100644 index 0000000..fe226a0 --- /dev/null +++ b/js/dojo-1.6/dojox/string/Builder.js @@ -0,0 +1,141 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+if(!dojo._hasResource["dojox.string.Builder"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.string.Builder"] = true;
+dojo.provide("dojox.string.Builder");
+
+dojox.string.Builder = function(/*String?*/str){
+ // summary:
+ // A fast buffer for creating large strings.
+ //
+ // length: Number
+ // The current length of the internal string.
+
+ // N.B. the public nature of the internal buffer is no longer
+ // needed because the IE-specific fork is no longer needed--TRT.
+ var b = "";
+ this.length = 0;
+
+ this.append = function(/* String... */s){
+ // summary: Append all arguments to the end of the buffer
+ if(arguments.length>1){
+ /*
+ This is a loop unroll was designed specifically for Firefox;
+ it would seem that static index access on an Arguments
+ object is a LOT faster than doing dynamic index access.
+ Therefore, we create a buffer string and take advantage
+ of JS's switch fallthrough. The peformance of this method
+ comes very close to straight up string concatenation (+=).
+
+ If the arguments object length is greater than 9, we fall
+ back to standard dynamic access.
+
+ This optimization seems to have no real effect on either
+ Safari or Opera, so we just use it for all.
+
+ It turns out also that this loop unroll can increase performance
+ significantly with Internet Explorer, particularly when
+ as many arguments are provided as possible.
+
+ Loop unroll per suggestion from Kris Zyp, implemented by
+ Tom Trenka.
+
+ Note: added empty string to force a string cast if needed.
+ */
+ var tmp="", l=arguments.length;
+ switch(l){
+ case 9: tmp=""+arguments[8]+tmp;
+ case 8: tmp=""+arguments[7]+tmp;
+ case 7: tmp=""+arguments[6]+tmp;
+ case 6: tmp=""+arguments[5]+tmp;
+ case 5: tmp=""+arguments[4]+tmp;
+ case 4: tmp=""+arguments[3]+tmp;
+ case 3: tmp=""+arguments[2]+tmp;
+ case 2: {
+ b+=""+arguments[0]+arguments[1]+tmp;
+ break;
+ }
+ default: {
+ var i=0;
+ while(i<arguments.length){
+ tmp += arguments[i++];
+ }
+ b += tmp;
+ }
+ }
+ } else {
+ b += s;
+ }
+ this.length = b.length;
+ return this; // dojox.string.Builder
+ };
+
+ this.concat = function(/*String...*/s){
+ // summary:
+ // Alias for append.
+ return this.append.apply(this, arguments); // dojox.string.Builder
+ };
+
+ this.appendArray = function(/*Array*/strings) {
+ // summary:
+ // Append an array of items to the internal buffer.
+
+ // Changed from String.prototype.concat.apply because of IE.
+ return this.append.apply(this, strings); // dojox.string.Builder
+ };
+
+ this.clear = function(){
+ // summary:
+ // Remove all characters from the buffer.
+ b = "";
+ this.length = 0;
+ return this; // dojox.string.Builder
+ };
+
+ this.replace = function(/* String */oldStr, /* String */ newStr){
+ // summary:
+ // Replace instances of one string with another in the buffer.
+ b = b.replace(oldStr,newStr);
+ this.length = b.length;
+ return this; // dojox.string.Builder
+ };
+
+ this.remove = function(/* Number */start, /* Number? */len){
+ // summary:
+ // Remove len characters starting at index start. If len
+ // is not provided, the end of the string is assumed.
+ if(len===undefined){ len = b.length; }
+ if(len == 0){ return this; }
+ b = b.substr(0, start) + b.substr(start+len);
+ this.length = b.length;
+ return this; // dojox.string.Builder
+ };
+
+ this.insert = function(/* Number */index, /* String */str){
+ // summary:
+ // Insert string str starting at index.
+ if(index == 0){
+ b = str + b;
+ }else{
+ b = b.slice(0, index) + str + b.slice(index);
+ }
+ this.length = b.length;
+ return this; // dojox.string.Builder
+ };
+
+ this.toString = function(){
+ // summary:
+ // Return the string representation of the internal buffer.
+ return b; // String
+ };
+
+ // initialize the buffer.
+ if(str){ this.append(str); }
+};
+
+}
diff --git a/js/dojo-1.6/dojox/string/Builder.xd.js b/js/dojo-1.6/dojox/string/Builder.xd.js new file mode 100644 index 0000000..54642c1 --- /dev/null +++ b/js/dojo-1.6/dojox/string/Builder.xd.js @@ -0,0 +1,145 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+dojo._xdResourceLoaded(function(dojo, dijit, dojox){
+return {depends: [["provide", "dojox.string.Builder"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.string.Builder"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.string.Builder"] = true;
+dojo.provide("dojox.string.Builder");
+
+dojox.string.Builder = function(/*String?*/str){
+ // summary:
+ // A fast buffer for creating large strings.
+ //
+ // length: Number
+ // The current length of the internal string.
+
+ // N.B. the public nature of the internal buffer is no longer
+ // needed because the IE-specific fork is no longer needed--TRT.
+ var b = "";
+ this.length = 0;
+
+ this.append = function(/* String... */s){
+ // summary: Append all arguments to the end of the buffer
+ if(arguments.length>1){
+ /*
+ This is a loop unroll was designed specifically for Firefox;
+ it would seem that static index access on an Arguments
+ object is a LOT faster than doing dynamic index access.
+ Therefore, we create a buffer string and take advantage
+ of JS's switch fallthrough. The peformance of this method
+ comes very close to straight up string concatenation (+=).
+
+ If the arguments object length is greater than 9, we fall
+ back to standard dynamic access.
+
+ This optimization seems to have no real effect on either
+ Safari or Opera, so we just use it for all.
+
+ It turns out also that this loop unroll can increase performance
+ significantly with Internet Explorer, particularly when
+ as many arguments are provided as possible.
+
+ Loop unroll per suggestion from Kris Zyp, implemented by
+ Tom Trenka.
+
+ Note: added empty string to force a string cast if needed.
+ */
+ var tmp="", l=arguments.length;
+ switch(l){
+ case 9: tmp=""+arguments[8]+tmp;
+ case 8: tmp=""+arguments[7]+tmp;
+ case 7: tmp=""+arguments[6]+tmp;
+ case 6: tmp=""+arguments[5]+tmp;
+ case 5: tmp=""+arguments[4]+tmp;
+ case 4: tmp=""+arguments[3]+tmp;
+ case 3: tmp=""+arguments[2]+tmp;
+ case 2: {
+ b+=""+arguments[0]+arguments[1]+tmp;
+ break;
+ }
+ default: {
+ var i=0;
+ while(i<arguments.length){
+ tmp += arguments[i++];
+ }
+ b += tmp;
+ }
+ }
+ } else {
+ b += s;
+ }
+ this.length = b.length;
+ return this; // dojox.string.Builder
+ };
+
+ this.concat = function(/*String...*/s){
+ // summary:
+ // Alias for append.
+ return this.append.apply(this, arguments); // dojox.string.Builder
+ };
+
+ this.appendArray = function(/*Array*/strings) {
+ // summary:
+ // Append an array of items to the internal buffer.
+
+ // Changed from String.prototype.concat.apply because of IE.
+ return this.append.apply(this, strings); // dojox.string.Builder
+ };
+
+ this.clear = function(){
+ // summary:
+ // Remove all characters from the buffer.
+ b = "";
+ this.length = 0;
+ return this; // dojox.string.Builder
+ };
+
+ this.replace = function(/* String */oldStr, /* String */ newStr){
+ // summary:
+ // Replace instances of one string with another in the buffer.
+ b = b.replace(oldStr,newStr);
+ this.length = b.length;
+ return this; // dojox.string.Builder
+ };
+
+ this.remove = function(/* Number */start, /* Number? */len){
+ // summary:
+ // Remove len characters starting at index start. If len
+ // is not provided, the end of the string is assumed.
+ if(len===undefined){ len = b.length; }
+ if(len == 0){ return this; }
+ b = b.substr(0, start) + b.substr(start+len);
+ this.length = b.length;
+ return this; // dojox.string.Builder
+ };
+
+ this.insert = function(/* Number */index, /* String */str){
+ // summary:
+ // Insert string str starting at index.
+ if(index == 0){
+ b = str + b;
+ }else{
+ b = b.slice(0, index) + str + b.slice(index);
+ }
+ this.length = b.length;
+ return this; // dojox.string.Builder
+ };
+
+ this.toString = function(){
+ // summary:
+ // Return the string representation of the internal buffer.
+ return b; // String
+ };
+
+ // initialize the buffer.
+ if(str){ this.append(str); }
+};
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/string/README b/js/dojo-1.6/dojox/string/README new file mode 100644 index 0000000..c09d59e --- /dev/null +++ b/js/dojo-1.6/dojox/string/README @@ -0,0 +1,39 @@ +------------------------------------------------------------------------------- +DojoX String Utilities +------------------------------------------------------------------------------- +Version 0.9 +Release date: 05/08/2007 +------------------------------------------------------------------------------- +Project state: +dojox.string.Builder: production +dojox.string.sprintf: beta +dojox.string.tokenize: beta +------------------------------------------------------------------------------- +Project authors + Ben Lowery + Tom Trenka (ttrenka@gmail.com) + Neil Roberts +------------------------------------------------------------------------------- +Project description + +The DojoX String utilties project is a placeholder for miscellaneous string +utility functions. At the time of writing, only the Builder object has been +added; but we anticipate other string utilities may end up living here as well. +------------------------------------------------------------------------------- +Dependencies: + +Dojo Core (package loader). +------------------------------------------------------------------------------- +Documentation + +See the Dojo Toolkit API docs (http://dojotookit.org/api), dojo.string.Builder. +------------------------------------------------------------------------------- +Installation instructions + +Grab the following from the Dojo SVN Repository: +http://svn.dojotoolkit.org/var/src/dojo/dojox/trunk/string/* + +Install into the following directory structure: +/dojox/string/ + +...which should be at the same level as your Dojo checkout. diff --git a/js/dojo-1.6/dojox/string/sprintf.js b/js/dojo-1.6/dojox/string/sprintf.js new file mode 100644 index 0000000..a2838ac --- /dev/null +++ b/js/dojo-1.6/dojox/string/sprintf.js @@ -0,0 +1,413 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+if(!dojo._hasResource["dojox.string.sprintf"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.string.sprintf"] = true;
+dojo.provide("dojox.string.sprintf");
+
+dojo.require("dojox.string.tokenize");
+
+dojox.string.sprintf = function(/*String*/ format, /*mixed...*/ filler){
+ for(var args = [], i = 1; i < arguments.length; i++){
+ args.push(arguments[i]);
+ }
+ var formatter = new dojox.string.sprintf.Formatter(format);
+ return formatter.format.apply(formatter, args);
+}
+
+dojox.string.sprintf.Formatter = function(/*String*/ format){
+ var tokens = [];
+ this._mapped = false;
+ this._format = format;
+ this._tokens = dojox.string.tokenize(format, this._re, this._parseDelim, this);
+}
+dojo.extend(dojox.string.sprintf.Formatter, {
+ _re: /\%(?:\(([\w_]+)\)|([1-9]\d*)\$)?([0 +\-\#]*)(\*|\d+)?(\.)?(\*|\d+)?[hlL]?([\%scdeEfFgGiouxX])/g,
+ _parseDelim: function(mapping, intmapping, flags, minWidth, period, precision, specifier){
+ if(mapping){
+ this._mapped = true;
+ }
+ return {
+ mapping: mapping,
+ intmapping: intmapping,
+ flags: flags,
+ _minWidth: minWidth, // May be dependent on parameters
+ period: period,
+ _precision: precision, // May be dependent on parameters
+ specifier: specifier
+ };
+ },
+ _specifiers: {
+ b: {
+ base: 2,
+ isInt: true
+ },
+ o: {
+ base: 8,
+ isInt: true
+ },
+ x: {
+ base: 16,
+ isInt: true
+ },
+ X: {
+ extend: ["x"],
+ toUpper: true
+ },
+ d: {
+ base: 10,
+ isInt: true
+ },
+ i: {
+ extend: ["d"]
+ },
+ u: {
+ extend: ["d"],
+ isUnsigned: true
+ },
+ c: {
+ setArg: function(token){
+ if(!isNaN(token.arg)){
+ var num = parseInt(token.arg);
+ if(num < 0 || num > 127){
+ throw new Error("invalid character code passed to %c in sprintf");
+ }
+ token.arg = isNaN(num) ? "" + num : String.fromCharCode(num);
+ }
+ }
+ },
+ s: {
+ setMaxWidth: function(token){
+ token.maxWidth = (token.period == ".") ? token.precision : -1;
+ }
+ },
+ e: {
+ isDouble: true,
+ doubleNotation: "e"
+ },
+ E: {
+ extend: ["e"],
+ toUpper: true
+ },
+ f: {
+ isDouble: true,
+ doubleNotation: "f"
+ },
+ F: {
+ extend: ["f"]
+ },
+ g: {
+ isDouble: true,
+ doubleNotation: "g"
+ },
+ G: {
+ extend: ["g"],
+ toUpper: true
+ }
+ },
+ format: function(/*mixed...*/ filler){
+ if(this._mapped && typeof filler != "object"){
+ throw new Error("format requires a mapping");
+ }
+
+ var str = "";
+ var position = 0;
+ for(var i = 0, token; i < this._tokens.length; i++){
+ token = this._tokens[i];
+ if(typeof token == "string"){
+ str += token;
+ }else{
+ if(this._mapped){
+ if(typeof filler[token.mapping] == "undefined"){
+ throw new Error("missing key " + token.mapping);
+ }
+ token.arg = filler[token.mapping];
+ }else{
+ if(token.intmapping){
+ var position = parseInt(token.intmapping) - 1;
+ }
+ if(position >= arguments.length){
+ throw new Error("got " + arguments.length + " printf arguments, insufficient for '" + this._format + "'");
+ }
+ token.arg = arguments[position++];
+ }
+
+ if(!token.compiled){
+ token.compiled = true;
+ token.sign = "";
+ token.zeroPad = false;
+ token.rightJustify = false;
+ token.alternative = false;
+
+ var flags = {};
+ for(var fi = token.flags.length; fi--;){
+ var flag = token.flags.charAt(fi);
+ flags[flag] = true;
+ switch(flag){
+ case " ":
+ token.sign = " ";
+ break;
+ case "+":
+ token.sign = "+";
+ break;
+ case "0":
+ token.zeroPad = (flags["-"]) ? false : true;
+ break;
+ case "-":
+ token.rightJustify = true;
+ token.zeroPad = false;
+ break;
+ case "\#":
+ token.alternative = true;
+ break;
+ default:
+ throw Error("bad formatting flag '" + token.flags.charAt(fi) + "'");
+ }
+ }
+
+ token.minWidth = (token._minWidth) ? parseInt(token._minWidth) : 0;
+ token.maxWidth = -1;
+ token.toUpper = false;
+ token.isUnsigned = false;
+ token.isInt = false;
+ token.isDouble = false;
+ token.precision = 1;
+ if(token.period == '.'){
+ if(token._precision){
+ token.precision = parseInt(token._precision);
+ }else{
+ token.precision = 0;
+ }
+ }
+
+ var mixins = this._specifiers[token.specifier];
+ if(typeof mixins == "undefined"){
+ throw new Error("unexpected specifier '" + token.specifier + "'");
+ }
+ if(mixins.extend){
+ dojo.mixin(mixins, this._specifiers[mixins.extend]);
+ delete mixins.extend;
+ }
+ dojo.mixin(token, mixins);
+ }
+
+ if(typeof token.setArg == "function"){
+ token.setArg(token);
+ }
+
+ if(typeof token.setMaxWidth == "function"){
+ token.setMaxWidth(token);
+ }
+
+ if(token._minWidth == "*"){
+ if(this._mapped){
+ throw new Error("* width not supported in mapped formats");
+ }
+ token.minWidth = parseInt(arguments[position++]);
+ if(isNaN(token.minWidth)){
+ throw new Error("the argument for * width at position " + position + " is not a number in " + this._format);
+ }
+ // negative width means rightJustify
+ if (token.minWidth < 0) {
+ token.rightJustify = true;
+ token.minWidth = -token.minWidth;
+ }
+ }
+
+ if(token._precision == "*" && token.period == "."){
+ if(this._mapped){
+ throw new Error("* precision not supported in mapped formats");
+ }
+ token.precision = parseInt(arguments[position++]);
+ if(isNaN(token.precision)){
+ throw Error("the argument for * precision at position " + position + " is not a number in " + this._format);
+ }
+ // negative precision means unspecified
+ if (token.precision < 0) {
+ token.precision = 1;
+ token.period = '';
+ }
+ }
+
+ if(token.isInt){
+ // a specified precision means no zero padding
+ if(token.period == '.'){
+ token.zeroPad = false;
+ }
+ this.formatInt(token);
+ }else if(token.isDouble){
+ if(token.period != '.'){
+ token.precision = 6;
+ }
+ this.formatDouble(token);
+ }
+ this.fitField(token);
+
+ str += "" + token.arg;
+ }
+ }
+
+ return str;
+ },
+ _zeros10: '0000000000',
+ _spaces10: ' ',
+ formatInt: function(token) {
+ var i = parseInt(token.arg);
+ if(!isFinite(i)){ // isNaN(f) || f == Number.POSITIVE_INFINITY || f == Number.NEGATIVE_INFINITY)
+ // allow this only if arg is number
+ if(typeof token.arg != "number"){
+ throw new Error("format argument '" + token.arg + "' not an integer; parseInt returned " + i);
+ }
+ //return '' + i;
+ i = 0;
+ }
+
+ // if not base 10, make negatives be positive
+ // otherwise, (-10).toString(16) is '-a' instead of 'fffffff6'
+ if(i < 0 && (token.isUnsigned || token.base != 10)){
+ i = 0xffffffff + i + 1;
+ }
+
+ if(i < 0){
+ token.arg = (- i).toString(token.base);
+ this.zeroPad(token);
+ token.arg = "-" + token.arg;
+ }else{
+ token.arg = i.toString(token.base);
+ // need to make sure that argument 0 with precision==0 is formatted as ''
+ if(!i && !token.precision){
+ token.arg = "";
+ }else{
+ this.zeroPad(token);
+ }
+ if(token.sign){
+ token.arg = token.sign + token.arg;
+ }
+ }
+ if(token.base == 16){
+ if(token.alternative){
+ token.arg = '0x' + token.arg;
+ }
+ token.arg = token.toUpper ? token.arg.toUpperCase() : token.arg.toLowerCase();
+ }
+ if(token.base == 8){
+ if(token.alternative && token.arg.charAt(0) != '0'){
+ token.arg = '0' + token.arg;
+ }
+ }
+ },
+ formatDouble: function(token) {
+ var f = parseFloat(token.arg);
+ if(!isFinite(f)){ // isNaN(f) || f == Number.POSITIVE_INFINITY || f == Number.NEGATIVE_INFINITY)
+ // allow this only if arg is number
+ if(typeof token.arg != "number"){
+ throw new Error("format argument '" + token.arg + "' not a float; parseFloat returned " + f);
+ }
+ // C99 says that for 'f':
+ // infinity -> '[-]inf' or '[-]infinity' ('[-]INF' or '[-]INFINITY' for 'F')
+ // NaN -> a string starting with 'nan' ('NAN' for 'F')
+ // this is not commonly implemented though.
+ //return '' + f;
+ f = 0;
+ }
+
+ switch(token.doubleNotation) {
+ case 'e': {
+ token.arg = f.toExponential(token.precision);
+ break;
+ }
+ case 'f': {
+ token.arg = f.toFixed(token.precision);
+ break;
+ }
+ case 'g': {
+ // C says use 'e' notation if exponent is < -4 or is >= prec
+ // ECMAScript for toPrecision says use exponential notation if exponent is >= prec,
+ // though step 17 of toPrecision indicates a test for < -6 to force exponential.
+ if(Math.abs(f) < 0.0001){
+ //print("forcing exponential notation for f=" + f);
+ token.arg = f.toExponential(token.precision > 0 ? token.precision - 1 : token.precision);
+ }else{
+ token.arg = f.toPrecision(token.precision);
+ }
+
+ // In C, unlike 'f', 'gG' removes trailing 0s from fractional part, unless alternative format flag ("#").
+ // But ECMAScript formats toPrecision as 0.00100000. So remove trailing 0s.
+ if(!token.alternative){
+ //print("replacing trailing 0 in '" + s + "'");
+ token.arg = token.arg.replace(/(\..*[^0])0*/, "$1");
+ // if fractional part is entirely 0, remove it and decimal point
+ token.arg = token.arg.replace(/\.0*e/, 'e').replace(/\.0$/,'');
+ }
+ break;
+ }
+ default: throw new Error("unexpected double notation '" + token.doubleNotation + "'");
+ }
+
+ // C says that exponent must have at least two digits.
+ // But ECMAScript does not; toExponential results in things like "1.000000e-8" and "1.000000e+8".
+ // Note that s.replace(/e([\+\-])(\d)/, "e$10$2") won't work because of the "$10" instead of "$1".
+ // And replace(re, func) isn't supported on IE50 or Safari1.
+ token.arg = token.arg.replace(/e\+(\d)$/, "e+0$1").replace(/e\-(\d)$/, "e-0$1");
+
+ // Ensure a '0' before the period.
+ // Opera implements (0.001).toString() as '0.001', but (0.001).toFixed(1) is '.001'
+ if(dojo.isOpera){
+ token.arg = token.arg.replace(/^\./, '0.');
+ }
+
+ // if alt, ensure a decimal point
+ if(token.alternative){
+ token.arg = token.arg.replace(/^(\d+)$/,"$1.");
+ token.arg = token.arg.replace(/^(\d+)e/,"$1.e");
+ }
+
+ if(f >= 0 && token.sign){
+ token.arg = token.sign + token.arg;
+ }
+
+ token.arg = token.toUpper ? token.arg.toUpperCase() : token.arg.toLowerCase();
+ },
+ zeroPad: function(token, /*Int*/ length) {
+ length = (arguments.length == 2) ? length : token.precision;
+ if(typeof token.arg != "string"){
+ token.arg = "" + token.arg;
+ }
+
+ var tenless = length - 10;
+ while(token.arg.length < tenless){
+ token.arg = (token.rightJustify) ? token.arg + this._zeros10 : this._zeros10 + token.arg;
+ }
+ var pad = length - token.arg.length;
+ token.arg = (token.rightJustify) ? token.arg + this._zeros10.substring(0, pad) : this._zeros10.substring(0, pad) + token.arg;
+ },
+ fitField: function(token) {
+ if(token.maxWidth >= 0 && token.arg.length > token.maxWidth){
+ return token.arg.substring(0, token.maxWidth);
+ }
+ if(token.zeroPad){
+ this.zeroPad(token, token.minWidth);
+ return;
+ }
+ this.spacePad(token);
+ },
+ spacePad: function(token, /*Int*/ length) {
+ length = (arguments.length == 2) ? length : token.minWidth;
+ if(typeof token.arg != 'string'){
+ token.arg = '' + token.arg;
+ }
+
+ var tenless = length - 10;
+ while(token.arg.length < tenless){
+ token.arg = (token.rightJustify) ? token.arg + this._spaces10 : this._spaces10 + token.arg;
+ }
+ var pad = length - token.arg.length;
+ token.arg = (token.rightJustify) ? token.arg + this._spaces10.substring(0, pad) : this._spaces10.substring(0, pad) + token.arg;
+ }
+});
+
+}
diff --git a/js/dojo-1.6/dojox/string/sprintf.xd.js b/js/dojo-1.6/dojox/string/sprintf.xd.js new file mode 100644 index 0000000..91168ae --- /dev/null +++ b/js/dojo-1.6/dojox/string/sprintf.xd.js @@ -0,0 +1,418 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+dojo._xdResourceLoaded(function(dojo, dijit, dojox){
+return {depends: [["provide", "dojox.string.sprintf"],
+["require", "dojox.string.tokenize"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.string.sprintf"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.string.sprintf"] = true;
+dojo.provide("dojox.string.sprintf");
+
+dojo.require("dojox.string.tokenize");
+
+dojox.string.sprintf = function(/*String*/ format, /*mixed...*/ filler){
+ for(var args = [], i = 1; i < arguments.length; i++){
+ args.push(arguments[i]);
+ }
+ var formatter = new dojox.string.sprintf.Formatter(format);
+ return formatter.format.apply(formatter, args);
+}
+
+dojox.string.sprintf.Formatter = function(/*String*/ format){
+ var tokens = [];
+ this._mapped = false;
+ this._format = format;
+ this._tokens = dojox.string.tokenize(format, this._re, this._parseDelim, this);
+}
+dojo.extend(dojox.string.sprintf.Formatter, {
+ _re: /\%(?:\(([\w_]+)\)|([1-9]\d*)\$)?([0 +\-\#]*)(\*|\d+)?(\.)?(\*|\d+)?[hlL]?([\%scdeEfFgGiouxX])/g,
+ _parseDelim: function(mapping, intmapping, flags, minWidth, period, precision, specifier){
+ if(mapping){
+ this._mapped = true;
+ }
+ return {
+ mapping: mapping,
+ intmapping: intmapping,
+ flags: flags,
+ _minWidth: minWidth, // May be dependent on parameters
+ period: period,
+ _precision: precision, // May be dependent on parameters
+ specifier: specifier
+ };
+ },
+ _specifiers: {
+ b: {
+ base: 2,
+ isInt: true
+ },
+ o: {
+ base: 8,
+ isInt: true
+ },
+ x: {
+ base: 16,
+ isInt: true
+ },
+ X: {
+ extend: ["x"],
+ toUpper: true
+ },
+ d: {
+ base: 10,
+ isInt: true
+ },
+ i: {
+ extend: ["d"]
+ },
+ u: {
+ extend: ["d"],
+ isUnsigned: true
+ },
+ c: {
+ setArg: function(token){
+ if(!isNaN(token.arg)){
+ var num = parseInt(token.arg);
+ if(num < 0 || num > 127){
+ throw new Error("invalid character code passed to %c in sprintf");
+ }
+ token.arg = isNaN(num) ? "" + num : String.fromCharCode(num);
+ }
+ }
+ },
+ s: {
+ setMaxWidth: function(token){
+ token.maxWidth = (token.period == ".") ? token.precision : -1;
+ }
+ },
+ e: {
+ isDouble: true,
+ doubleNotation: "e"
+ },
+ E: {
+ extend: ["e"],
+ toUpper: true
+ },
+ f: {
+ isDouble: true,
+ doubleNotation: "f"
+ },
+ F: {
+ extend: ["f"]
+ },
+ g: {
+ isDouble: true,
+ doubleNotation: "g"
+ },
+ G: {
+ extend: ["g"],
+ toUpper: true
+ }
+ },
+ format: function(/*mixed...*/ filler){
+ if(this._mapped && typeof filler != "object"){
+ throw new Error("format requires a mapping");
+ }
+
+ var str = "";
+ var position = 0;
+ for(var i = 0, token; i < this._tokens.length; i++){
+ token = this._tokens[i];
+ if(typeof token == "string"){
+ str += token;
+ }else{
+ if(this._mapped){
+ if(typeof filler[token.mapping] == "undefined"){
+ throw new Error("missing key " + token.mapping);
+ }
+ token.arg = filler[token.mapping];
+ }else{
+ if(token.intmapping){
+ var position = parseInt(token.intmapping) - 1;
+ }
+ if(position >= arguments.length){
+ throw new Error("got " + arguments.length + " printf arguments, insufficient for '" + this._format + "'");
+ }
+ token.arg = arguments[position++];
+ }
+
+ if(!token.compiled){
+ token.compiled = true;
+ token.sign = "";
+ token.zeroPad = false;
+ token.rightJustify = false;
+ token.alternative = false;
+
+ var flags = {};
+ for(var fi = token.flags.length; fi--;){
+ var flag = token.flags.charAt(fi);
+ flags[flag] = true;
+ switch(flag){
+ case " ":
+ token.sign = " ";
+ break;
+ case "+":
+ token.sign = "+";
+ break;
+ case "0":
+ token.zeroPad = (flags["-"]) ? false : true;
+ break;
+ case "-":
+ token.rightJustify = true;
+ token.zeroPad = false;
+ break;
+ case "\#":
+ token.alternative = true;
+ break;
+ default:
+ throw Error("bad formatting flag '" + token.flags.charAt(fi) + "'");
+ }
+ }
+
+ token.minWidth = (token._minWidth) ? parseInt(token._minWidth) : 0;
+ token.maxWidth = -1;
+ token.toUpper = false;
+ token.isUnsigned = false;
+ token.isInt = false;
+ token.isDouble = false;
+ token.precision = 1;
+ if(token.period == '.'){
+ if(token._precision){
+ token.precision = parseInt(token._precision);
+ }else{
+ token.precision = 0;
+ }
+ }
+
+ var mixins = this._specifiers[token.specifier];
+ if(typeof mixins == "undefined"){
+ throw new Error("unexpected specifier '" + token.specifier + "'");
+ }
+ if(mixins.extend){
+ dojo.mixin(mixins, this._specifiers[mixins.extend]);
+ delete mixins.extend;
+ }
+ dojo.mixin(token, mixins);
+ }
+
+ if(typeof token.setArg == "function"){
+ token.setArg(token);
+ }
+
+ if(typeof token.setMaxWidth == "function"){
+ token.setMaxWidth(token);
+ }
+
+ if(token._minWidth == "*"){
+ if(this._mapped){
+ throw new Error("* width not supported in mapped formats");
+ }
+ token.minWidth = parseInt(arguments[position++]);
+ if(isNaN(token.minWidth)){
+ throw new Error("the argument for * width at position " + position + " is not a number in " + this._format);
+ }
+ // negative width means rightJustify
+ if (token.minWidth < 0) {
+ token.rightJustify = true;
+ token.minWidth = -token.minWidth;
+ }
+ }
+
+ if(token._precision == "*" && token.period == "."){
+ if(this._mapped){
+ throw new Error("* precision not supported in mapped formats");
+ }
+ token.precision = parseInt(arguments[position++]);
+ if(isNaN(token.precision)){
+ throw Error("the argument for * precision at position " + position + " is not a number in " + this._format);
+ }
+ // negative precision means unspecified
+ if (token.precision < 0) {
+ token.precision = 1;
+ token.period = '';
+ }
+ }
+
+ if(token.isInt){
+ // a specified precision means no zero padding
+ if(token.period == '.'){
+ token.zeroPad = false;
+ }
+ this.formatInt(token);
+ }else if(token.isDouble){
+ if(token.period != '.'){
+ token.precision = 6;
+ }
+ this.formatDouble(token);
+ }
+ this.fitField(token);
+
+ str += "" + token.arg;
+ }
+ }
+
+ return str;
+ },
+ _zeros10: '0000000000',
+ _spaces10: ' ',
+ formatInt: function(token) {
+ var i = parseInt(token.arg);
+ if(!isFinite(i)){ // isNaN(f) || f == Number.POSITIVE_INFINITY || f == Number.NEGATIVE_INFINITY)
+ // allow this only if arg is number
+ if(typeof token.arg != "number"){
+ throw new Error("format argument '" + token.arg + "' not an integer; parseInt returned " + i);
+ }
+ //return '' + i;
+ i = 0;
+ }
+
+ // if not base 10, make negatives be positive
+ // otherwise, (-10).toString(16) is '-a' instead of 'fffffff6'
+ if(i < 0 && (token.isUnsigned || token.base != 10)){
+ i = 0xffffffff + i + 1;
+ }
+
+ if(i < 0){
+ token.arg = (- i).toString(token.base);
+ this.zeroPad(token);
+ token.arg = "-" + token.arg;
+ }else{
+ token.arg = i.toString(token.base);
+ // need to make sure that argument 0 with precision==0 is formatted as ''
+ if(!i && !token.precision){
+ token.arg = "";
+ }else{
+ this.zeroPad(token);
+ }
+ if(token.sign){
+ token.arg = token.sign + token.arg;
+ }
+ }
+ if(token.base == 16){
+ if(token.alternative){
+ token.arg = '0x' + token.arg;
+ }
+ token.arg = token.toUpper ? token.arg.toUpperCase() : token.arg.toLowerCase();
+ }
+ if(token.base == 8){
+ if(token.alternative && token.arg.charAt(0) != '0'){
+ token.arg = '0' + token.arg;
+ }
+ }
+ },
+ formatDouble: function(token) {
+ var f = parseFloat(token.arg);
+ if(!isFinite(f)){ // isNaN(f) || f == Number.POSITIVE_INFINITY || f == Number.NEGATIVE_INFINITY)
+ // allow this only if arg is number
+ if(typeof token.arg != "number"){
+ throw new Error("format argument '" + token.arg + "' not a float; parseFloat returned " + f);
+ }
+ // C99 says that for 'f':
+ // infinity -> '[-]inf' or '[-]infinity' ('[-]INF' or '[-]INFINITY' for 'F')
+ // NaN -> a string starting with 'nan' ('NAN' for 'F')
+ // this is not commonly implemented though.
+ //return '' + f;
+ f = 0;
+ }
+
+ switch(token.doubleNotation) {
+ case 'e': {
+ token.arg = f.toExponential(token.precision);
+ break;
+ }
+ case 'f': {
+ token.arg = f.toFixed(token.precision);
+ break;
+ }
+ case 'g': {
+ // C says use 'e' notation if exponent is < -4 or is >= prec
+ // ECMAScript for toPrecision says use exponential notation if exponent is >= prec,
+ // though step 17 of toPrecision indicates a test for < -6 to force exponential.
+ if(Math.abs(f) < 0.0001){
+ //print("forcing exponential notation for f=" + f);
+ token.arg = f.toExponential(token.precision > 0 ? token.precision - 1 : token.precision);
+ }else{
+ token.arg = f.toPrecision(token.precision);
+ }
+
+ // In C, unlike 'f', 'gG' removes trailing 0s from fractional part, unless alternative format flag ("#").
+ // But ECMAScript formats toPrecision as 0.00100000. So remove trailing 0s.
+ if(!token.alternative){
+ //print("replacing trailing 0 in '" + s + "'");
+ token.arg = token.arg.replace(/(\..*[^0])0*/, "$1");
+ // if fractional part is entirely 0, remove it and decimal point
+ token.arg = token.arg.replace(/\.0*e/, 'e').replace(/\.0$/,'');
+ }
+ break;
+ }
+ default: throw new Error("unexpected double notation '" + token.doubleNotation + "'");
+ }
+
+ // C says that exponent must have at least two digits.
+ // But ECMAScript does not; toExponential results in things like "1.000000e-8" and "1.000000e+8".
+ // Note that s.replace(/e([\+\-])(\d)/, "e$10$2") won't work because of the "$10" instead of "$1".
+ // And replace(re, func) isn't supported on IE50 or Safari1.
+ token.arg = token.arg.replace(/e\+(\d)$/, "e+0$1").replace(/e\-(\d)$/, "e-0$1");
+
+ // Ensure a '0' before the period.
+ // Opera implements (0.001).toString() as '0.001', but (0.001).toFixed(1) is '.001'
+ if(dojo.isOpera){
+ token.arg = token.arg.replace(/^\./, '0.');
+ }
+
+ // if alt, ensure a decimal point
+ if(token.alternative){
+ token.arg = token.arg.replace(/^(\d+)$/,"$1.");
+ token.arg = token.arg.replace(/^(\d+)e/,"$1.e");
+ }
+
+ if(f >= 0 && token.sign){
+ token.arg = token.sign + token.arg;
+ }
+
+ token.arg = token.toUpper ? token.arg.toUpperCase() : token.arg.toLowerCase();
+ },
+ zeroPad: function(token, /*Int*/ length) {
+ length = (arguments.length == 2) ? length : token.precision;
+ if(typeof token.arg != "string"){
+ token.arg = "" + token.arg;
+ }
+
+ var tenless = length - 10;
+ while(token.arg.length < tenless){
+ token.arg = (token.rightJustify) ? token.arg + this._zeros10 : this._zeros10 + token.arg;
+ }
+ var pad = length - token.arg.length;
+ token.arg = (token.rightJustify) ? token.arg + this._zeros10.substring(0, pad) : this._zeros10.substring(0, pad) + token.arg;
+ },
+ fitField: function(token) {
+ if(token.maxWidth >= 0 && token.arg.length > token.maxWidth){
+ return token.arg.substring(0, token.maxWidth);
+ }
+ if(token.zeroPad){
+ this.zeroPad(token, token.minWidth);
+ return;
+ }
+ this.spacePad(token);
+ },
+ spacePad: function(token, /*Int*/ length) {
+ length = (arguments.length == 2) ? length : token.minWidth;
+ if(typeof token.arg != 'string'){
+ token.arg = '' + token.arg;
+ }
+
+ var tenless = length - 10;
+ while(token.arg.length < tenless){
+ token.arg = (token.rightJustify) ? token.arg + this._spaces10 : this._spaces10 + token.arg;
+ }
+ var pad = length - token.arg.length;
+ token.arg = (token.rightJustify) ? token.arg + this._spaces10.substring(0, pad) : this._spaces10.substring(0, pad) + token.arg;
+ }
+});
+
+}
+
+}};});
diff --git a/js/dojo-1.6/dojox/string/tokenize.js b/js/dojo-1.6/dojox/string/tokenize.js new file mode 100644 index 0000000..cd6da65 --- /dev/null +++ b/js/dojo-1.6/dojox/string/tokenize.js @@ -0,0 +1,49 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+if(!dojo._hasResource["dojox.string.tokenize"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.string.tokenize"] = true;
+dojo.provide("dojox.string.tokenize");
+
+dojox.string.tokenize = function(/*String*/ str, /*RegExp*/ re, /*Function?*/ parseDelim, /*Object?*/ instance){
+ // summary:
+ // Split a string by a regular expression with the ability to capture the delimeters
+ // parseDelim:
+ // Each group (excluding the 0 group) is passed as a parameter. If the function returns
+ // a value, it's added to the list of tokens.
+ // instance:
+ // Used as the "this" instance when calling parseDelim
+ var tokens = [];
+ var match, content, lastIndex = 0;
+ while(match = re.exec(str)){
+ content = str.slice(lastIndex, re.lastIndex - match[0].length);
+ if(content.length){
+ tokens.push(content);
+ }
+ if(parseDelim){
+ if(dojo.isOpera){
+ var copy = match.slice(0);
+ while(copy.length < match.length){
+ copy.push(null);
+ }
+ match = copy;
+ }
+ var parsed = parseDelim.apply(instance, match.slice(1).concat(tokens.length));
+ if(typeof parsed != "undefined"){
+ tokens.push(parsed);
+ }
+ }
+ lastIndex = re.lastIndex;
+ }
+ content = str.slice(lastIndex);
+ if(content.length){
+ tokens.push(content);
+ }
+ return tokens;
+}
+
+}
diff --git a/js/dojo-1.6/dojox/string/tokenize.xd.js b/js/dojo-1.6/dojox/string/tokenize.xd.js new file mode 100644 index 0000000..1237511 --- /dev/null +++ b/js/dojo-1.6/dojox/string/tokenize.xd.js @@ -0,0 +1,53 @@ +/*
+ Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
+ Available via Academic Free License >= 2.1 OR the modified BSD license.
+ see: http://dojotoolkit.org/license for details
+*/
+
+
+dojo._xdResourceLoaded(function(dojo, dijit, dojox){
+return {depends: [["provide", "dojox.string.tokenize"]],
+defineResource: function(dojo, dijit, dojox){if(!dojo._hasResource["dojox.string.tokenize"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
+dojo._hasResource["dojox.string.tokenize"] = true;
+dojo.provide("dojox.string.tokenize");
+
+dojox.string.tokenize = function(/*String*/ str, /*RegExp*/ re, /*Function?*/ parseDelim, /*Object?*/ instance){
+ // summary:
+ // Split a string by a regular expression with the ability to capture the delimeters
+ // parseDelim:
+ // Each group (excluding the 0 group) is passed as a parameter. If the function returns
+ // a value, it's added to the list of tokens.
+ // instance:
+ // Used as the "this" instance when calling parseDelim
+ var tokens = [];
+ var match, content, lastIndex = 0;
+ while(match = re.exec(str)){
+ content = str.slice(lastIndex, re.lastIndex - match[0].length);
+ if(content.length){
+ tokens.push(content);
+ }
+ if(parseDelim){
+ if(dojo.isOpera){
+ var copy = match.slice(0);
+ while(copy.length < match.length){
+ copy.push(null);
+ }
+ match = copy;
+ }
+ var parsed = parseDelim.apply(instance, match.slice(1).concat(tokens.length));
+ if(typeof parsed != "undefined"){
+ tokens.push(parsed);
+ }
+ }
+ lastIndex = re.lastIndex;
+ }
+ content = str.slice(lastIndex);
+ if(content.length){
+ tokens.push(content);
+ }
+ return tokens;
+}
+
+}
+
+}};});
|
