author | Dan |
Thu, 03 Jul 2008 15:37:18 -0400 | |
changeset 596 | 82320949a3b5 |
parent 581 | 5e8fd89c02ea |
permissions | -rw-r--r-- |
581
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1 |
// SpryData.js - version 0.45 - Spry Pre-Release 1.6.1 |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
2 |
// |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
3 |
// Copyright (c) 2007. Adobe Systems Incorporated. |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
4 |
// All rights reserved. |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
5 |
// |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
6 |
// Redistribution and use in source and binary forms, with or without |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
7 |
// modification, are permitted provided that the following conditions are met: |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
8 |
// |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
9 |
// * Redistributions of source code must retain the above copyright notice, |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
10 |
// this list of conditions and the following disclaimer. |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
11 |
// * Redistributions in binary form must reproduce the above copyright notice, |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
12 |
// this list of conditions and the following disclaimer in the documentation |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
13 |
// and/or other materials provided with the distribution. |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
14 |
// * Neither the name of Adobe Systems Incorporated nor the names of its |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
15 |
// contributors may be used to endorse or promote products derived from this |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
16 |
// software without specific prior written permission. |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
17 |
// |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
18 |
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
19 |
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
20 |
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
21 |
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
22 |
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
23 |
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
24 |
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
25 |
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
26 |
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
27 |
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
28 |
// POSSIBILITY OF SUCH DAMAGE. |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
29 |
|
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
30 |
var Spry;if(!Spry)Spry={};if(!Spry.Utils)Spry.Utils={};Spry.Utils.msProgIDs=["MSXML2.XMLHTTP.6.0","MSXML2.XMLHTTP.3.0"];Spry.Utils.createXMLHttpRequest=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
31 |
{var req=null;try |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
32 |
{if(window.ActiveXObject) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
33 |
{while(!req&&Spry.Utils.msProgIDs.length) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
34 |
{try{req=new ActiveXObject(Spry.Utils.msProgIDs[0]);}catch(e){req=null;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
35 |
if(!req) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
36 |
Spry.Utils.msProgIDs.splice(0,1);}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
37 |
if(!req&&window.XMLHttpRequest) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
38 |
req=new XMLHttpRequest();} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
39 |
catch(e){req=null;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
40 |
if(!req) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
41 |
Spry.Debug.reportError("Failed to create an XMLHttpRequest object!");return req;};Spry.Utils.loadURL=function(method,url,async,callback,opts) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
42 |
{var req=new Spry.Utils.loadURL.Request();req.method=method;req.url=url;req.async=async;req.successCallback=callback;Spry.Utils.setOptions(req,opts);try |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
43 |
{req.xhRequest=Spry.Utils.createXMLHttpRequest();if(!req.xhRequest) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
44 |
return null;if(req.async) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
45 |
req.xhRequest.onreadystatechange=function(){Spry.Utils.loadURL.callback(req);};req.xhRequest.open(req.method,req.url,req.async,req.username,req.password);if(req.headers) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
46 |
{for(var name in req.headers) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
47 |
req.xhRequest.setRequestHeader(name,req.headers[name]);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
48 |
req.xhRequest.send(req.postData);if(!req.async) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
49 |
Spry.Utils.loadURL.callback(req);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
50 |
catch(e) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
51 |
{if(req.errorCallback) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
52 |
req.errorCallback(req);else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
53 |
Spry.Debug.reportError("Exception caught while loading "+url+": "+e);req=null;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
54 |
return req;};Spry.Utils.loadURL.callback=function(req) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
55 |
{if(!req||req.xhRequest.readyState!=4) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
56 |
return;if(req.successCallback&&(req.xhRequest.status==200||req.xhRequest.status==0)) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
57 |
req.successCallback(req);else if(req.errorCallback) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
58 |
req.errorCallback(req);};Spry.Utils.loadURL.Request=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
59 |
{var props=Spry.Utils.loadURL.Request.props;var numProps=props.length;for(var i=0;i<numProps;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
60 |
this[props[i]]=null;this.method="GET";this.async=true;this.headers={};};Spry.Utils.loadURL.Request.props=["method","url","async","username","password","postData","successCallback","errorCallback","headers","userData","xhRequest"];Spry.Utils.loadURL.Request.prototype.extractRequestOptions=function(opts,undefineRequestProps) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
61 |
{if(!opts) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
62 |
return;var props=Spry.Utils.loadURL.Request.props;var numProps=props.length;for(var i=0;i<numProps;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
63 |
{var prop=props[i];if(opts[prop]!=undefined) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
64 |
{this[prop]=opts[prop];if(undefineRequestProps) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
65 |
opts[prop]=undefined;}}};Spry.Utils.loadURL.Request.prototype.clone=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
66 |
{var props=Spry.Utils.loadURL.Request.props;var numProps=props.length;var req=new Spry.Utils.loadURL.Request;for(var i=0;i<numProps;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
67 |
req[props[i]]=this[props[i]];if(this.headers) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
68 |
{req.headers={};Spry.Utils.setOptions(req.headers,this.headers);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
69 |
return req;};Spry.Utils.setInnerHTML=function(ele,str,preventScripts) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
70 |
{if(!ele) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
71 |
return;ele=Spry.$(ele);var scriptExpr="<script[^>]*>(.|\s|\n|\r)*?</script>";ele.innerHTML=str.replace(new RegExp(scriptExpr,"img"),"");if(preventScripts) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
72 |
return;var matches=str.match(new RegExp(scriptExpr,"img"));if(matches) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
73 |
{var numMatches=matches.length;for(var i=0;i<numMatches;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
74 |
{var s=matches[i].replace(/<script[^>]*>[\s\r\n]*(<\!--)?|(-->)?[\s\r\n]*<\/script>/img,"");Spry.Utils.eval(s);}}};Spry.Utils.updateContent=function(ele,url,finishFunc,opts) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
75 |
{Spry.Utils.loadURL("GET",url,true,function(req) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
76 |
{Spry.Utils.setInnerHTML(ele,req.xhRequest.responseText);if(finishFunc) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
77 |
finishFunc(ele,url);},opts);};if(!Spry.$$) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
78 |
{Spry.Utils.addEventListener=function(element,eventType,handler,capture) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
79 |
{try |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
80 |
{element=Spry.$(element);if(element.addEventListener) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
81 |
element.addEventListener(eventType,handler,capture);else if(element.attachEvent) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
82 |
element.attachEvent("on"+eventType,handler);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
83 |
catch(e){}};Spry.Utils.removeEventListener=function(element,eventType,handler,capture) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
84 |
{try |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
85 |
{element=Spry.$(element);if(element.removeEventListener) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
86 |
element.removeEventListener(eventType,handler,capture);else if(element.detachEvent) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
87 |
element.detachEvent("on"+eventType,handler);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
88 |
catch(e){}};Spry.Utils.addLoadListener=function(handler) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
89 |
{if(typeof window.addEventListener!='undefined') |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
90 |
window.addEventListener('load',handler,false);else if(typeof document.addEventListener!='undefined') |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
91 |
document.addEventListener('load',handler,false);else if(typeof window.attachEvent!='undefined') |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
92 |
window.attachEvent('onload',handler);};Spry.Utils.addClassName=function(ele,className) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
93 |
{ele=Spry.$(ele);if(!ele||!className||(ele.className&&ele.className.search(new RegExp("\\b"+className+"\\b"))!=-1)) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
94 |
return;ele.className+=(ele.className?" ":"")+className;};Spry.Utils.removeClassName=function(ele,className) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
95 |
{ele=Spry.$(ele);if(!ele||!className||(ele.className&&ele.className.search(new RegExp("\\b"+className+"\\b"))==-1)) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
96 |
return;ele.className=ele.className.replace(new RegExp("\\s*\\b"+className+"\\b","g"),"");};Spry.Utils.getObjectByName=function(name) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
97 |
{var result=null;if(name) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
98 |
{var lu=window;var objPath=name.split(".");for(var i=0;lu&&i<objPath.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
99 |
{result=lu[objPath[i]];lu=result;}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
100 |
return result;};Spry.$=function(element) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
101 |
{if(arguments.length>1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
102 |
{for(var i=0,elements=[],length=arguments.length;i<length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
103 |
elements.push(Spry.$(arguments[i]));return elements;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
104 |
if(typeof element=='string') |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
105 |
element=document.getElementById(element);return element;};} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
106 |
Spry.Utils.eval=function(str) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
107 |
{return eval(str);};Spry.Utils.escapeQuotesAndLineBreaks=function(str) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
108 |
{if(str) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
109 |
{str=str.replace(/\\/g,"\\\\");str=str.replace(/["']/g,"\\$&");str=str.replace(/\n/g,"\\n");str=str.replace(/\r/g,"\\r");} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
110 |
return str;};Spry.Utils.encodeEntities=function(str) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
111 |
{if(str&&str.search(/[&<>"]/)!=-1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
112 |
{str=str.replace(/&/g,"&");str=str.replace(/</g,"<");str=str.replace(/>/g,">");str=str.replace(/"/g,""");} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
113 |
return str};Spry.Utils.decodeEntities=function(str) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
114 |
{var d=Spry.Utils.decodeEntities.div;if(!d) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
115 |
{d=document.createElement('div');Spry.Utils.decodeEntities.div=d;if(!d)return str;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
116 |
d.innerHTML=str;if(d.childNodes.length==1&&d.firstChild.nodeType==3&&d.firstChild.nextSibling==null) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
117 |
str=d.firstChild.data;else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
118 |
{str=str.replace(/</gi,"<");str=str.replace(/>/gi,">");str=str.replace(/"/gi,"\"");str=str.replace(/&/gi,"&");} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
119 |
return str;};Spry.Utils.fixupIETagAttributes=function(inStr) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
120 |
{var outStr="";var tagStart=inStr.match(/^<[^\s>]+\s*/)[0];var tagEnd=inStr.match(/\s*\/?>$/)[0];var tagAttrs=inStr.replace(/^<[^\s>]+\s*|\s*\/?>/g,"");outStr+=tagStart;if(tagAttrs) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
121 |
{var startIndex=0;var endIndex=0;while(startIndex<tagAttrs.length) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
122 |
{while(tagAttrs.charAt(endIndex)!='='&&endIndex<tagAttrs.length) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
123 |
++endIndex;if(endIndex>=tagAttrs.length) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
124 |
{outStr+=tagAttrs.substring(startIndex,endIndex);break;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
125 |
++endIndex;outStr+=tagAttrs.substring(startIndex,endIndex);startIndex=endIndex;if(tagAttrs.charAt(endIndex)=='"'||tagAttrs.charAt(endIndex)=="'") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
126 |
{var savedIndex=endIndex++;while(endIndex<tagAttrs.length) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
127 |
{if(tagAttrs.charAt(endIndex)==tagAttrs.charAt(savedIndex)) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
128 |
{endIndex++;break;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
129 |
else if(tagAttrs.charAt(endIndex)=="\\") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
130 |
endIndex++;endIndex++;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
131 |
outStr+=tagAttrs.substring(startIndex,endIndex);startIndex=endIndex;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
132 |
else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
133 |
{outStr+="\"";var sIndex=tagAttrs.slice(endIndex).search(/\s/);endIndex=(sIndex!=-1)?(endIndex+sIndex):tagAttrs.length;outStr+=tagAttrs.slice(startIndex,endIndex);outStr+="\"";startIndex=endIndex;}}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
134 |
outStr+=tagEnd;return outStr;};Spry.Utils.fixUpIEInnerHTML=function(inStr) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
135 |
{var outStr="";var regexp=new RegExp("<\\!--|<\\!\\[CDATA\\[|<\\w+[^<>]*>|-->|\\]\\](>|\>)","g");var searchStartIndex=0;var skipFixUp=0;while(inStr.length) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
136 |
{var results=regexp.exec(inStr);if(!results||!results[0]) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
137 |
{outStr+=inStr.substr(searchStartIndex,inStr.length-searchStartIndex);break;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
138 |
if(results.index!=searchStartIndex) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
139 |
{outStr+=inStr.substr(searchStartIndex,results.index-searchStartIndex);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
140 |
if(results[0]=="<!--"||results[0]=="<![CDATA[") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
141 |
{++skipFixUp;outStr+=results[0];} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
142 |
else if(results[0]=="-->"||results[0]=="]]>"||(skipFixUp&&results[0]=="]]>")) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
143 |
{--skipFixUp;outStr+=results[0];} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
144 |
else if(!skipFixUp&&results[0].charAt(0)=='<') |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
145 |
outStr+=Spry.Utils.fixupIETagAttributes(results[0]);else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
146 |
outStr+=results[0];searchStartIndex=regexp.lastIndex;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
147 |
return outStr;};Spry.Utils.stringToXMLDoc=function(str) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
148 |
{var xmlDoc=null;try |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
149 |
{var xmlDOMObj=new ActiveXObject("Microsoft.XMLDOM");xmlDOMObj.async=false;xmlDOMObj.loadXML(str);xmlDoc=xmlDOMObj;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
150 |
catch(e) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
151 |
{try |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
152 |
{var domParser=new DOMParser;xmlDoc=domParser.parseFromString(str,'text/xml');} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
153 |
catch(e) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
154 |
{Spry.Debug.reportError("Caught exception in Spry.Utils.stringToXMLDoc(): "+e+"\n");xmlDoc=null;}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
155 |
return xmlDoc;};Spry.Utils.serializeObject=function(obj) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
156 |
{var str="";var firstItem=true;if(obj==null||obj==undefined) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
157 |
return str+obj;var objType=typeof obj;if(objType=="number"||objType=="boolean") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
158 |
str+=obj;else if(objType=="string") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
159 |
str+="\""+Spry.Utils.escapeQuotesAndLineBreaks(obj)+"\"";else if(obj.constructor==Array) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
160 |
{str+="[";for(var i=0;i<obj.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
161 |
{if(!firstItem) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
162 |
str+=", ";str+=Spry.Utils.serializeObject(obj[i]);firstItem=false;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
163 |
str+="]";} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
164 |
else if(objType=="object") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
165 |
{str+="{";for(var p in obj) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
166 |
{if(!firstItem) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
167 |
str+=", ";str+="\""+p+"\": "+Spry.Utils.serializeObject(obj[p]);firstItem=false;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
168 |
str+="}";} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
169 |
return str;};Spry.Utils.getNodesByFunc=function(root,func) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
170 |
{var nodeStack=new Array;var resultArr=new Array;var node=root;while(node) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
171 |
{if(func(node)) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
172 |
resultArr.push(node);if(node.hasChildNodes()) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
173 |
{nodeStack.push(node);node=node.firstChild;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
174 |
else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
175 |
{if(node==root) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
176 |
node=null;else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
177 |
try{node=node.nextSibling;}catch(e){node=null;};} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
178 |
while(!node&&nodeStack.length>0) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
179 |
{node=nodeStack.pop();if(node==root) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
180 |
node=null;else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
181 |
try{node=node.nextSibling;}catch(e){node=null;}}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
182 |
if(nodeStack&&nodeStack.length>0) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
183 |
Spry.Debug.trace("-- WARNING: Spry.Utils.getNodesByFunc() failed to traverse all nodes!\n");return resultArr;};Spry.Utils.getFirstChildWithNodeName=function(node,nodeName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
184 |
{var child=node.firstChild;while(child) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
185 |
{if(child.nodeName==nodeName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
186 |
return child;child=child.nextSibling;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
187 |
return null;};Spry.Utils.setOptions=function(obj,optionsObj,ignoreUndefinedProps) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
188 |
{if(!optionsObj) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
189 |
return;for(var optionName in optionsObj) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
190 |
{if(ignoreUndefinedProps&&optionsObj[optionName]==undefined) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
191 |
continue;obj[optionName]=optionsObj[optionName];}};Spry.Utils.SelectionManager={};Spry.Utils.SelectionManager.selectionGroups=new Object;Spry.Utils.SelectionManager.SelectionGroup=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
192 |
{this.selectedElements=new Array;};Spry.Utils.SelectionManager.SelectionGroup.prototype.select=function(element,className,multiSelect) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
193 |
{var selObj=null;if(!multiSelect) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
194 |
{this.clearSelection();} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
195 |
else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
196 |
{for(var i=0;i<this.selectedElements.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
197 |
{selObj=this.selectedElements[i].element;if(selObj.element==element) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
198 |
{if(selObj.className!=className) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
199 |
{Spry.Utils.removeClassName(element,selObj.className);Spry.Utils.addClassName(element,className);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
200 |
return;}}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
201 |
selObj=new Object;selObj.element=element;selObj.className=className;this.selectedElements.push(selObj);Spry.Utils.addClassName(element,className);};Spry.Utils.SelectionManager.SelectionGroup.prototype.unSelect=function(element) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
202 |
{for(var i=0;i<this.selectedElements.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
203 |
{var selObj=this.selectedElements[i].element;if(selObj.element==element) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
204 |
{Spry.Utils.removeClassName(selObj.element,selObj.className);return;}}};Spry.Utils.SelectionManager.SelectionGroup.prototype.clearSelection=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
205 |
{var selObj=null;do |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
206 |
{selObj=this.selectedElements.shift();if(selObj) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
207 |
Spry.Utils.removeClassName(selObj.element,selObj.className);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
208 |
while(selObj);};Spry.Utils.SelectionManager.getSelectionGroup=function(selectionGroupName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
209 |
{if(!selectionGroupName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
210 |
return null;var groupObj=Spry.Utils.SelectionManager.selectionGroups[selectionGroupName];if(!groupObj) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
211 |
{groupObj=new Spry.Utils.SelectionManager.SelectionGroup();Spry.Utils.SelectionManager.selectionGroups[selectionGroupName]=groupObj;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
212 |
return groupObj;};Spry.Utils.SelectionManager.select=function(selectionGroupName,element,className,multiSelect) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
213 |
{var groupObj=Spry.Utils.SelectionManager.getSelectionGroup(selectionGroupName);if(!groupObj) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
214 |
return;groupObj.select(element,className,multiSelect);};Spry.Utils.SelectionManager.unSelect=function(selectionGroupName,element) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
215 |
{var groupObj=Spry.Utils.SelectionManager.getSelectionGroup(selectionGroupName);if(!groupObj) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
216 |
return;groupObj.unSelect(element,className);};Spry.Utils.SelectionManager.clearSelection=function(selectionGroupName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
217 |
{var groupObj=Spry.Utils.SelectionManager.getSelectionGroup(selectionGroupName);if(!groupObj) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
218 |
return;groupObj.clearSelection();};Spry.Utils.Notifier=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
219 |
{this.observers=[];this.suppressNotifications=0;};Spry.Utils.Notifier.prototype.addObserver=function(observer) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
220 |
{if(!observer) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
221 |
return;var len=this.observers.length;for(var i=0;i<len;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
222 |
{if(this.observers[i]==observer) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
223 |
return;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
224 |
this.observers[len]=observer;};Spry.Utils.Notifier.prototype.removeObserver=function(observer) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
225 |
{if(!observer) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
226 |
return;for(var i=0;i<this.observers.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
227 |
{if(this.observers[i]==observer) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
228 |
{this.observers.splice(i,1);break;}}};Spry.Utils.Notifier.prototype.notifyObservers=function(methodName,data) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
229 |
{if(!methodName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
230 |
return;if(!this.suppressNotifications) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
231 |
{var len=this.observers.length;for(var i=0;i<len;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
232 |
{var obs=this.observers[i];if(obs) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
233 |
{if(typeof obs=="function") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
234 |
obs(methodName,this,data);else if(obs[methodName]) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
235 |
obs[methodName](this,data);}}}};Spry.Utils.Notifier.prototype.enableNotifications=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
236 |
{if(--this.suppressNotifications<0) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
237 |
{this.suppressNotifications=0;Spry.Debug.reportError("Unbalanced enableNotifications() call!\n");}};Spry.Utils.Notifier.prototype.disableNotifications=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
238 |
{++this.suppressNotifications;};Spry.Debug={};Spry.Debug.enableTrace=true;Spry.Debug.debugWindow=null;Spry.Debug.onloadDidFire=false;Spry.Utils.addLoadListener(function(){Spry.Debug.onloadDidFire=true;Spry.Debug.flushQueuedMessages();});Spry.Debug.flushQueuedMessages=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
239 |
{if(Spry.Debug.flushQueuedMessages.msgs) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
240 |
{var msgs=Spry.Debug.flushQueuedMessages.msgs;for(var i=0;i<msgs.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
241 |
Spry.Debug.debugOut(msgs[i].msg,msgs[i].color);Spry.Debug.flushQueuedMessages.msgs=null;}};Spry.Debug.createDebugWindow=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
242 |
{if(!Spry.Debug.enableTrace||Spry.Debug.debugWindow||!Spry.Debug.onloadDidFire) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
243 |
return;try |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
244 |
{Spry.Debug.debugWindow=document.createElement("div");var div=Spry.Debug.debugWindow;div.style.fontSize="12px";div.style.fontFamily="console";div.style.position="absolute";div.style.width="400px";div.style.height="300px";div.style.overflow="auto";div.style.border="solid 1px black";div.style.backgroundColor="white";div.style.color="black";div.style.bottom="0px";div.style.right="0px";div.setAttribute("id","SpryDebugWindow");document.body.appendChild(Spry.Debug.debugWindow);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
245 |
catch(e){}};Spry.Debug.debugOut=function(str,bgColor) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
246 |
{if(!Spry.Debug.debugWindow) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
247 |
{Spry.Debug.createDebugWindow();if(!Spry.Debug.debugWindow) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
248 |
{if(!Spry.Debug.flushQueuedMessages.msgs) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
249 |
Spry.Debug.flushQueuedMessages.msgs=new Array;Spry.Debug.flushQueuedMessages.msgs.push({msg:str,color:bgColor});return;}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
250 |
var d=document.createElement("div");if(bgColor) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
251 |
d.style.backgroundColor=bgColor;d.innerHTML=str;Spry.Debug.debugWindow.appendChild(d);};Spry.Debug.trace=function(str) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
252 |
{Spry.Debug.debugOut(str);};Spry.Debug.reportError=function(str) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
253 |
{Spry.Debug.debugOut(str,"red");};Spry.Data={};Spry.Data.regionsArray={};Spry.Data.initRegionsOnLoad=true;Spry.Data.initRegions=function(rootNode) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
254 |
{rootNode=rootNode?Spry.$(rootNode):document.body;var lastRegionFound=null;var regions=Spry.Utils.getNodesByFunc(rootNode,function(node) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
255 |
{try |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
256 |
{if(node.nodeType!=1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
257 |
return false;var attrName="spry:region";var attr=node.attributes.getNamedItem(attrName);if(!attr) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
258 |
{attrName="spry:detailregion";attr=node.attributes.getNamedItem(attrName);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
259 |
if(attr) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
260 |
{if(lastRegionFound) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
261 |
{var parent=node.parentNode;while(parent) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
262 |
{if(parent==lastRegionFound) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
263 |
{Spry.Debug.reportError("Found a nested "+attrName+" in the following markup. Nested regions are currently not supported.<br/><pre>"+Spry.Utils.encodeEntities(parent.innerHTML)+"</pre>");return false;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
264 |
parent=parent.parentNode;}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
265 |
if(attr.value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
266 |
{attr=node.attributes.getNamedItem("id");if(!attr||!attr.value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
267 |
{node.setAttribute("id","spryregion"+(++Spry.Data.initRegions.nextUniqueRegionID));} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
268 |
lastRegionFound=node;return true;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
269 |
else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
270 |
Spry.Debug.reportError(attrName+" attributes require one or more data set names as values!");}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
271 |
catch(e){} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
272 |
return false;});var name,dataSets,i;var newRegions=[];for(i=0;i<regions.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
273 |
{var rgn=regions[i];var isDetailRegion=false;name=rgn.attributes.getNamedItem("id").value;attr=rgn.attributes.getNamedItem("spry:region");if(!attr) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
274 |
{attr=rgn.attributes.getNamedItem("spry:detailregion");isDetailRegion=true;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
275 |
if(!attr.value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
276 |
{Spry.Debug.reportError("spry:region and spry:detailregion attributes require one or more data set names as values!");continue;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
277 |
rgn.attributes.removeNamedItem(attr.nodeName);Spry.Utils.removeClassName(rgn,Spry.Data.Region.hiddenRegionClassName);dataSets=Spry.Data.Region.strToDataSetsArray(attr.value);if(!dataSets.length) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
278 |
{Spry.Debug.reportError("spry:region or spry:detailregion attribute has no data set!");continue;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
279 |
var hasBehaviorAttributes=false;var hasSpryContent=false;var dataStr="";var parent=null;var regionStates={};var regionStateMap={};attr=rgn.attributes.getNamedItem("spry:readystate");if(attr&&attr.value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
280 |
regionStateMap["ready"]=attr.value;attr=rgn.attributes.getNamedItem("spry:errorstate");if(attr&&attr.value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
281 |
regionStateMap["error"]=attr.value;attr=rgn.attributes.getNamedItem("spry:loadingstate");if(attr&&attr.value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
282 |
regionStateMap["loading"]=attr.value;attr=rgn.attributes.getNamedItem("spry:expiredstate");if(attr&&attr.value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
283 |
regionStateMap["expired"]=attr.value;var piRegions=Spry.Utils.getNodesByFunc(rgn,function(node) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
284 |
{try |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
285 |
{if(node.nodeType==1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
286 |
{var attributes=node.attributes;var numPI=Spry.Data.Region.PI.orderedInstructions.length;var lastStartComment=null;var lastEndComment=null;for(var i=0;i<numPI;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
287 |
{var piName=Spry.Data.Region.PI.orderedInstructions[i];var attr=attributes.getNamedItem(piName);if(!attr) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
288 |
continue;var piDesc=Spry.Data.Region.PI.instructions[piName];var childrenOnly=(node==rgn)?true:piDesc.childrenOnly;var openTag=piDesc.getOpenTag(node,piName);var closeTag=piDesc.getCloseTag(node,piName);if(childrenOnly) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
289 |
{var oComment=document.createComment(openTag);var cComment=document.createComment(closeTag);if(!lastStartComment) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
290 |
node.insertBefore(oComment,node.firstChild);else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
291 |
node.insertBefore(oComment,lastStartComment.nextSibling);lastStartComment=oComment;if(!lastEndComment) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
292 |
node.appendChild(cComment);else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
293 |
node.insertBefore(cComment,lastEndComment);lastEndComment=cComment;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
294 |
else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
295 |
{var parent=node.parentNode;parent.insertBefore(document.createComment(openTag),node);parent.insertBefore(document.createComment(closeTag),node.nextSibling);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
296 |
if(piName=="spry:state") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
297 |
regionStates[attr.value]=true;node.removeAttribute(piName);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
298 |
if(Spry.Data.Region.enableBehaviorAttributes) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
299 |
{var bAttrs=Spry.Data.Region.behaviorAttrs;for(var behaviorAttrName in bAttrs) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
300 |
{var bAttr=attributes.getNamedItem(behaviorAttrName);if(bAttr) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
301 |
{hasBehaviorAttributes=true;if(bAttrs[behaviorAttrName].setup) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
302 |
bAttrs[behaviorAttrName].setup(node,bAttr.value);}}}}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
303 |
catch(e){} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
304 |
return false;});dataStr=rgn.innerHTML;if(window.ActiveXObject&&!Spry.Data.Region.disableIEInnerHTMLFixUp&&dataStr.search(/=\{/)!=-1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
305 |
{if(Spry.Data.Region.debug) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
306 |
Spry.Debug.trace("<hr />Performing IE innerHTML fix up of Region: "+name+"<br /><br />"+Spry.Utils.encodeEntities(dataStr));dataStr=Spry.Utils.fixUpIEInnerHTML(dataStr);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
307 |
if(Spry.Data.Region.debug) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
308 |
Spry.Debug.trace("<hr />Region template markup for '"+name+"':<br /><br />"+Spry.Utils.encodeEntities(dataStr));if(!hasSpryContent) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
309 |
{rgn.innerHTML="";} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
310 |
var region=new Spry.Data.Region(rgn,name,isDetailRegion,dataStr,dataSets,regionStates,regionStateMap,hasBehaviorAttributes);Spry.Data.regionsArray[region.name]=region;newRegions.push(region);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
311 |
for(var i=0;i<newRegions.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
312 |
newRegions[i].updateContent();};Spry.Data.initRegions.nextUniqueRegionID=0;Spry.Data.updateRegion=function(regionName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
313 |
{if(!regionName||!Spry.Data.regionsArray||!Spry.Data.regionsArray[regionName]) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
314 |
return;try{Spry.Data.regionsArray[regionName].updateContent();} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
315 |
catch(e){Spry.Debug.reportError("Spry.Data.updateRegion("+regionName+") caught an exception: "+e+"\n");}};Spry.Data.getRegion=function(regionName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
316 |
{return Spry.Data.regionsArray[regionName];};Spry.Data.updateAllRegions=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
317 |
{if(!Spry.Data.regionsArray) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
318 |
return;for(var regionName in Spry.Data.regionsArray) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
319 |
Spry.Data.updateRegion(regionName);};Spry.Data.getDataSetByName=function(dataSetName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
320 |
{var ds=window[dataSetName];if(typeof ds!="object"||!ds.getData||!ds.filter) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
321 |
return null;return ds;};Spry.Data.DataSet=function(options) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
322 |
{Spry.Utils.Notifier.call(this);this.name="";this.internalID=Spry.Data.DataSet.nextDataSetID++;this.curRowID=0;this.data=[];this.unfilteredData=null;this.dataHash={};this.columnTypes={};this.filterFunc=null;this.filterDataFunc=null;this.distinctOnLoad=false;this.distinctFieldsOnLoad=null;this.sortOnLoad=null;this.sortOrderOnLoad="ascending";this.keepSorted=false;this.dataWasLoaded=false;this.pendingRequest=null;this.lastSortColumns=[];this.lastSortOrder="";this.loadIntervalID=0;Spry.Utils.setOptions(this,options);};Spry.Data.DataSet.prototype=new Spry.Utils.Notifier();Spry.Data.DataSet.prototype.constructor=Spry.Data.DataSet;Spry.Data.DataSet.prototype.getData=function(unfiltered) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
323 |
{return(unfiltered&&this.unfilteredData)?this.unfilteredData:this.data;};Spry.Data.DataSet.prototype.getUnfilteredData=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
324 |
{return this.getData(true);};Spry.Data.DataSet.prototype.getLoadDataRequestIsPending=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
325 |
{return this.pendingRequest!=null;};Spry.Data.DataSet.prototype.getDataWasLoaded=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
326 |
{return this.dataWasLoaded;};Spry.Data.DataSet.prototype.getValue=function(valueName,rowContext) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
327 |
{var result=undefined;if(!rowContext) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
328 |
rowContext=this.getCurrentRow();switch(valueName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
329 |
{case"ds_RowNumber":result=this.getRowNumber(rowContext);break;case"ds_RowNumberPlus1":result=this.getRowNumber(rowContext)+1;break;case"ds_RowCount":result=this.getRowCount();break;case"ds_UnfilteredRowCount":result=this.getRowCount(true);break;case"ds_CurrentRowNumber":result=this.getCurrentRowNumber();break;case"ds_CurrentRowID":result=this.getCurrentRowID();break;case"ds_EvenOddRow":result=(this.getRowNumber(rowContext)%2)?Spry.Data.Region.evenRowClassName:Spry.Data.Region.oddRowClassName;break;case"ds_SortOrder":result=this.getSortOrder();break;case"ds_SortColumn":result=this.getSortColumn();break;default:if(rowContext) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
330 |
result=rowContext[valueName];break;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
331 |
return result;};Spry.Data.DataSet.prototype.setDataFromArray=function(arr,fireSyncLoad) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
332 |
{this.notifyObservers("onPreLoad");this.unfilteredData=null;this.filteredData=null;this.data=[];this.dataHash={};var arrLen=arr.length;for(var i=0;i<arrLen;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
333 |
{var row=arr[i];if(row.ds_RowID==undefined) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
334 |
row.ds_RowID=i;this.dataHash[row.ds_RowID]=row;this.data.push(row);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
335 |
this.loadData(fireSyncLoad);};Spry.Data.DataSet.prototype.loadData=function(syncLoad) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
336 |
{var self=this;this.pendingRequest=new Object;this.dataWasLoaded=false;var loadCallbackFunc=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
337 |
{self.pendingRequest=null;self.dataWasLoaded=true;self.applyColumnTypes();self.disableNotifications();self.filterAndSortData();self.enableNotifications();self.notifyObservers("onPostLoad");self.notifyObservers("onDataChanged");};if(syncLoad) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
338 |
loadCallbackFunc();else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
339 |
this.pendingRequest.timer=setTimeout(loadCallbackFunc,0);};Spry.Data.DataSet.prototype.filterAndSortData=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
340 |
{if(this.filterDataFunc) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
341 |
this.filterData(this.filterDataFunc,true);if(this.distinctOnLoad) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
342 |
this.distinct(this.distinctFieldsOnLoad);if(this.keepSorted&&this.getSortColumn()) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
343 |
this.sort(this.lastSortColumns,this.lastSortOrder);else if(this.sortOnLoad) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
344 |
this.sort(this.sortOnLoad,this.sortOrderOnLoad);if(this.filterFunc) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
345 |
this.filter(this.filterFunc,true);if(this.data&&this.data.length>0) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
346 |
this.curRowID=this.data[0]['ds_RowID'];else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
347 |
this.curRowID=0;};Spry.Data.DataSet.prototype.cancelLoadData=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
348 |
{if(this.pendingRequest&&this.pendingRequest.timer) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
349 |
clearTimeout(this.pendingRequest.timer);this.pendingRequest=null;};Spry.Data.DataSet.prototype.getRowCount=function(unfiltered) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
350 |
{var rows=this.getData(unfiltered);return rows?rows.length:0;};Spry.Data.DataSet.prototype.getRowByID=function(rowID) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
351 |
{if(!this.data) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
352 |
return null;return this.dataHash[rowID];};Spry.Data.DataSet.prototype.getRowByRowNumber=function(rowNumber,unfiltered) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
353 |
{var rows=this.getData(unfiltered);if(rows&&rowNumber>=0&&rowNumber<rows.length) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
354 |
return rows[rowNumber];return null;};Spry.Data.DataSet.prototype.getCurrentRow=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
355 |
{return this.getRowByID(this.curRowID);};Spry.Data.DataSet.prototype.setCurrentRow=function(rowID) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
356 |
{if(this.curRowID==rowID) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
357 |
return;var nData={oldRowID:this.curRowID,newRowID:rowID};this.curRowID=rowID;this.notifyObservers("onCurrentRowChanged",nData);};Spry.Data.DataSet.prototype.getRowNumber=function(row,unfiltered) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
358 |
{if(row) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
359 |
{var rows=this.getData(unfiltered);if(rows&&rows.length) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
360 |
{var numRows=rows.length;for(var i=0;i<numRows;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
361 |
{if(rows[i]==row) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
362 |
return i;}}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
363 |
return-1;};Spry.Data.DataSet.prototype.getCurrentRowNumber=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
364 |
{return this.getRowNumber(this.getCurrentRow());};Spry.Data.DataSet.prototype.getCurrentRowID=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
365 |
{return this.curRowID;};Spry.Data.DataSet.prototype.setCurrentRowNumber=function(rowNumber) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
366 |
{if(!this.data||rowNumber>=this.data.length) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
367 |
{Spry.Debug.trace("Invalid row number: "+rowNumber+"\n");return;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
368 |
var rowID=this.data[rowNumber]["ds_RowID"];if(rowID==undefined||this.curRowID==rowID) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
369 |
return;this.setCurrentRow(rowID);};Spry.Data.DataSet.prototype.findRowsWithColumnValues=function(valueObj,firstMatchOnly,unfiltered) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
370 |
{var results=[];var rows=this.getData(unfiltered);if(rows) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
371 |
{var numRows=rows.length;for(var i=0;i<numRows;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
372 |
{var row=rows[i];var matched=true;for(var colName in valueObj) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
373 |
{if(valueObj[colName]!=row[colName]) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
374 |
{matched=false;break;}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
375 |
if(matched) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
376 |
{if(firstMatchOnly) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
377 |
return row;results.push(row);}}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
378 |
return firstMatchOnly?null:results;};Spry.Data.DataSet.prototype.setColumnType=function(columnNames,columnType) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
379 |
{if(columnNames) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
380 |
{if(typeof columnNames=="string") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
381 |
columnNames=[columnNames];for(var i=0;i<columnNames.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
382 |
this.columnTypes[columnNames[i]]=columnType;}};Spry.Data.DataSet.prototype.getColumnType=function(columnName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
383 |
{if(this.columnTypes[columnName]) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
384 |
return this.columnTypes[columnName];return"string";};Spry.Data.DataSet.prototype.applyColumnTypes=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
385 |
{var rows=this.getData(true);var numRows=rows.length;var colNames=[];if(numRows<1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
386 |
return;for(var cname in this.columnTypes) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
387 |
{var ctype=this.columnTypes[cname];if(ctype!="string") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
388 |
{for(var i=0;i<numRows;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
389 |
{var row=rows[i];var val=row[cname];if(val!=undefined) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
390 |
{if(ctype=="number") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
391 |
row[cname]=new Number(val);else if(ctype=="html") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
392 |
row[cname]=Spry.Utils.decodeEntities(val);}}}}};Spry.Data.DataSet.prototype.distinct=function(columnNames) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
393 |
{if(this.data) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
394 |
{var oldData=this.data;this.data=[];this.dataHash={};var dataChanged=false;var alreadySeenHash={};var i=0;var keys=[];if(typeof columnNames=="string") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
395 |
keys=[columnNames];else if(columnNames) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
396 |
keys=columnNames;else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
397 |
for(var recField in oldData[0]) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
398 |
keys[i++]=recField;for(var i=0;i<oldData.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
399 |
{var rec=oldData[i];var hashStr="";for(var j=0;j<keys.length;j++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
400 |
{recField=keys[j];if(recField!="ds_RowID") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
401 |
{if(hashStr) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
402 |
hashStr+=",";hashStr+=recField+":"+"\""+rec[recField]+"\"";}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
403 |
if(!alreadySeenHash[hashStr]) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
404 |
{this.data.push(rec);this.dataHash[rec['ds_RowID']]=rec;alreadySeenHash[hashStr]=true;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
405 |
else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
406 |
dataChanged=true;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
407 |
if(dataChanged) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
408 |
this.notifyObservers('onDataChanged');}};Spry.Data.DataSet.prototype.getSortColumn=function(){return(this.lastSortColumns&&this.lastSortColumns.length>0)?this.lastSortColumns[0]:"";};Spry.Data.DataSet.prototype.getSortOrder=function(){return this.lastSortOrder?this.lastSortOrder:"";};Spry.Data.DataSet.prototype.sort=function(columnNames,sortOrder) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
409 |
{if(!columnNames) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
410 |
return;if(typeof columnNames=="string") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
411 |
columnNames=[columnNames,"ds_RowID"];else if(columnNames.length<2&&columnNames[0]!="ds_RowID") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
412 |
columnNames.push("ds_RowID");if(!sortOrder) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
413 |
sortOrder="toggle";if(sortOrder=="toggle") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
414 |
{if(this.lastSortColumns.length>0&&this.lastSortColumns[0]==columnNames[0]&&this.lastSortOrder=="ascending") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
415 |
sortOrder="descending";else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
416 |
sortOrder="ascending";} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
417 |
if(sortOrder!="ascending"&&sortOrder!="descending") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
418 |
{Spry.Debug.reportError("Invalid sort order type specified: "+sortOrder+"\n");return;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
419 |
var nData={oldSortColumns:this.lastSortColumns,oldSortOrder:this.lastSortOrder,newSortColumns:columnNames,newSortOrder:sortOrder};this.notifyObservers("onPreSort",nData);var cname=columnNames[columnNames.length-1];var sortfunc=Spry.Data.DataSet.prototype.sort.getSortFunc(cname,this.getColumnType(cname),sortOrder);for(var i=columnNames.length-2;i>=0;i--) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
420 |
{cname=columnNames[i];sortfunc=Spry.Data.DataSet.prototype.sort.buildSecondarySortFunc(Spry.Data.DataSet.prototype.sort.getSortFunc(cname,this.getColumnType(cname),sortOrder),sortfunc);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
421 |
if(this.unfilteredData) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
422 |
{this.unfilteredData.sort(sortfunc);if(this.filterFunc) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
423 |
this.filter(this.filterFunc,true);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
424 |
else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
425 |
this.data.sort(sortfunc);this.lastSortColumns=columnNames.slice(0);this.lastSortOrder=sortOrder;this.notifyObservers("onPostSort",nData);};Spry.Data.DataSet.prototype.sort.getSortFunc=function(prop,type,order) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
426 |
{var sortfunc=null;if(type=="number") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
427 |
{if(order=="ascending") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
428 |
sortfunc=function(a,b) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
429 |
{a=a[prop];b=b[prop];if(a==undefined||b==undefined) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
430 |
return(a==b)?0:(a?1:-1);return a-b;};else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
431 |
sortfunc=function(a,b) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
432 |
{a=a[prop];b=b[prop];if(a==undefined||b==undefined) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
433 |
return(a==b)?0:(a?-1:1);return b-a;};} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
434 |
else if(type=="date") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
435 |
{if(order=="ascending") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
436 |
sortfunc=function(a,b) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
437 |
{var dA=a[prop];var dB=b[prop];dA=dA?(new Date(dA)):0;dB=dB?(new Date(dB)):0;return dA-dB;};else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
438 |
sortfunc=function(a,b) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
439 |
{var dA=a[prop];var dB=b[prop];dA=dA?(new Date(dA)):0;dB=dB?(new Date(dB)):0;return dB-dA;};} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
440 |
else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
441 |
{if(order=="ascending") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
442 |
sortfunc=function(a,b){a=a[prop];b=b[prop];if(a==undefined||b==undefined) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
443 |
return(a==b)?0:(a?1:-1);var tA=a.toString();var tB=b.toString();var tA_l=tA.toLowerCase();var tB_l=tB.toLowerCase();var min_len=tA.length>tB.length?tB.length:tA.length;for(var i=0;i<min_len;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
444 |
{var a_l_c=tA_l.charAt(i);var b_l_c=tB_l.charAt(i);var a_c=tA.charAt(i);var b_c=tB.charAt(i);if(a_l_c>b_l_c) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
445 |
return 1;else if(a_l_c<b_l_c) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
446 |
return-1;else if(a_c>b_c) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
447 |
return 1;else if(a_c<b_c) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
448 |
return-1;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
449 |
if(tA.length==tB.length) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
450 |
return 0;else if(tA.length>tB.length) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
451 |
return 1;return-1;};else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
452 |
sortfunc=function(a,b){a=a[prop];b=b[prop];if(a==undefined||b==undefined) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
453 |
return(a==b)?0:(a?-1:1);var tA=a.toString();var tB=b.toString();var tA_l=tA.toLowerCase();var tB_l=tB.toLowerCase();var min_len=tA.length>tB.length?tB.length:tA.length;for(var i=0;i<min_len;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
454 |
{var a_l_c=tA_l.charAt(i);var b_l_c=tB_l.charAt(i);var a_c=tA.charAt(i);var b_c=tB.charAt(i);if(a_l_c>b_l_c) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
455 |
return-1;else if(a_l_c<b_l_c) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
456 |
return 1;else if(a_c>b_c) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
457 |
return-1;else if(a_c<b_c) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
458 |
return 1;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
459 |
if(tA.length==tB.length) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
460 |
return 0;else if(tA.length>tB.length) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
461 |
return-1;return 1;};} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
462 |
return sortfunc;};Spry.Data.DataSet.prototype.sort.buildSecondarySortFunc=function(funcA,funcB) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
463 |
{return function(a,b) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
464 |
{var ret=funcA(a,b);if(ret==0) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
465 |
ret=funcB(a,b);return ret;};};Spry.Data.DataSet.prototype.filterData=function(filterFunc,filterOnly) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
466 |
{var dataChanged=false;if(!filterFunc) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
467 |
{this.filterDataFunc=null;dataChanged=true;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
468 |
else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
469 |
{this.filterDataFunc=filterFunc;if(this.dataWasLoaded&&((this.unfilteredData&&this.unfilteredData.length)||(this.data&&this.data.length))) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
470 |
{if(this.unfilteredData) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
471 |
{this.data=this.unfilteredData;this.unfilteredData=null;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
472 |
var oldData=this.data;this.data=[];this.dataHash={};for(var i=0;i<oldData.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
473 |
{var newRow=filterFunc(this,oldData[i],i);if(newRow) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
474 |
{this.data.push(newRow);this.dataHash[newRow["ds_RowID"]]=newRow;}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
475 |
dataChanged=true;}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
476 |
if(dataChanged) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
477 |
{if(!filterOnly) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
478 |
{this.disableNotifications();if(this.filterFunc) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
479 |
this.filter(this.filterFunc,true);this.enableNotifications();} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
480 |
this.notifyObservers("onDataChanged");}};Spry.Data.DataSet.prototype.filter=function(filterFunc,filterOnly) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
481 |
{var dataChanged=false;if(!filterFunc) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
482 |
{if(this.filterFunc&&this.unfilteredData) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
483 |
{this.data=this.unfilteredData;this.unfilteredData=null;this.filterFunc=null;dataChanged=true;}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
484 |
else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
485 |
{this.filterFunc=filterFunc;if(this.dataWasLoaded&&(this.unfilteredData||(this.data&&this.data.length))) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
486 |
{if(!this.unfilteredData) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
487 |
this.unfilteredData=this.data;var udata=this.unfilteredData;this.data=[];for(var i=0;i<udata.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
488 |
{var newRow=filterFunc(this,udata[i],i);if(newRow) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
489 |
this.data.push(newRow);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
490 |
dataChanged=true;}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
491 |
if(dataChanged) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
492 |
this.notifyObservers("onDataChanged");};Spry.Data.DataSet.prototype.startLoadInterval=function(interval) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
493 |
{this.stopLoadInterval();if(interval>0) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
494 |
{var self=this;this.loadInterval=interval;this.loadIntervalID=setInterval(function(){self.loadData();},interval);}};Spry.Data.DataSet.prototype.stopLoadInterval=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
495 |
{if(this.loadIntervalID) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
496 |
clearInterval(this.loadIntervalID);this.loadInterval=0;this.loadIntervalID=null;};Spry.Data.DataSet.nextDataSetID=0;Spry.Data.HTTPSourceDataSet=function(dataSetURL,dataSetOptions) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
497 |
{Spry.Data.DataSet.call(this);this.url=dataSetURL;this.dataSetsForDataRefStrings=new Array;this.hasDataRefStrings=false;this.useCache=true;this.setRequestInfo(dataSetOptions,true);Spry.Utils.setOptions(this,dataSetOptions,true);this.recalculateDataSetDependencies();if(this.loadInterval>0) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
498 |
this.startLoadInterval(this.loadInterval);};Spry.Data.HTTPSourceDataSet.prototype=new Spry.Data.DataSet();Spry.Data.HTTPSourceDataSet.prototype.constructor=Spry.Data.HTTPSourceDataSet;Spry.Data.HTTPSourceDataSet.prototype.setRequestInfo=function(requestInfo,undefineRequestProps) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
499 |
{this.requestInfo=new Spry.Utils.loadURL.Request();this.requestInfo.extractRequestOptions(requestInfo,undefineRequestProps);if(this.requestInfo.method=="POST") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
500 |
{if(!this.requestInfo.headers) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
501 |
this.requestInfo.headers={};if(!this.requestInfo.headers['Content-Type']) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
502 |
this.requestInfo.headers['Content-Type']="application/x-www-form-urlencoded; charset=UTF-8";}};Spry.Data.HTTPSourceDataSet.prototype.recalculateDataSetDependencies=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
503 |
{this.hasDataRefStrings=false;var i=0;for(i=0;i<this.dataSetsForDataRefStrings.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
504 |
{var ds=this.dataSetsForDataRefStrings[i];if(ds) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
505 |
ds.removeObserver(this);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
506 |
this.dataSetsForDataRefStrings=new Array();var regionStrs=this.getDataRefStrings();var dsCount=0;for(var n=0;n<regionStrs.length;n++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
507 |
{var tokens=Spry.Data.Region.getTokensFromStr(regionStrs[n]);for(i=0;tokens&&i<tokens.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
508 |
{if(tokens[i].search(/{[^}:]+::[^}]+}/)!=-1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
509 |
{var dsName=tokens[i].replace(/^\{|::.*\}/g,"");var ds=null;if(!this.dataSetsForDataRefStrings[dsName]) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
510 |
{ds=Spry.Data.getDataSetByName(dsName);if(dsName&&ds) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
511 |
{this.dataSetsForDataRefStrings[dsName]=ds;this.dataSetsForDataRefStrings[dsCount++]=ds;this.hasDataRefStrings=true;}}}}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
512 |
for(i=0;i<this.dataSetsForDataRefStrings.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
513 |
{var ds=this.dataSetsForDataRefStrings[i];ds.addObserver(this);}};Spry.Data.HTTPSourceDataSet.prototype.getDataRefStrings=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
514 |
{var strArr=[];if(this.url)strArr.push(this.url);if(this.requestInfo&&this.requestInfo.postData)strArr.push(this.requestInfo.postData);return strArr;};Spry.Data.HTTPSourceDataSet.prototype.attemptLoadData=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
515 |
{for(var i=0;i<this.dataSetsForDataRefStrings.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
516 |
{var ds=this.dataSetsForDataRefStrings[i];if(ds.getLoadDataRequestIsPending()||!ds.getDataWasLoaded()) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
517 |
return;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
518 |
this.loadData();};Spry.Data.HTTPSourceDataSet.prototype.onCurrentRowChanged=function(ds,data) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
519 |
{this.attemptLoadData();};Spry.Data.HTTPSourceDataSet.prototype.onPostSort=function(ds,data) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
520 |
{this.attemptLoadData();};Spry.Data.HTTPSourceDataSet.prototype.onDataChanged=function(ds,data) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
521 |
{this.attemptLoadData();};Spry.Data.HTTPSourceDataSet.prototype.loadData=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
522 |
{if(!this.url) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
523 |
return;this.cancelLoadData();var url=this.url;var postData=this.requestInfo.postData;if(this.hasDataRefStrings) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
524 |
{var allDataSetsReady=true;for(var i=0;i<this.dataSetsForDataRefStrings.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
525 |
{var ds=this.dataSetsForDataRefStrings[i];if(ds.getLoadDataRequestIsPending()) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
526 |
allDataSetsReady=false;else if(!ds.getDataWasLoaded()) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
527 |
{ds.loadData();allDataSetsReady=false;}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
528 |
if(!allDataSetsReady) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
529 |
return;url=Spry.Data.Region.processDataRefString(null,this.url,this.dataSetsForDataRefStrings);if(!url) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
530 |
return;if(postData&&(typeof postData)=="string") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
531 |
postData=Spry.Data.Region.processDataRefString(null,postData,this.dataSetsForDataRefStrings);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
532 |
this.notifyObservers("onPreLoad");this.data=null;this.dataWasLoaded=false;this.unfilteredData=null;this.dataHash=null;this.curRowID=0;var req=this.requestInfo.clone();req.url=url;req.postData=postData;this.pendingRequest=new Object;this.pendingRequest.data=Spry.Data.HTTPSourceDataSet.LoadManager.loadData(req,this,this.useCache);};Spry.Data.HTTPSourceDataSet.prototype.cancelLoadData=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
533 |
{if(this.pendingRequest) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
534 |
{Spry.Data.HTTPSourceDataSet.LoadManager.cancelLoadData(this.pendingRequest.data,this);this.pendingRequest=null;}};Spry.Data.HTTPSourceDataSet.prototype.getURL=function(){return this.url;};Spry.Data.HTTPSourceDataSet.prototype.setURL=function(url,requestOptions) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
535 |
{if(this.url==url) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
536 |
{if(!requestOptions||(this.requestInfo.method==requestOptions.method&&(requestOptions.method!="POST"||this.requestInfo.postData==requestOptions.postData))) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
537 |
return;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
538 |
this.url=url;this.setRequestInfo(requestOptions);this.cancelLoadData();this.recalculateDataSetDependencies();this.dataWasLoaded=false;};Spry.Data.HTTPSourceDataSet.prototype.setDataFromDoc=function(rawDataDoc) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
539 |
{this.pendingRequest=null;this.loadDataIntoDataSet(rawDataDoc);this.applyColumnTypes();this.disableNotifications();this.filterAndSortData();this.enableNotifications();this.notifyObservers("onPostLoad");this.notifyObservers("onDataChanged");};Spry.Data.HTTPSourceDataSet.prototype.loadDataIntoDataSet=function(rawDataDoc) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
540 |
{this.dataHash=new Object;this.data=new Array;this.dataWasLoaded=true;};Spry.Data.HTTPSourceDataSet.prototype.xhRequestProcessor=function(xhRequest) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
541 |
{var resp=xhRequest.responseText;if(xhRequest.status==200||xhRequest.status==0) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
542 |
return resp;return null;};Spry.Data.HTTPSourceDataSet.prototype.sessionExpiredChecker=function(req) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
543 |
{if(req.xhRequest.responseText=='session expired') |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
544 |
return true;return false;};Spry.Data.HTTPSourceDataSet.prototype.setSessionExpiredChecker=function(checker) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
545 |
{this.sessionExpiredChecker=checker;};Spry.Data.HTTPSourceDataSet.prototype.onRequestResponse=function(cachedRequest,req) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
546 |
{this.setDataFromDoc(cachedRequest.rawData);};Spry.Data.HTTPSourceDataSet.prototype.onRequestError=function(cachedRequest,req) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
547 |
{this.notifyObservers("onLoadError",req);};Spry.Data.HTTPSourceDataSet.prototype.onRequestSessionExpired=function(cachedRequest,req) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
548 |
{this.notifyObservers("onSessionExpired",req);};Spry.Data.HTTPSourceDataSet.LoadManager={};Spry.Data.HTTPSourceDataSet.LoadManager.cache=[];Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest=function(reqInfo,xhRequestProcessor,sessionExpiredChecker) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
549 |
{Spry.Utils.Notifier.call(this);this.reqInfo=reqInfo;this.rawData=null;this.timer=null;this.state=Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.NOT_LOADED;this.xhRequestProcessor=xhRequestProcessor;this.sessionExpiredChecker=sessionExpiredChecker;};Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.prototype=new Spry.Utils.Notifier();Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.prototype.constructor=Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest;Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.NOT_LOADED=1;Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.LOAD_REQUESTED=2;Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.LOAD_FAILED=3;Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.LOAD_SUCCESSFUL=4;Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.prototype.loadDataCallback=function(req) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
550 |
{if(req.xhRequest.readyState!=4) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
551 |
return;var rawData=null;if(this.xhRequestProcessor)rawData=this.xhRequestProcessor(req.xhRequest);if(this.sessionExpiredChecker) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
552 |
{Spry.Utils.setOptions(req,{'rawData':rawData},false);if(this.sessionExpiredChecker(req)) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
553 |
{this.state=Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.LOAD_FAILED;this.notifyObservers("onRequestSessionExpired",req);this.observers.length=0;return;}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
554 |
if(!rawData) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
555 |
{this.state=Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.LOAD_FAILED;this.notifyObservers("onRequestError",req);this.observers.length=0;return;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
556 |
this.rawData=rawData;this.state=Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.LOAD_SUCCESSFUL;this.notifyObservers("onRequestResponse",req);this.observers.length=0;};Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.prototype.loadData=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
557 |
{var self=this;this.cancelLoadData();this.rawData=null;this.state=Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.LOAD_REQUESTED;var reqInfo=this.reqInfo.clone();reqInfo.successCallback=function(req){self.loadDataCallback(req);};reqInfo.errorCallback=reqInfo.successCallback;this.timer=setTimeout(function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
558 |
{self.timer=null;Spry.Utils.loadURL(reqInfo.method,reqInfo.url,reqInfo.async,reqInfo.successCallback,reqInfo);},0);};Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.prototype.cancelLoadData=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
559 |
{if(this.state==Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.LOAD_REQUESTED) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
560 |
{if(this.timer) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
561 |
{this.timer.clearTimeout();this.timer=null;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
562 |
this.rawData=null;this.state=Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.NOT_LOADED;}};Spry.Data.HTTPSourceDataSet.LoadManager.getCacheKey=function(reqInfo) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
563 |
{return reqInfo.method+"::"+reqInfo.url+"::"+reqInfo.postData+"::"+reqInfo.username;};Spry.Data.HTTPSourceDataSet.LoadManager.loadData=function(reqInfo,ds,useCache) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
564 |
{if(!reqInfo) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
565 |
return null;var cacheObj=null;var cacheKey=null;if(useCache) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
566 |
{cacheKey=Spry.Data.HTTPSourceDataSet.LoadManager.getCacheKey(reqInfo);cacheObj=Spry.Data.HTTPSourceDataSet.LoadManager.cache[cacheKey];} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
567 |
if(cacheObj) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
568 |
{if(cacheObj.state==Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.LOAD_REQUESTED) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
569 |
{if(ds) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
570 |
cacheObj.addObserver(ds);return cacheObj;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
571 |
else if(cacheObj.state==Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest.LOAD_SUCCESSFUL) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
572 |
{if(ds) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
573 |
setTimeout(function(){ds.setDataFromDoc(cacheObj.rawData);},0);return cacheObj;}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
574 |
if(!cacheObj) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
575 |
{cacheObj=new Spry.Data.HTTPSourceDataSet.LoadManager.CachedRequest(reqInfo,(ds?ds.xhRequestProcessor:null),(ds?ds.sessionExpiredChecker:null));if(useCache) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
576 |
{Spry.Data.HTTPSourceDataSet.LoadManager.cache[cacheKey]=cacheObj;cacheObj.addObserver({onRequestError:function(){Spry.Data.HTTPSourceDataSet.LoadManager.cache[cacheKey]=undefined;}});}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
577 |
if(ds) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
578 |
cacheObj.addObserver(ds);cacheObj.loadData();return cacheObj;};Spry.Data.HTTPSourceDataSet.LoadManager.cancelLoadData=function(cacheObj,ds) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
579 |
{if(cacheObj) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
580 |
{if(ds) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
581 |
cacheObj.removeObserver(ds);else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
582 |
cacheObj.cancelLoadData();}};Spry.Data.XMLDataSet=function(dataSetURL,dataSetPath,dataSetOptions) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
583 |
{this.xpath=dataSetPath;this.doc=null;this.subPaths=[];this.entityEncodeStrings=true;Spry.Data.HTTPSourceDataSet.call(this,dataSetURL,dataSetOptions);var jwType=typeof this.subPaths;if(jwType=="string"||(jwType=="object"&&this.subPaths.constructor!=Array)) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
584 |
this.subPaths=[this.subPaths];};Spry.Data.XMLDataSet.prototype=new Spry.Data.HTTPSourceDataSet();Spry.Data.XMLDataSet.prototype.constructor=Spry.Data.XMLDataSet;Spry.Data.XMLDataSet.prototype.getDataRefStrings=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
585 |
{var strArr=[];if(this.url)strArr.push(this.url);if(this.xpath)strArr.push(this.xpath);if(this.requestInfo&&this.requestInfo.postData)strArr.push(this.requestInfo.postData);return strArr;};Spry.Data.XMLDataSet.prototype.getDocument=function(){return this.doc;};Spry.Data.XMLDataSet.prototype.getXPath=function(){return this.xpath;};Spry.Data.XMLDataSet.prototype.setXPath=function(path) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
586 |
{if(this.xpath!=path) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
587 |
{this.xpath=path;if(this.dataWasLoaded&&this.doc) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
588 |
{this.notifyObservers("onPreLoad");this.setDataFromDoc(this.doc);}}};Spry.Data.XMLDataSet.nodeContainsElementNode=function(node) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
589 |
{if(node) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
590 |
{node=node.firstChild;while(node) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
591 |
{if(node.nodeType==1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
592 |
return true;node=node.nextSibling;}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
593 |
return false;};Spry.Data.XMLDataSet.getNodeText=function(node,encodeText,encodeCData) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
594 |
{var txt="";if(!node) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
595 |
return;try |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
596 |
{var child=node.firstChild;while(child) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
597 |
{try |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
598 |
{if(child.nodeType==3) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
599 |
txt+=encodeText?Spry.Utils.encodeEntities(child.data):child.data;else if(child.nodeType==4) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
600 |
txt+=encodeCData?Spry.Utils.encodeEntities(child.data):child.data;}catch(e){Spry.Debug.reportError("Spry.Data.XMLDataSet.getNodeText() exception caught: "+e+"\n");} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
601 |
child=child.nextSibling;}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
602 |
catch(e){Spry.Debug.reportError("Spry.Data.XMLDataSet.getNodeText() exception caught: "+e+"\n");} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
603 |
return txt;};Spry.Data.XMLDataSet.createObjectForNode=function(node,encodeText,encodeCData) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
604 |
{if(!node) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
605 |
return null;var obj=new Object();var i=0;var attr=null;try |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
606 |
{for(i=0;i<node.attributes.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
607 |
{attr=node.attributes[i];if(attr&&attr.nodeType==2) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
608 |
obj["@"+attr.name]=attr.value;}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
609 |
catch(e) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
610 |
{Spry.Debug.reportError("Spry.Data.XMLDataSet.createObjectForNode() caught exception while accessing attributes: "+e+"\n");} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
611 |
var child=node.firstChild;if(child&&!child.nextSibling&&child.nodeType!=1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
612 |
{obj[node.nodeName]=Spry.Data.XMLDataSet.getNodeText(node,encodeText,encodeCData);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
613 |
while(child) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
614 |
{if(child.nodeType==1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
615 |
{if(!Spry.Data.XMLDataSet.nodeContainsElementNode(child)) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
616 |
{obj[child.nodeName]=Spry.Data.XMLDataSet.getNodeText(child,encodeText,encodeCData);try |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
617 |
{var namePrefix=child.nodeName+"/@";for(i=0;i<child.attributes.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
618 |
{attr=child.attributes[i];if(attr&&attr.nodeType==2) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
619 |
obj[namePrefix+attr.name]=attr.value;}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
620 |
catch(e) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
621 |
{Spry.Debug.reportError("Spry.Data.XMLDataSet.createObjectForNode() caught exception while accessing attributes: "+e+"\n");}}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
622 |
child=child.nextSibling;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
623 |
return obj;};Spry.Data.XMLDataSet.getRecordSetFromXMLDoc=function(xmlDoc,path,suppressColumns,entityEncodeStrings) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
624 |
{if(!xmlDoc||!path) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
625 |
return null;var recordSet=new Object();recordSet.xmlDoc=xmlDoc;recordSet.xmlPath=path;recordSet.dataHash=new Object;recordSet.data=new Array;recordSet.getData=function(){return this.data;};var ctx=new ExprContext(xmlDoc);var pathExpr=xpathParse(path);var e=pathExpr.evaluate(ctx);var nodeArray=e.nodeSetValue();var isDOMNodeArray=true;if(nodeArray&&nodeArray.length>0) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
626 |
isDOMNodeArray=nodeArray[0].nodeType!=2;var nextID=0;var encodeText=true;var encodeCData=false;if(typeof entityEncodeStrings=="boolean") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
627 |
encodeText=encodeCData=entityEncodeStrings;for(var i=0;i<nodeArray.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
628 |
{var rowObj=null;if(suppressColumns) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
629 |
rowObj=new Object;else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
630 |
{if(isDOMNodeArray) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
631 |
rowObj=Spry.Data.XMLDataSet.createObjectForNode(nodeArray[i],encodeText,encodeCData);else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
632 |
{rowObj=new Object;rowObj["@"+nodeArray[i].name]=nodeArray[i].value;}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
633 |
if(rowObj) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
634 |
{rowObj['ds_RowID']=nextID++;rowObj['ds_XMLNode']=nodeArray[i];recordSet.dataHash[rowObj['ds_RowID']]=rowObj;recordSet.data.push(rowObj);}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
635 |
return recordSet;};Spry.Data.XMLDataSet.PathNode=function(path) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
636 |
{this.path=path;this.subPaths=[];this.xpath="";};Spry.Data.XMLDataSet.PathNode.prototype.addSubPath=function(path) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
637 |
{var node=this.findSubPath(path);if(!node) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
638 |
{node=new Spry.Data.XMLDataSet.PathNode(path);this.subPaths.push(node);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
639 |
return node;};Spry.Data.XMLDataSet.PathNode.prototype.findSubPath=function(path) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
640 |
{var numSubPaths=this.subPaths.length;for(var i=0;i<numSubPaths;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
641 |
{var subPath=this.subPaths[i];if(path==subPath.path) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
642 |
return subPath;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
643 |
return null;};Spry.Data.XMLDataSet.PathNode.prototype.consolidate=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
644 |
{var numSubPaths=this.subPaths.length;if(!this.xpath&&numSubPaths==1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
645 |
{var subPath=this.subPaths[0];this.path+=((subPath[0]!="/")?"/":"")+subPath.path;this.xpath=subPath.xpath;this.subPaths=subPath.subPaths;this.consolidate();return;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
646 |
for(var i=0;i<numSubPaths;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
647 |
this.subPaths[i].consolidate();};Spry.Data.XMLDataSet.prototype.convertXPathsToPathTree=function(xpathArray) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
648 |
{var xpaLen=xpathArray.length;var root=new Spry.Data.XMLDataSet.PathNode("");for(var i=0;i<xpaLen;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
649 |
{var xpath=xpathArray[i];var cleanXPath=xpath.replace(/\/\//g,"/__SPRYDS__");cleanXPath=cleanXPath.replace(/^\//,"");var pathItems=cleanXPath.split(/\//);var pathItemsLen=pathItems.length;var node=root;for(var j=0;j<pathItemsLen;j++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
650 |
{var path=pathItems[j].replace(/__SPRYDS__/,"//");node=node.addSubPath(path);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
651 |
node.xpath=xpath;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
652 |
root.consolidate();return root;};Spry.Data.XMLDataSet.prototype.flattenSubPaths=function(rs,subPaths) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
653 |
{if(!rs||!subPaths) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
654 |
return;var numSubPaths=subPaths.length;if(numSubPaths<1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
655 |
return;var data=rs.data;var dataHash={};var xpathArray=[];var cleanedXPathArray=[];for(var i=0;i<numSubPaths;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
656 |
{var subPath=subPaths[i];if(typeof subPath=="object") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
657 |
subPath=subPath.path;if(!subPath) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
658 |
subPath="";xpathArray[i]=Spry.Data.Region.processDataRefString(null,subPath,this.dataSetsForDataRefStrings);cleanedXPathArray[i]=xpathArray[i].replace(/\[.*\]/g,"");} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
659 |
var row;var numRows=data.length;var newData=[];for(var i=0;i<numRows;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
660 |
{row=data[i];var newRows=[row];for(var j=0;j<numSubPaths;j++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
661 |
{var newRS=Spry.Data.XMLDataSet.getRecordSetFromXMLDoc(row.ds_XMLNode,xpathArray[j],(subPaths[j].xpath?false:true),this.entityEncodeStrings);if(newRS&&newRS.data&&newRS.data.length) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
662 |
{if(typeof subPaths[j]=="object"&&subPaths[j].subPaths) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
663 |
{var sp=subPaths[j].subPaths;spType=typeof sp;if(spType=="string") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
664 |
sp=[sp];else if(spType=="object"&&spType.constructor==Object) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
665 |
sp=[sp];this.flattenSubPaths(newRS,sp);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
666 |
var newRSData=newRS.data;var numRSRows=newRSData.length;var cleanedXPath=cleanedXPathArray[j]+"/";var numNewRows=newRows.length;var joinedRows=[];for(var k=0;k<numNewRows;k++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
667 |
{var newRow=newRows[k];for(var l=0;l<numRSRows;l++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
668 |
{var newRowObj=new Object;var newRSRow=newRSData[l];for(prop in newRow) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
669 |
newRowObj[prop]=newRow[prop];for(var prop in newRSRow) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
670 |
{var newPropName=cleanedXPath+prop;if(cleanedXPath==(prop+"/")||cleanedXPath.search(new RegExp("\\/"+prop+"\\/$"))!=-1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
671 |
newPropName=cleanedXPathArray[j];newRowObj[newPropName]=newRSRow[prop];} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
672 |
joinedRows.push(newRowObj);}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
673 |
newRows=joinedRows;}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
674 |
newData=newData.concat(newRows);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
675 |
data=newData;numRows=data.length;for(i=0;i<numRows;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
676 |
{row=data[i];row.ds_RowID=i;dataHash[row.ds_RowID]=row;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
677 |
rs.data=data;rs.dataHash=dataHash;};Spry.Data.XMLDataSet.prototype.loadDataIntoDataSet=function(rawDataDoc) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
678 |
{var rs=null;var mainXPath=Spry.Data.Region.processDataRefString(null,this.xpath,this.dataSetsForDataRefStrings);var subPaths=this.subPaths;var suppressColumns=false;if(this.subPaths&&this.subPaths.length>0) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
679 |
{var processedSubPaths=[];var numSubPaths=subPaths.length;for(var i=0;i<numSubPaths;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
680 |
{var subPathStr=Spry.Data.Region.processDataRefString(null,subPaths[i],this.dataSetsForDataRefStrings);if(subPathStr.charAt(0)!='/') |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
681 |
subPathStr=mainXPath+"/"+subPathStr;processedSubPaths.push(subPathStr);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
682 |
processedSubPaths.unshift(mainXPath);var commonParent=this.convertXPathsToPathTree(processedSubPaths);mainXPath=commonParent.path;subPaths=commonParent.subPaths;suppressColumns=commonParent.xpath?false:true;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
683 |
rs=Spry.Data.XMLDataSet.getRecordSetFromXMLDoc(rawDataDoc,mainXPath,suppressColumns,this.entityEncodeStrings);if(!rs) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
684 |
{Spry.Debug.reportError("Spry.Data.XMLDataSet.loadDataIntoDataSet() failed to create dataSet '"+this.name+"'for '"+this.xpath+"' - "+this.url+"\n");return;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
685 |
this.flattenSubPaths(rs,subPaths);this.doc=rs.xmlDoc;this.data=rs.data;this.dataHash=rs.dataHash;this.dataWasLoaded=(this.doc!=null);};Spry.Data.XMLDataSet.prototype.xhRequestProcessor=function(xhRequest) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
686 |
{var resp=xhRequest.responseXML;var manualParseRequired=false;if(xhRequest.status!=200) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
687 |
{if(xhRequest.status==0) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
688 |
{if(xhRequest.responseText&&(!resp||!resp.firstChild)) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
689 |
manualParseRequired=true;}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
690 |
else if(!resp) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
691 |
{manualParseRequired=true;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
692 |
if(manualParseRequired) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
693 |
resp=Spry.Utils.stringToXMLDoc(xhRequest.responseText);if(!resp||!resp.firstChild||resp.firstChild.nodeName=="parsererror") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
694 |
return null;return resp;};Spry.Data.XMLDataSet.prototype.sessionExpiredChecker=function(req) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
695 |
{if(req.xhRequest.responseText=='session expired') |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
696 |
return true;else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
697 |
{if(req.rawData) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
698 |
{var firstChild=req.rawData.documentElement.firstChild;if(firstChild&&firstChild.nodeValue=="session expired") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
699 |
return true;}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
700 |
return false;};Spry.Data.Region=function(regionNode,name,isDetailRegion,data,dataSets,regionStates,regionStateMap,hasBehaviorAttributes) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
701 |
{this.regionNode=regionNode;this.name=name;this.isDetailRegion=isDetailRegion;this.data=data;this.dataSets=dataSets;this.hasBehaviorAttributes=hasBehaviorAttributes;this.tokens=null;this.currentState=null;this.states={ready:true};this.stateMap={};Spry.Utils.setOptions(this.states,regionStates);Spry.Utils.setOptions(this.stateMap,regionStateMap);for(var i=0;i<this.dataSets.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
702 |
{var ds=this.dataSets[i];try |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
703 |
{if(ds) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
704 |
ds.addObserver(this);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
705 |
catch(e){Spry.Debug.reportError("Failed to add '"+this.name+"' as a dataSet observer!\n");}}};Spry.Data.Region.hiddenRegionClassName="SpryHiddenRegion";Spry.Data.Region.evenRowClassName="even";Spry.Data.Region.oddRowClassName="odd";Spry.Data.Region.notifiers={};Spry.Data.Region.evalScripts=true;Spry.Data.Region.addObserver=function(regionID,observer) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
706 |
{var n=Spry.Data.Region.notifiers[regionID];if(!n) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
707 |
{n=new Spry.Utils.Notifier();Spry.Data.Region.notifiers[regionID]=n;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
708 |
n.addObserver(observer);};Spry.Data.Region.removeObserver=function(regionID,observer) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
709 |
{var n=Spry.Data.Region.notifiers[regionID];if(n) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
710 |
n.removeObserver(observer);};Spry.Data.Region.notifyObservers=function(methodName,region,data) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
711 |
{var n=Spry.Data.Region.notifiers[region.name];if(n) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
712 |
{var dataObj={};if(data&&typeof data=="object") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
713 |
dataObj=data;else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
714 |
dataObj.data=data;dataObj.region=region;dataObj.regionID=region.name;dataObj.regionNode=region.regionNode;n.notifyObservers(methodName,dataObj);}};Spry.Data.Region.RS_Error=0x01;Spry.Data.Region.RS_LoadingData=0x02;Spry.Data.Region.RS_PreUpdate=0x04;Spry.Data.Region.RS_PostUpdate=0x08;Spry.Data.Region.prototype.getState=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
715 |
{return this.currentState;};Spry.Data.Region.prototype.mapState=function(stateName,newStateName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
716 |
{this.stateMap[stateName]=newStateName;};Spry.Data.Region.prototype.getMappedState=function(stateName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
717 |
{var mappedState=this.stateMap[stateName];return mappedState?mappedState:stateName;};Spry.Data.Region.prototype.setState=function(stateName,suppressNotfications) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
718 |
{var stateObj={state:stateName,mappedState:this.getMappedState(stateName)};if(!suppressNotfications) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
719 |
Spry.Data.Region.notifyObservers("onPreStateChange",this,stateObj);this.currentState=stateObj.mappedState?stateObj.mappedState:stateName;if(this.states[stateName]) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
720 |
{var notificationData={state:this.currentState};if(!suppressNotfications) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
721 |
Spry.Data.Region.notifyObservers("onPreUpdate",this,notificationData);var str=this.transform();if(Spry.Data.Region.debug) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
722 |
Spry.Debug.trace("<hr />Generated region markup for '"+this.name+"':<br /><br />"+Spry.Utils.encodeEntities(str));Spry.Utils.setInnerHTML(this.regionNode,str,!Spry.Data.Region.evalScripts);if(this.hasBehaviorAttributes) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
723 |
this.attachBehaviors();if(!suppressNotfications) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
724 |
Spry.Data.Region.notifyObservers("onPostUpdate",this,notificationData);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
725 |
if(!suppressNotfications) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
726 |
Spry.Data.Region.notifyObservers("onPostStateChange",this,stateObj);};Spry.Data.Region.prototype.getDataSets=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
727 |
{return this.dataSets;};Spry.Data.Region.prototype.addDataSet=function(aDataSet) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
728 |
{if(!aDataSet) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
729 |
return;if(!this.dataSets) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
730 |
this.dataSets=new Array;for(var i=0;i<this.dataSets.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
731 |
{if(this.dataSets[i]==aDataSet) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
732 |
return;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
733 |
this.dataSets.push(aDataSet);aDataSet.addObserver(this);};Spry.Data.Region.prototype.removeDataSet=function(aDataSet) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
734 |
{if(!aDataSet||this.dataSets) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
735 |
return;for(var i=0;i<this.dataSets.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
736 |
{if(this.dataSets[i]==aDataSet) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
737 |
{this.dataSets.splice(i,1);aDataSet.removeObserver(this);return;}}};Spry.Data.Region.prototype.onPreLoad=function(dataSet) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
738 |
{if(this.currentState!="loading") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
739 |
this.setState("loading");};Spry.Data.Region.prototype.onLoadError=function(dataSet) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
740 |
{if(this.currentState!="error") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
741 |
this.setState("error");Spry.Data.Region.notifyObservers("onError",this);};Spry.Data.Region.prototype.onSessionExpired=function(dataSet) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
742 |
{if(this.currentState!="expired") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
743 |
this.setState("expired");Spry.Data.Region.notifyObservers("onExpired",this);};Spry.Data.Region.prototype.onCurrentRowChanged=function(dataSet,data) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
744 |
{if(this.isDetailRegion) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
745 |
this.updateContent();};Spry.Data.Region.prototype.onPostSort=function(dataSet,data) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
746 |
{this.updateContent();};Spry.Data.Region.prototype.onDataChanged=function(dataSet,data) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
747 |
{this.updateContent();};Spry.Data.Region.enableBehaviorAttributes=true;Spry.Data.Region.behaviorAttrs={};Spry.Data.Region.behaviorAttrs["spry:select"]={attach:function(rgn,node,value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
748 |
{var selectGroupName=null;try{selectGroupName=node.attributes.getNamedItem("spry:selectgroup").value;}catch(e){} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
749 |
if(!selectGroupName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
750 |
selectGroupName="default";Spry.Utils.addEventListener(node,"click",function(event){Spry.Utils.SelectionManager.select(selectGroupName,node,value);},false);if(node.attributes.getNamedItem("spry:selected")) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
751 |
Spry.Utils.SelectionManager.select(selectGroupName,node,value);}};Spry.Data.Region.behaviorAttrs["spry:hover"]={attach:function(rgn,node,value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
752 |
{Spry.Utils.addEventListener(node,"mouseover",function(event){Spry.Utils.addClassName(node,value);},false);Spry.Utils.addEventListener(node,"mouseout",function(event){Spry.Utils.removeClassName(node,value);},false);}};Spry.Data.Region.setUpRowNumberForEvenOddAttr=function(node,attr,value,rowNumAttrName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
753 |
{if(!value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
754 |
{Spry.Debug.showError("The "+attr+" attribute requires a CSS class name as its value!");node.attributes.removeNamedItem(attr);return;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
755 |
var dsName="";var valArr=value.split(/\s/);if(valArr.length>1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
756 |
{dsName=valArr[0];node.setAttribute(attr,valArr[1]);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
757 |
node.setAttribute(rowNumAttrName,"{"+(dsName?(dsName+"::"):"")+"ds_RowNumber}");};Spry.Data.Region.behaviorAttrs["spry:even"]={setup:function(node,value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
758 |
{Spry.Data.Region.setUpRowNumberForEvenOddAttr(node,"spry:even",value,"spryevenrownumber");},attach:function(rgn,node,value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
759 |
{if(value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
760 |
{rowNumAttr=node.attributes.getNamedItem("spryevenrownumber");if(rowNumAttr&&rowNumAttr.value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
761 |
{var rowNum=parseInt(rowNumAttr.value);if(rowNum%2) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
762 |
Spry.Utils.addClassName(node,value);}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
763 |
node.removeAttribute("spry:even");node.removeAttribute("spryevenrownumber");}};Spry.Data.Region.behaviorAttrs["spry:odd"]={setup:function(node,value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
764 |
{Spry.Data.Region.setUpRowNumberForEvenOddAttr(node,"spry:odd",value,"spryoddrownumber");},attach:function(rgn,node,value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
765 |
{if(value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
766 |
{rowNumAttr=node.attributes.getNamedItem("spryoddrownumber");if(rowNumAttr&&rowNumAttr.value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
767 |
{var rowNum=parseInt(rowNumAttr.value);if(rowNum%2==0) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
768 |
Spry.Utils.addClassName(node,value);}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
769 |
node.removeAttribute("spry:odd");node.removeAttribute("spryoddrownumber");}};Spry.Data.Region.setRowAttrClickHandler=function(node,dsName,rowAttr,funcName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
770 |
{if(dsName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
771 |
{var ds=Spry.Data.getDataSetByName(dsName);if(ds) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
772 |
{rowIDAttr=node.attributes.getNamedItem(rowAttr);if(rowIDAttr) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
773 |
{var rowAttrVal=rowIDAttr.value;if(rowAttrVal) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
774 |
Spry.Utils.addEventListener(node,"click",function(event){ds[funcName](rowAttrVal);},false);}}}};Spry.Data.Region.behaviorAttrs["spry:setrow"]={setup:function(node,value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
775 |
{if(!value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
776 |
{Spry.Debug.reportError("The spry:setrow attribute requires a data set name as its value!");node.removeAttribute("spry:setrow");return;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
777 |
node.setAttribute("spryrowid","{"+value+"::ds_RowID}");},attach:function(rgn,node,value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
778 |
{Spry.Data.Region.setRowAttrClickHandler(node,value,"spryrowid","setCurrentRow");node.removeAttribute("spry:setrow");node.removeAttribute("spryrowid");}};Spry.Data.Region.behaviorAttrs["spry:setrownumber"]={setup:function(node,value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
779 |
{if(!value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
780 |
{Spry.Debug.reportError("The spry:setrownumber attribute requires a data set name as its value!");node.removeAttribute("spry:setrownumber");return;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
781 |
node.setAttribute("spryrownumber","{"+value+"::ds_RowID}");},attach:function(rgn,node,value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
782 |
{Spry.Data.Region.setRowAttrClickHandler(node,value,"spryrownumber","setCurrentRowNumber");node.removeAttribute("spry:setrownumber");node.removeAttribute("spryrownumber");}};Spry.Data.Region.behaviorAttrs["spry:sort"]={attach:function(rgn,node,value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
783 |
{if(!value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
784 |
return;var ds=rgn.getDataSets()[0];var sortOrder="toggle";var colArray=value.split(/\s/);if(colArray.length>1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
785 |
{var specifiedDS=Spry.Data.getDataSetByName(colArray[0]);if(specifiedDS) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
786 |
{ds=specifiedDS;colArray.shift();} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
787 |
if(colArray.length>1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
788 |
{var str=colArray[colArray.length-1];if(str=="ascending"||str=="descending"||str=="toggle") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
789 |
{sortOrder=str;colArray.pop();}}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
790 |
if(ds&&colArray.length>0) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
791 |
Spry.Utils.addEventListener(node,"click",function(event){ds.sort(colArray,sortOrder);},false);node.removeAttribute("spry:sort");}};Spry.Data.Region.prototype.attachBehaviors=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
792 |
{var rgn=this;Spry.Utils.getNodesByFunc(this.regionNode,function(node) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
793 |
{if(!node||node.nodeType!=1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
794 |
return false;try |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
795 |
{var bAttrs=Spry.Data.Region.behaviorAttrs;for(var bAttrName in bAttrs) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
796 |
{var attr=node.attributes.getNamedItem(bAttrName);if(attr) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
797 |
{var behavior=bAttrs[bAttrName];if(behavior&&behavior.attach) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
798 |
behavior.attach(rgn,node,attr.value);}}}catch(e){} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
799 |
return false;});};Spry.Data.Region.prototype.updateContent=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
800 |
{var allDataSetsReady=true;var dsArray=this.getDataSets();if(!dsArray||dsArray.length<1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
801 |
{Spry.Debug.reportError("updateContent(): Region '"+this.name+"' has no data set!\n");return;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
802 |
for(var i=0;i<dsArray.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
803 |
{var ds=dsArray[i];if(ds) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
804 |
{if(ds.getLoadDataRequestIsPending()) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
805 |
allDataSetsReady=false;else if(!ds.getDataWasLoaded()) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
806 |
{ds.loadData();allDataSetsReady=false;}}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
807 |
if(!allDataSetsReady) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
808 |
{Spry.Data.Region.notifyObservers("onLoadingData",this);return;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
809 |
this.setState("ready");};Spry.Data.Region.prototype.clearContent=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
810 |
{this.regionNode.innerHTML="";};Spry.Data.Region.processContentPI=function(inStr) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
811 |
{var outStr="";var regexp=/<!--\s*<\/?spry:content\s*[^>]*>\s*-->/mg;var searchStartIndex=0;var processingContentTag=0;while(inStr.length) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
812 |
{var results=regexp.exec(inStr);if(!results||!results[0]) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
813 |
{outStr+=inStr.substr(searchStartIndex,inStr.length-searchStartIndex);break;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
814 |
if(!processingContentTag&&results.index!=searchStartIndex) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
815 |
{outStr+=inStr.substr(searchStartIndex,results.index-searchStartIndex);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
816 |
if(results[0].search(/<\//)!=-1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
817 |
{--processingContentTag;if(processingContentTag) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
818 |
Spry.Debug.reportError("Nested spry:content regions are not allowed!\n");} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
819 |
else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
820 |
{++processingContentTag;var dataRefStr=results[0].replace(/.*\bdataref="/,"");outStr+=dataRefStr.replace(/".*$/,"");} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
821 |
searchStartIndex=regexp.lastIndex;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
822 |
return outStr;};Spry.Data.Region.prototype.tokenizeData=function(dataStr) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
823 |
{if(!dataStr) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
824 |
return null;var rootToken=new Spry.Data.Region.Token(Spry.Data.Region.Token.LIST_TOKEN,null,null,null);var tokenStack=new Array;var parseStr=Spry.Data.Region.processContentPI(dataStr);tokenStack.push(rootToken);var regexp=/((<!--\s*){0,1}<\/{0,1}spry:[^>]+>(\s*-->){0,1})|((\{|%7[bB])[^\}\s%]+(\}|%7[dD]))/mg;var searchStartIndex=0;while(parseStr.length) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
825 |
{var results=regexp.exec(parseStr);var token=null;if(!results||!results[0]) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
826 |
{var str=parseStr.substr(searchStartIndex,parseStr.length-searchStartIndex);token=new Spry.Data.Region.Token(Spry.Data.Region.Token.STRING_TOKEN,null,str,str);tokenStack[tokenStack.length-1].addChild(token);break;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
827 |
if(results.index!=searchStartIndex) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
828 |
{var str=parseStr.substr(searchStartIndex,results.index-searchStartIndex);token=new Spry.Data.Region.Token(Spry.Data.Region.Token.STRING_TOKEN,null,str,str);tokenStack[tokenStack.length-1].addChild(token);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
829 |
if(results[0].search(/^({|%7[bB])/)!=-1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
830 |
{var valueName=results[0];var regionStr=results[0];valueName=valueName.replace(/^({|%7[bB])/,"");valueName=valueName.replace(/(}|%7[dD])$/,"");var dataSetName=null;var splitArray=valueName.split(/::/);if(splitArray.length>1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
831 |
{dataSetName=splitArray[0];valueName=splitArray[1];} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
832 |
regionStr=regionStr.replace(/^%7[bB]/,"{");regionStr=regionStr.replace(/%7[dD]$/,"}");token=new Spry.Data.Region.Token(Spry.Data.Region.Token.VALUE_TOKEN,dataSetName,valueName,new String(regionStr));tokenStack[tokenStack.length-1].addChild(token);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
833 |
else if(results[0].charAt(0)=='<') |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
834 |
{var piName=results[0].replace(/^(<!--\s*){0,1}<\/?/,"");piName=piName.replace(/>(\s*-->){0,1}|\s.*$/,"");if(results[0].search(/<\//)!=-1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
835 |
{if(tokenStack[tokenStack.length-1].tokenType!=Spry.Data.Region.Token.PROCESSING_INSTRUCTION_TOKEN) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
836 |
{Spry.Debug.reportError("Invalid processing instruction close tag: "+piName+" -- "+results[0]+"\n");return null;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
837 |
tokenStack.pop();} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
838 |
else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
839 |
{var piDesc=Spry.Data.Region.PI.instructions[piName];if(piDesc) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
840 |
{var dataSet=null;var selectedDataSetName="";if(results[0].search(/^.*\bselect=\"/)!=-1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
841 |
{selectedDataSetName=results[0].replace(/^.*\bselect=\"/,"");selectedDataSetName=selectedDataSetName.replace(/".*$/,"");if(selectedDataSetName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
842 |
{dataSet=Spry.Data.getDataSetByName(selectedDataSetName);if(!dataSet) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
843 |
{Spry.Debug.reportError("Failed to retrieve data set ("+selectedDataSetName+") for "+piName+"\n");selectedDataSetName="";}}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
844 |
var jsExpr=null;if(results[0].search(/^.*\btest=\"/)!=-1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
845 |
{jsExpr=results[0].replace(/^.*\btest=\"/,"");jsExpr=jsExpr.replace(/".*$/,"");jsExpr=Spry.Utils.decodeEntities(jsExpr);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
846 |
var regionState=null;if(results[0].search(/^.*\bname=\"/)!=-1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
847 |
{regionState=results[0].replace(/^.*\bname=\"/,"");regionState=regionState.replace(/".*$/,"");regionState=Spry.Utils.decodeEntities(regionState);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
848 |
var piData=new Spry.Data.Region.Token.PIData(piName,selectedDataSetName,jsExpr,regionState);token=new Spry.Data.Region.Token(Spry.Data.Region.Token.PROCESSING_INSTRUCTION_TOKEN,dataSet,piData,new String(results[0]));tokenStack[tokenStack.length-1].addChild(token);tokenStack.push(token);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
849 |
else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
850 |
{Spry.Debug.reportError("Unsupported region processing instruction: "+results[0]+"\n");return null;}}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
851 |
else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
852 |
{Spry.Debug.reportError("Invalid region token: "+results[0]+"\n");return null;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
853 |
searchStartIndex=regexp.lastIndex;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
854 |
return rootToken;};Spry.Data.Region.prototype.callScriptFunction=function(funcName,processContext) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
855 |
{var result=undefined;funcName=funcName.replace(/^\s*\{?\s*function::\s*|\s*\}?\s*$/g,"");var func=Spry.Utils.getObjectByName(funcName);if(func) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
856 |
result=func(this.name,function(){return processContext.getValueFromDataSet.apply(processContext,arguments);});return result;};Spry.Data.Region.prototype.evaluateExpression=function(exprStr,processContext) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
857 |
{var result=undefined;try |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
858 |
{if(exprStr.search(/^\s*function::/)!=-1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
859 |
result=this.callScriptFunction(exprStr,processContext);else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
860 |
result=Spry.Utils.eval(Spry.Data.Region.processDataRefString(processContext,exprStr,null,true));} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
861 |
catch(e) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
862 |
{Spry.Debug.trace("Caught exception in Spry.Data.Region.prototype.evaluateExpression() while evaluating: "+Spry.Utils.encodeEntities(exprStr)+"\n Exception:"+e+"\n");} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
863 |
return result;};Spry.Data.Region.prototype.processTokenChildren=function(outputArr,token,processContext) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
864 |
{var children=token.children;var len=children.length;for(var i=0;i<len;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
865 |
this.processTokens(outputArr,children[i],processContext);};Spry.Data.Region.prototype.processTokens=function(outputArr,token,processContext) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
866 |
{var i=0;switch(token.tokenType) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
867 |
{case Spry.Data.Region.Token.LIST_TOKEN:this.processTokenChildren(outputArr,token,processContext);break;case Spry.Data.Region.Token.STRING_TOKEN:outputArr.push(token.data);break;case Spry.Data.Region.Token.PROCESSING_INSTRUCTION_TOKEN:if(token.data.name=="spry:repeat") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
868 |
{var dataSet=null;if(token.dataSet) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
869 |
dataSet=token.dataSet;else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
870 |
dataSet=this.dataSets[0];if(dataSet) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
871 |
{var dsContext=processContext.getDataSetContext(dataSet);if(!dsContext) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
872 |
{Spry.Debug.reportError("processTokens() failed to get a data set context!\n");break;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
873 |
dsContext.pushState();var dataSetRows=dsContext.getData();var numRows=dataSetRows.length;for(i=0;i<numRows;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
874 |
{dsContext.setRowIndex(i);var testVal=true;if(token.data.jsExpr) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
875 |
testVal=this.evaluateExpression(token.data.jsExpr,processContext);if(testVal) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
876 |
this.processTokenChildren(outputArr,token,processContext);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
877 |
dsContext.popState();}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
878 |
else if(token.data.name=="spry:if") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
879 |
{var testVal=true;if(token.data.jsExpr) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
880 |
testVal=this.evaluateExpression(token.data.jsExpr,processContext);if(testVal) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
881 |
this.processTokenChildren(outputArr,token,processContext);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
882 |
else if(token.data.name=="spry:choose") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
883 |
{var defaultChild=null;var childToProcess=null;var testVal=false;var j=0;for(j=0;j<token.children.length;j++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
884 |
{var child=token.children[j];if(child.tokenType==Spry.Data.Region.Token.PROCESSING_INSTRUCTION_TOKEN) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
885 |
{if(child.data.name=="spry:when") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
886 |
{if(child.data.jsExpr) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
887 |
{testVal=this.evaluateExpression(child.data.jsExpr,processContext);if(testVal) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
888 |
{childToProcess=child;break;}}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
889 |
else if(child.data.name=="spry:default") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
890 |
defaultChild=child;}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
891 |
if(!childToProcess&&defaultChild) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
892 |
childToProcess=defaultChild;if(childToProcess) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
893 |
this.processTokenChildren(outputArr,childToProcess,processContext);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
894 |
else if(token.data.name=="spry:state") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
895 |
{var testVal=true;if(!token.data.regionState||token.data.regionState==this.currentState) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
896 |
this.processTokenChildren(outputArr,token,processContext);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
897 |
else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
898 |
{Spry.Debug.reportError("processTokens(): Unknown processing instruction: "+token.data.name+"\n");return"";} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
899 |
break;case Spry.Data.Region.Token.VALUE_TOKEN:var dataSet=token.dataSet;var val=undefined;if(dataSet&&dataSet=="function") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
900 |
{val=this.callScriptFunction(token.data,processContext);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
901 |
else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
902 |
{if(!dataSet&&this.dataSets&&this.dataSets.length>0&&this.dataSets[0]) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
903 |
{dataSet=this.dataSets[0];} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
904 |
if(!dataSet) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
905 |
{Spry.Debug.reportError("processTokens(): Value reference has no data set specified: "+token.regionStr+"\n");return"";} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
906 |
val=processContext.getValueFromDataSet(dataSet,token.data);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
907 |
if(typeof val!="undefined") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
908 |
outputArr.push(val+"");break;default:Spry.Debug.reportError("processTokens(): Invalid token type: "+token.regionStr+"\n");break;}};Spry.Data.Region.prototype.transform=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
909 |
{if(this.data&&!this.tokens) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
910 |
this.tokens=this.tokenizeData(this.data);if(!this.tokens) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
911 |
return"";processContext=new Spry.Data.Region.ProcessingContext(this);if(!processContext) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
912 |
return"";var outputArr=[""];this.processTokens(outputArr,this.tokens,processContext);return outputArr.join("");};Spry.Data.Region.PI={};Spry.Data.Region.PI.instructions={};Spry.Data.Region.PI.buildOpenTagForValueAttr=function(ele,piName,attrName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
913 |
{if(!ele||!piName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
914 |
return"";var jsExpr="";try |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
915 |
{var testAttr=ele.attributes.getNamedItem(piName);if(testAttr&&testAttr.value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
916 |
jsExpr=Spry.Utils.encodeEntities(testAttr.value);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
917 |
catch(e){jsExpr="";} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
918 |
if(!jsExpr) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
919 |
{Spry.Debug.reportError(piName+" attribute requires a JavaScript expression that returns true or false!\n");return"";} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
920 |
return"<"+Spry.Data.Region.PI.instructions[piName].tagName+" "+attrName+"=\""+jsExpr+"\">";};Spry.Data.Region.PI.buildOpenTagForTest=function(ele,piName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
921 |
{return Spry.Data.Region.PI.buildOpenTagForValueAttr(ele,piName,"test");};Spry.Data.Region.PI.buildOpenTagForState=function(ele,piName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
922 |
{return Spry.Data.Region.PI.buildOpenTagForValueAttr(ele,piName,"name");};Spry.Data.Region.PI.buildOpenTagForRepeat=function(ele,piName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
923 |
{if(!ele||!piName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
924 |
return"";var selectAttrStr="";try |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
925 |
{var selectAttr=ele.attributes.getNamedItem(piName);if(selectAttr&&selectAttr.value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
926 |
{selectAttrStr=selectAttr.value;selectAttrStr=selectAttrStr.replace(/\s/g,"");}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
927 |
catch(e){selectAttrStr="";} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
928 |
if(!selectAttrStr) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
929 |
{Spry.Debug.reportError(piName+" attribute requires a data set name!\n");return"";} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
930 |
var testAttrStr="";try |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
931 |
{var testAttr=ele.attributes.getNamedItem("spry:test");if(testAttr) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
932 |
{if(testAttr.value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
933 |
testAttrStr=" test=\""+Spry.Utils.encodeEntities(testAttr.value)+"\"";ele.attributes.removeNamedItem(testAttr.nodeName);}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
934 |
catch(e){testAttrStr="";} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
935 |
return"<"+Spry.Data.Region.PI.instructions[piName].tagName+" select=\""+selectAttrStr+"\""+testAttrStr+">";};Spry.Data.Region.PI.buildOpenTagForContent=function(ele,piName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
936 |
{if(!ele||!piName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
937 |
return"";var dataRefStr="";try |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
938 |
{var contentAttr=ele.attributes.getNamedItem(piName);if(contentAttr&&contentAttr.value) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
939 |
dataRefStr=Spry.Utils.encodeEntities(contentAttr.value);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
940 |
catch(e){dataRefStr="";} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
941 |
if(!dataRefStr) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
942 |
{Spry.Debug.reportError(piName+" attribute requires a data reference!\n");return"";} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
943 |
return"<"+Spry.Data.Region.PI.instructions[piName].tagName+" dataref=\""+dataRefStr+"\">";};Spry.Data.Region.PI.buildOpenTag=function(ele,piName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
944 |
{return"<"+Spry.Data.Region.PI.instructions[piName].tagName+">";};Spry.Data.Region.PI.buildCloseTag=function(ele,piName) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
945 |
{return"</"+Spry.Data.Region.PI.instructions[piName].tagName+">";};Spry.Data.Region.PI.instructions["spry:state"]={tagName:"spry:state",childrenOnly:false,getOpenTag:Spry.Data.Region.PI.buildOpenTagForState,getCloseTag:Spry.Data.Region.PI.buildCloseTag};Spry.Data.Region.PI.instructions["spry:if"]={tagName:"spry:if",childrenOnly:false,getOpenTag:Spry.Data.Region.PI.buildOpenTagForTest,getCloseTag:Spry.Data.Region.PI.buildCloseTag};Spry.Data.Region.PI.instructions["spry:repeat"]={tagName:"spry:repeat",childrenOnly:false,getOpenTag:Spry.Data.Region.PI.buildOpenTagForRepeat,getCloseTag:Spry.Data.Region.PI.buildCloseTag};Spry.Data.Region.PI.instructions["spry:repeatchildren"]={tagName:"spry:repeat",childrenOnly:true,getOpenTag:Spry.Data.Region.PI.buildOpenTagForRepeat,getCloseTag:Spry.Data.Region.PI.buildCloseTag};Spry.Data.Region.PI.instructions["spry:choose"]={tagName:"spry:choose",childrenOnly:true,getOpenTag:Spry.Data.Region.PI.buildOpenTag,getCloseTag:Spry.Data.Region.PI.buildCloseTag};Spry.Data.Region.PI.instructions["spry:when"]={tagName:"spry:when",childrenOnly:false,getOpenTag:Spry.Data.Region.PI.buildOpenTagForTest,getCloseTag:Spry.Data.Region.PI.buildCloseTag};Spry.Data.Region.PI.instructions["spry:default"]={tagName:"spry:default",childrenOnly:false,getOpenTag:Spry.Data.Region.PI.buildOpenTag,getCloseTag:Spry.Data.Region.PI.buildCloseTag};Spry.Data.Region.PI.instructions["spry:content"]={tagName:"spry:content",childrenOnly:true,getOpenTag:Spry.Data.Region.PI.buildOpenTagForContent,getCloseTag:Spry.Data.Region.PI.buildCloseTag};Spry.Data.Region.PI.orderedInstructions=["spry:state","spry:if","spry:repeat","spry:repeatchildren","spry:choose","spry:when","spry:default","spry:content"];Spry.Data.Region.getTokensFromStr=function(str) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
946 |
{if(!str) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
947 |
return null;return str.match(/{[^}]+}/g);};Spry.Data.Region.processDataRefString=function(processingContext,regionStr,dataSetsToUse,isJSExpr) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
948 |
{if(!regionStr) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
949 |
return"";if(!processingContext&&!dataSetsToUse) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
950 |
return regionStr;var resultStr="";var re=new RegExp("\\{([^\\}:]+::)?[^\\}]+\\}","g");var startSearchIndex=0;while(startSearchIndex<regionStr.length) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
951 |
{var reArray=re.exec(regionStr);if(!reArray||!reArray[0]) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
952 |
{resultStr+=regionStr.substr(startSearchIndex,regionStr.length-startSearchIndex);return resultStr;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
953 |
if(reArray.index!=startSearchIndex) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
954 |
resultStr+=regionStr.substr(startSearchIndex,reArray.index-startSearchIndex);var dsName="";if(reArray[0].search(/^\{[^}:]+::/)!=-1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
955 |
dsName=reArray[0].replace(/^\{|::.*/g,"");var fieldName=reArray[0].replace(/^\{|.*::|\}/g,"");var row=null;var val="";if(processingContext) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
956 |
val=processingContext.getValueFromDataSet(dsName,fieldName);else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
957 |
{var ds=dsName?dataSetsToUse[dsName]:dataSetsToUse[0];if(ds) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
958 |
val=ds.getValue(fieldName);} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
959 |
if(typeof val!="undefined") |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
960 |
{val+="";resultStr+=isJSExpr?Spry.Utils.escapeQuotesAndLineBreaks(val):val;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
961 |
if(startSearchIndex==re.lastIndex) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
962 |
{var leftOverIndex=reArray.index+reArray[0].length;if(leftOverIndex<regionStr.length) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
963 |
resultStr+=regionStr.substr(leftOverIndex);break;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
964 |
startSearchIndex=re.lastIndex;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
965 |
return resultStr;};Spry.Data.Region.strToDataSetsArray=function(str,returnRegionNames) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
966 |
{var dataSetsArr=new Array;var foundHash={};if(!str) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
967 |
return dataSetsArr;str=str.replace(/\s+/g," ");str=str.replace(/^\s|\s$/g,"");var arr=str.split(/ /);for(var i=0;i<arr.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
968 |
{if(arr[i]&&!Spry.Data.Region.PI.instructions[arr[i]]) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
969 |
{try{var dataSet=Spry.Data.getDataSetByName(arr[i]);if(!foundHash[arr[i]]) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
970 |
{if(returnRegionNames) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
971 |
dataSetsArr.push(arr[i]);else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
972 |
dataSetsArr.push(dataSet);foundHash[arr[i]]=true;}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
973 |
catch(e){}}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
974 |
return dataSetsArr;};Spry.Data.Region.DSContext=function(dataSet,processingContext) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
975 |
{var m_dataSet=dataSet;var m_processingContext=processingContext;var m_curRowIndexArray=[{rowIndex:-1}];var m_parent=null;var m_children=[];var getInternalRowIndex=function(){return m_curRowIndexArray[m_curRowIndexArray.length-1].rowIndex;};this.resetAll=function(){m_curRowIndexArray=[{rowIndex:m_dataSet.getCurrentRow()}]};this.getDataSet=function(){return m_dataSet;};this.getNumRows=function(unfiltered) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
976 |
{var data=this.getCurrentState().data;return data?data.length:m_dataSet.getRowCount(unfiltered);};this.getData=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
977 |
{var data=this.getCurrentState().data;return data?data:m_dataSet.getData();};this.setData=function(data) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
978 |
{this.getCurrentState().data=data;};this.getValue=function(valueName,rowContext) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
979 |
{var result="";var curState=this.getCurrentState();var ds=curState.nestedDS?curState.nestedDS:this.getDataSet();if(ds) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
980 |
result=ds.getValue(valueName,rowContext);return result;};this.getCurrentRow=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
981 |
{if(m_curRowIndexArray.length<2||getInternalRowIndex()<0) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
982 |
return m_dataSet.getCurrentRow();var data=this.getData();var curRowIndex=getInternalRowIndex();if(curRowIndex<0||curRowIndex>data.length) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
983 |
{Spry.Debug.reportError("Invalid index used in Spry.Data.Region.DSContext.getCurrentRow()!\n");return null;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
984 |
return data[curRowIndex];};this.getRowIndex=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
985 |
{var curRowIndex=getInternalRowIndex();if(curRowIndex>=0) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
986 |
return curRowIndex;return m_dataSet.getRowNumber(m_dataSet.getCurrentRow());};this.setRowIndex=function(rowIndex) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
987 |
{this.getCurrentState().rowIndex=rowIndex;var data=this.getData();var numChildren=m_children.length;for(var i=0;i<numChildren;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
988 |
m_children[i].syncDataWithParentRow(this,rowIndex,data);};this.syncDataWithParentRow=function(parentDSContext,rowIndex,parentData) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
989 |
{var row=parentData[rowIndex];if(row) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
990 |
{nestedDS=m_dataSet.getNestedDataSetForParentRow(row);if(nestedDS) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
991 |
{var currentState=this.getCurrentState();currentState.nestedDS=nestedDS;currentState.data=nestedDS.getData();currentState.rowIndex=nestedDS.getCurrentRowNumber();currentState.rowIndex=currentState.rowIndex<0?0:currentState.rowIndex;var numChildren=m_children.length;for(var i=0;i<numChildren;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
992 |
m_children[i].syncDataWithParentRow(this,currentState.rowIndex,currentState.data);}}};this.pushState=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
993 |
{var curState=this.getCurrentState();var newState=new Object;newState.rowIndex=curState.rowIndex;newState.data=curState.data;newState.nestedDS=curState.nestedDS;m_curRowIndexArray.push(newState);var numChildren=m_children.length;for(var i=0;i<numChildren;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
994 |
m_children[i].pushState();};this.popState=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
995 |
{if(m_curRowIndexArray.length<2) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
996 |
{Spry.Debug.reportError("Stack underflow in Spry.Data.Region.DSContext.popState()!\n");return;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
997 |
var numChildren=m_children.length;for(var i=0;i<numChildren;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
998 |
m_children[i].popState();m_curRowIndexArray.pop();};this.getCurrentState=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
999 |
{return m_curRowIndexArray[m_curRowIndexArray.length-1];};this.addChild=function(childDSContext) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1000 |
{var numChildren=m_children.length;for(var i=0;i<numChildren;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1001 |
{if(m_children[i]==childDSContext) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1002 |
return;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1003 |
m_children.push(childDSContext);};};Spry.Data.Region.ProcessingContext=function(region) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1004 |
{this.region=region;this.dataSetContexts=[];if(region&®ion.dataSets) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1005 |
{var dsArray=region.dataSets.slice(0);var dsArrayLen=dsArray.length;for(var i=0;i<dsArrayLen;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1006 |
{var ds=region.dataSets[i];while(ds&&ds.getParentDataSet) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1007 |
{var doesExist=false;ds=ds.getParentDataSet();if(ds&&this.indexOf(dsArray,ds)==-1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1008 |
dsArray.push(ds);}} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1009 |
for(i=0;i<dsArray.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1010 |
this.dataSetContexts.push(new Spry.Data.Region.DSContext(dsArray[i],this));var dsContexts=this.dataSetContexts;var numDSContexts=dsContexts.length;for(i=0;i<numDSContexts;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1011 |
{var dsc=dsContexts[i];var ds=dsc.getDataSet();if(ds.getParentDataSet) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1012 |
{var parentDS=ds.getParentDataSet();if(parentDS) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1013 |
{var pdsc=this.getDataSetContext(parentDS);if(pdsc)pdsc.addChild(dsc);}}}}};Spry.Data.Region.ProcessingContext.prototype.indexOf=function(arr,item) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1014 |
{if(arr) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1015 |
{var arrLen=arr.length;for(var i=0;i<arrLen;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1016 |
if(arr[i]==item) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1017 |
return i;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1018 |
return-1;};Spry.Data.Region.ProcessingContext.prototype.getDataSetContext=function(dataSet) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1019 |
{if(!dataSet) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1020 |
{if(this.dataSetContexts.length>0) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1021 |
return this.dataSetContexts[0];return null;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1022 |
if(typeof dataSet=='string') |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1023 |
{dataSet=Spry.Data.getDataSetByName(dataSet);if(!dataSet) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1024 |
return null;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1025 |
for(var i=0;i<this.dataSetContexts.length;i++) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1026 |
{var dsc=this.dataSetContexts[i];if(dsc.getDataSet()==dataSet) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1027 |
return dsc;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1028 |
return null;};Spry.Data.Region.ProcessingContext.prototype.getValueFromDataSet=function() |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1029 |
{var dsName="";var columnName="";if(arguments.length>1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1030 |
{dsName=arguments[0];columnName=arguments[1];} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1031 |
else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1032 |
{var dataRef=arguments[0].replace(/\s*{\s*|\s*}\s*/g,"");if(dataRef.search("::")!=-1) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1033 |
{dsName=dataRef.replace(/::.*/,"");columnName=dataRef.replace(/.*::/,"");} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1034 |
else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1035 |
columnName=dataRef;} |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1036 |
var result="";var dsContext=this.getDataSetContext(dsName);if(dsContext) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1037 |
result=dsContext.getValue(columnName,dsContext.getCurrentRow());else |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1038 |
Spry.Debug.reportError("getValueFromDataSet: Failed to get "+dsName+" context for the "+this.region.regionNode.id+" region.\n");return result;};Spry.Data.Region.ProcessingContext.prototype.$v=Spry.Data.Region.ProcessingContext.prototype.getValueFromDataSet;Spry.Data.Region.ProcessingContext.prototype.getCurrentRowForDataSet=function(dataSet) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1039 |
{var dsc=this.getDataSetContext(dataSet);if(dsc) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1040 |
return dsc.getCurrentRow();return null;};Spry.Data.Region.Token=function(tokenType,dataSet,data,regionStr) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1041 |
{var self=this;this.tokenType=tokenType;this.dataSet=dataSet;this.data=data;this.regionStr=regionStr;this.parent=null;this.children=null;};Spry.Data.Region.Token.prototype.addChild=function(child) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1042 |
{if(!child) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1043 |
return;if(!this.children) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1044 |
this.children=new Array;this.children.push(child);child.parent=this;};Spry.Data.Region.Token.LIST_TOKEN=0;Spry.Data.Region.Token.STRING_TOKEN=1;Spry.Data.Region.Token.PROCESSING_INSTRUCTION_TOKEN=2;Spry.Data.Region.Token.VALUE_TOKEN=3;Spry.Data.Region.Token.PIData=function(piName,data,jsExpr,regionState) |
5e8fd89c02ea
Initial progress towards converting auto-completion framework to Spry. Not currently in a very working state.
Dan
parents:
diff
changeset
|
1045 |
{var self=this;this.name=piName;this.data=data;this.jsExpr=jsExpr;this.regionState=regionState;};Spry.Utils.addLoadListener(function(){setTimeout(function(){if(Spry.Data.initRegionsOnLoad)Spry.Data.initRegions();},0);}); |