[Checkins]
SVN: Sandbox/tlotze/z3c.formdemo-widgets/src/z3c/formdemo/
removed some unneeded files
Thomas Lotze
tl at gocept.com
Tue Sep 25 10:53:01 EDT 2007
Log message for revision 80013:
removed some unneeded files
Changed:
D Sandbox/tlotze/z3c.formdemo-widgets/src/z3c/formdemo/browser/table_sorted_header.pt
D Sandbox/tlotze/z3c.formdemo-widgets/src/z3c/formdemo/skin/img/
D Sandbox/tlotze/z3c.formdemo-widgets/src/z3c/formdemo/skin/json.js
D Sandbox/tlotze/z3c.formdemo-widgets/src/z3c/formdemo/skin/xmlhttp.js
-=-
Deleted: Sandbox/tlotze/z3c.formdemo-widgets/src/z3c/formdemo/browser/table_sorted_header.pt
===================================================================
--- Sandbox/tlotze/z3c.formdemo-widgets/src/z3c/formdemo/browser/table_sorted_header.pt 2007-09-25 14:41:53 UTC (rev 80012)
+++ Sandbox/tlotze/z3c.formdemo-widgets/src/z3c/formdemo/browser/table_sorted_header.pt 2007-09-25 14:53:01 UTC (rev 80013)
@@ -1,18 +0,0 @@
-<html tal:omit-tag="">
- <a href=""
- tal:attributes="href string:${request/URL}?sort-on=${options/name}"
- tal:content="options/header" />
- <span tal:condition="options/isSortedOn">
-
- </span>
- <img src="" width="7" height="4" style="vertical-align: middle"
- alt="sort ascending"
- tal:condition="options/isAscending"
- tal:attributes="src
- context/++resource++SpreadsheetImages/ascending.gif" />
- <img src="" width="7" height="4" style="vertical-align: middle"
- alt="sort ascending"
- tal:condition="options/isDecending"
- tal:attributes="src
- context/++resource++SpreadsheetImages/decending.gif" />
-</html>
Deleted: Sandbox/tlotze/z3c.formdemo-widgets/src/z3c/formdemo/skin/json.js
===================================================================
--- Sandbox/tlotze/z3c.formdemo-widgets/src/z3c/formdemo/skin/json.js 2007-09-25 14:41:53 UTC (rev 80012)
+++ Sandbox/tlotze/z3c.formdemo-widgets/src/z3c/formdemo/skin/json.js 2007-09-25 14:53:01 UTC (rev 80013)
@@ -1,212 +0,0 @@
-//----------------------------------------------------------------------------
-/**
- * @fileoverview JSON-RPC client implementation
- * @author Roger Ineichen roger at tiks.org
- * @version Initial, not documented
- */
-//----------------------------------------------------------------------------
-
-function JSONRPC(url) {
- this._url = url;
- this._methods = new Array();
- this._user = null;
- this._password = null;
-}
-
-function getJSONRPCProxy(url) {
- return new JSONRPC(url);
-}
-
-JSONRPC.prototype.addMethod = function(name, callback, requestId) {
- if (typeof(requestId) == 'undefined') {
- requestId = "jsonRequest";
- }
- var self = this;
- if(!self[name]){
- var method = new JSONRPCMethod(this._url, name, callback, requestId, this._user, this._password);
- self[name] = method;
- this._methods.push(method);
- }
-}
-
-JSONRPC.prototype.setAuthentication = function(user, pass) {
- this._user = user;
- this._password = pass;
- for(var i=0;i<this._methods.length;i++){
- this._methods[i].setAuthentication(user, pass);
- }
-}
-
-function JSONRPCMethod(url, methodName, callback, requestId, user, pass) {
- this.methodName = methodName;
- this.callback = callback;
- this.requestId = requestId;
- this.url = url;
- this.user = user;
- this.password = pass;
- var self = this;
-
- var fn = function(){
- var args = new Array();
- for(var i=0;i<arguments.length;i++){
- args.push(arguments[i]);
- }
- if(self.callback) {
- var data = self.jsonRequest(self.requestId, self.methodName, args);
- self.postData(self.url, self.user, self.password, data, function(resp){
- var res = null;
- var exc =null;
- try{
- res = self.handleResponse(resp);
- }catch(e){
- exc = e;
- }
- try{
- callback(res, self.requestId, exc);
- }catch(e){
- alert("except callback");
- }
- args = null;
- resp = null;
- });
- }
- else{
- var data = self.jsonRequest(self.requestId, self.methodName, args);
- var resp = self.postData(self.url, self.user, self.password, data);
- return self.handleResponse(resp);
- }
- }
- return fn;
-
-}
-
-JSONRPCMethod.prototype.postData = function(url, user, pass, data, callback) {
- var xmlhttp = new XMLHttp(url);
- var header = new Array()
- header["Content-Type"] = "application/json-rpc";
- xmlhttp.setHeaders(header);
- xmlhttp.user = user;
- xmlhttp.password = pass;
- xmlhttp.argString = data;
- if(callback == null){
- return xmlhttp.post();
- }else{
- xmlhttp.post(callback);
- }
-}
-
-JSONRPCMethod.prototype.jsonRequest = function(id, methodName, args){
- var ji = toJSON(id);
- var jm = toJSON(methodName);
- var ja = toJSON(args);
- return '{"id":' + ji + ', "method":' + jm + ', "params":' + ja + "}";
-}
-
-JSONRPCMethod.prototype.setAuthentication = function(user, pass){
- this.user = user;
- this.password = pass;
-}
-
-JSONRPCMethod.prototype.notify = function(){
- var args=new Array();
- for(var i=0;i<arguments.length;i++){
- args.push(arguments[i]);
- }
- var data = this.jsonRequest(null, this.methodName, args);
- this.postData(this.url, this.user, this.password, data, function(resp){});
-}
-
-JSONRPCMethod.prototype.handleResponse = function(resp){
- var status=null;
- try{
- status = resp.status;
- }catch(e){
- }
- if(status == 200){
- var respTxt = "";
- try{
- respTxt=resp.responseText;
- }catch(e){
- }
- if(respTxt == null || respTxt == ""){
- alert("The server responded with an empty document.");
- }else{
- var res = this.unmarshall(respTxt);
- if(res.error != null){
- alert("error " + res.error);
- }
- else if (res.requestId != self.requestId) {
- alert("wrong json id returned");
- }
- else{
- return res.result;
- }
- }
- }else{
- alert("error " + status);
- }
-}
-
-JSONRPCMethod.prototype.unmarshall = function(source){
- try {
- var obj;
- eval("obj=" + source);
- return obj;
- }catch(e){
- alert("The server's response could not be parsed.");
- }
-}
-
-function escapeJSONChar(c) {
- if(c == "\"" || c == "\\") return "\\" + c;
- else if (c == "\b") return "\\b";
- else if (c == "\f") return "\\f";
- else if (c == "\n") return "\\n";
- else if (c == "\r") return "\\r";
- else if (c == "\t") return "\\t";
- var hex = c.charCodeAt(0).toString(16);
- if(hex.length == 1) return "\\u000" + hex;
- else if(hex.length == 2) return "\\u00" + hex;
- else if(hex.length == 3) return "\\u0" + hex;
- else return "\\u" + hex;
-}
-
-function escapeJSONString(s) {
- var parts = s.split("");
- for(var i=0; i < parts.length; i++) {
- var c =parts[i];
- if(c == '"' ||
- c == '\\' ||
- c.charCodeAt(0) < 32 ||
- c.charCodeAt(0) >= 128)
- parts[i] = escapeJSONChar(parts[i]);
- }
- return "\"" + parts.join("") + "\"";
-}
-
-function toJSON(o) {
- if(o == null) {
- return "null";
- } else if(o.constructor == String) {
- return escapeJSONString(o);
- } else if(o.constructor == Number) {
- return o.toString();
- } else if(o.constructor == Boolean) {
- return o.toString();
- } else if(o.constructor == Date) {
- return o.valueOf().toString();
- } else if(o.constructor == Array) {
- var v = [];
- for(var i = 0; i < o.length; i++) v.push(toJSON(o[i]));
- return "[" + v.join(", ") + "]";
- }
- else {
- var v = [];
- for(attr in o) {
- if(o[attr] == null) v.push("\"" + attr + "\": null");
- else if(typeof o[attr] == "function"); // skip
- else v.push(escapeJSONString(attr) + ": " + toJSON(o[attr]));
- }
- return "{" + v.join(", ") + "}";
- }
-}
Deleted: Sandbox/tlotze/z3c.formdemo-widgets/src/z3c/formdemo/skin/xmlhttp.js
===================================================================
--- Sandbox/tlotze/z3c.formdemo-widgets/src/z3c/formdemo/skin/xmlhttp.js 2007-09-25 14:41:53 UTC (rev 80012)
+++ Sandbox/tlotze/z3c.formdemo-widgets/src/z3c/formdemo/skin/xmlhttp.js 2007-09-25 14:53:01 UTC (rev 80013)
@@ -1,309 +0,0 @@
-//----------------------------------------------------------------------------
-/**
- * @fileoverview Cross browser XMLHttpRequest implementation
- * Make sure the response set the Header to 'no-cache'.
- *
- * @author Roger Ineichen roger at tiks.org
- * @version Draft, not complete documented
- */
-//----------------------------------------------------------------------------
-
-//----------------------------------------------------------------------------
-// public API
-//----------------------------------------------------------------------------
-
-/**
- * Construct a new XMLHttp.
- * @class This is the basic XMLHttp class.
- * @constructor
- * @param {string} url URL pointing to the server
- * @return A new XMLHttp
- */
-function XMLHttp(url) {
- this.url = url;
- this.method = 'GET';
- this.async = false;
- this.username = null;
- this.password = null;
- this.timeout = null;
- this.argString = "";
- this.parameters = new Array();
- this.headers = new Array();
- this.headers['Content-Type'] = 'application/x-www-form-urlencoded'
-
- /* internal status flags */
- this.isAborted = false;
- this.isLoading = false;
- this.isLoaded = false;
- this.isInteractive = false;
- this.isComplete = false;
-
- /* event handlers (attached functions get called if readyState reached) */
- this.onLoading = null; // if readyState 1
- this.onLoaded = null; // if readyState 2
- this.onInteractive = null; // if readyState 3
- this.onComplete = null; // if readyState 4
- this.onError = null; // if readyState 4 and status != 200
- this.onTimeout = null; // if timeout reached
- this.callback = null; // if readyState 4 and status == 200
- this.callbackArgs = null;
-
- /* response variables */
- this.responseText = null;
- this.responseXML = null;
-
- /* setup the xmlhttp request now */
- this.xmlhttp = getXmlHttpRequest()
-}
-
-/**
- * Set the header information for the XMLHttp instance.
- * @param {array} args of key, value
- */
-XMLHttp.prototype.setHeaders = function(args) {
- for (var i in args) {
- this.headers[i] = args[i];
- }
-}
-
-/**
- * Set the arguments for the request or the XMLHttp instance.
- * @param {array} args of key, value
- */
-XMLHttp.prototype.setArguments = function(args) {
- for (var i in args) {
- // set parameter to the xmlhttp instance or to the parameter array
- if (typeof(this[i])=="undefined") {
- this.parameters[i] = args[i];
- }
- else {
- this[i] = args[i];
- }
- }
-}
-
-/**
- * Process a 'POST' request.
- * @param {function} callback callback funtion
- * @param {array} callbackArgs callback arguments
- */
-XMLHttp.prototype.post = function(callback, callbackArgs) {
- this.method = 'POST';
- this.async = false;
- if (typeof(callback)=="function") {
- this.callback = callback;
- this.async = true
- }
- if (typeof(callbackArgs)!="undefined") {
- this.callbackArgs = callbackArgs;
- }
- if (this.async) {
- this.process();
- }
- else {
- return this.process();
- }
-}
-
-/**
- * Process a 'GET' request.
- * @param {function} callback callback funtion
- * @param {array} callbackArgs callback arguments
- */
-XMLHttp.prototype.get = function(callback, callbackArgs) {
- this.method = 'GET';
- this.async = false;
- if (typeof(callback)=="function") {
- this.callback = callback;
- this.async = true
- }
- if (typeof(callbackArgs)!="undefined") {
- this.callbackArgs = callbackArgs;
- }
- if (this.async) {
- this.process();
- }
- else {
- return this.process();
- }
-}
-
-
-//----------------------------------------------------------------------------
-// helper methods (can be used directly if you need enhanced access, but the
-// method post and get are the prefered methods for processing a request.)
-//----------------------------------------------------------------------------
-
-/** @private */
-XMLHttp.prototype.process = function() {
-
- if (!this.xmlhttp) return false;
-
- var self = this;
- this.xmlhttp.onreadystatechange = function() {
- if (self.xmlhttp == null) { return; }
- if (self.xmlhttp.readyState == 1) { self._doLoading(self); }
- if (self.xmlhttp.readyState == 2) { self._doLoaded(self); }
- if (self.xmlhttp.readyState == 3) { self._doInteractive(self); }
- if (self.xmlhttp.readyState == 4) { self._doComplete(self); }
- };
-
- try {
- var args = null;
- for (var i in this.parameters) {
- if (this.argString.length>0) { this.argString += "&"; }
- this.argString += encodeURIComponent(i) + "=" + encodeURIComponent(this.parameters[i]);
- }
- if (this.method == "GET") {
- if (this.argString.length>0) {
- this.url += ((this.url.indexOf("?")>-1)?"&":"?") + this.argString;
- }
- this.xmlhttp.open(this.method, this.url, this.async);
- }
- if (this.method == "POST") {
- this.xmlhttp.open(this.method, this.url, this.async, this.username, this.password);
- args = this.argString;
- }
- if (typeof(this.xmlhttp.setRequestHeader)!="undefined" && this.xmlhttp.readyState == 1) {
- for (var i in this.headers) {
- this.xmlhttp.setRequestHeader(i, this.headers[i]);
- }
- }
- if (this.timeout > 0) {
- setTimeout(this._doTimeout, this.timeout);
- }
- this.xmlhttp.send(args);
- }
- catch(z) { return false; }
- /* on async call we return false and on sync calls we return the xmlhttp request */
- if (this.async) {
- return false;
- }
- else {
- return this.xmlhttp;
- }
-}
-
-
-//----------------------------------------------------------------------------
-// helper methods (can be used as a standalone cross browser xmlhttp request)
-//----------------------------------------------------------------------------
-
-/**
- * Global helper function for a cross browser XMLHttpRequest object.
- * @class This is a global helper function for a cross browser XMLHttpRequest object.
- * @constructor
- * @return A XMLHttpRequest instance for gecko browsers and a ActiveXObjecct
- * for ie browsers. Unsuported browsers get null returned.
- */
-getXmlHttpRequest = function() {
- if (window.XMLHttpRequest) {
- var req = new XMLHttpRequest();
- // some older versions of Moz did not support the readyState property
- // and the onreadystate event so we patch it!
- if (req.readyState == null) {
- req.readyState = 1;
- req.addEventListener("load", function () {
- req.readyState = 4;
- if (typeof req.onreadystatechange == "function") {
- req.onreadystatechange();
- }
- }, false);
- }
- return req;
- }
- else if (window.ActiveXObject) {
- var MSXML_XMLHTTP_IDS = new Array(
- "MSXML2.XMLHTTP.5.0",
- "MSXML2.XMLHTTP.4.0",
- "MSXML2.XMLHTTP.3.0",
- "MSXML2.XMLHTTP",
- "Microsoft.XMLHTTP");
- var success = false;
- for (var i = 0; i < MSXML_XMLHTTP_IDS.length && !success; i++) {
- try {
- return new ActiveXObject(MSXML_XMLHTTP_IDS[i]);
- success = true;
- } catch (e) {}
- }
- }
- else {
- return null;
- }
-}
-
-
-//----------------------------------------------------------------------------
-// built in helper methods
-//----------------------------------------------------------------------------
-
-/** @private */
-XMLHttp.prototype._doLoading = function(self) {
- if (self.isLoading) { return; }
- if (typeof(self.onLoading)=="function") {
- self.onLoading(self.xmlhttp);
- }
- self.isLoading = true;
-}
-
-/** @private */
-XMLHttp.prototype._doLoaded = function(self) {
- if (self.isLoaded) { return; }
- if (typeof(self.onLoaded)=="function") {
- self.onLoaded(self.xmlhttp);
- }
- self.isLoaded = true;
-}
-
-/** @private */
-XMLHttp.prototype._doInteractive = function(self) {
- if (self.isInteractive) { return; }
- if (typeof(self.onInteractive)=="function") {
- self.onInteractive(self.xmlhttp);
- }
- self.isInteractive = true;
-}
-
-/** @private */
-XMLHttp.prototype._doComplete = function(self) {
- if (self.isComplete || self.isAborted) { return; }
- self.isComplete = true;
- self.status = self.xmlhttp.status;
- self.statusText = self.xmlhttp.statusText;
- self.responseText = self.xmlhttp.responseText;
- self.responseXML = self.xmlhttp.responseXML;
- if (typeof(self.onComplete)=="function") {
- self.onComplete(self.xmlhttp);
- }
- if (self.xmlhttp.status==200 && typeof(self.callback)=="function") {
- if (self.callbackArgs) {
- self.callback(self.xmlhttp, self.callbackArgs);
- }
- else {
- self.callback(self.xmlhttp);
- }
- }
- if (self.xmlhttp.status!=200 && typeof(self.onError)=="function") {
- self.onError(self.xmlhttp);
- }
- if (self.async) {
- // on async calls, clean up so IE doesn't leak memory
- delete self.xmlhttp['onreadystatechange'];
- self.xmlhttp = null;
- }
-}
-
-/** @private */
-XMLHttp.prototype._doTimeout = function(self) {
- if (self.xmlhttp!=null && !self.isComplete) {
- self.xmlhttp.abort();
- self.isAborted = true;
- if (typeof(self.onTimeout)=="function") {
- self.onTimeout(self.xmlhttp);
- }
- // Opera won't fire onreadystatechange after abort, but other browsers do.
- // So we can't rely on the onreadystate function getting called. Clean up here!
- delete self.xmlhttp['onreadystatechange'];
- self.xmlhttp = null;
- }
-}
More information about the Checkins
mailing list