//Jasp.Native.Utils.js Jasp.extend = function($this, obj) { if(!$this) return obj; for (var p in obj) { if ($this[p] == null) { $this[p] = obj[p]; } } return $this; } Jasp.override = function($this, obj) { for (var p in obj) { $this[p] = obj[p]; } return $this; } Jasp.each = function(arr, cb) { for (var i = 0; i < arr.length; i++) if (arr[i] != undefined) cb(arr[i]); } Jasp.inherit = function(child, parent, clientBase) { var copy = {}; var ctor = child.prototype.constructor; Jasp.extend(copy, child.prototype); var F = function() { }; F.prototype = parent.prototype; child.prototype = new F(); for (var p in copy) { child.prototype[p] = copy[p]; } child.prototype.constructor = ctor; if(clientBase){ child.$clientBase = clientBase; Jasp.inherit(child, clientBase, null); } } Jasp.getElementById = function(element, id) { if (element == null) return document.getElementById(id); if (element.id == id) return element; for (var i = 0; element.childNodes && i < element.childNodes.length; i++) { var result = Jasp.getElementById(element.childNodes[i], id); if (result) return result; } return null; } Jasp.resources.push(108); //Jasp.Native.Json.js /* Copyright (c) 2005 JSON.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The Software shall be used for Good, not Evil. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* The global object JSON contains two methods. JSON.stringify(value) takes a JavaScript value and produces a JSON text. The value must not be cyclical. JSON.parse(text) takes a JSON text and produces a JavaScript value. It will return false if there is an error. */ Jasp.extend(Jasp, { json: (function() { var m = { '\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"': '\\"', '\\': '\\\\' }, s = { 'boolean': function(x) { return String(x); }, number: function(x) { return isFinite(x) ? String(x) : 'null'; }, string: function(x) { if (/["\\\x00-\x1f]/.test(x)) { x = x.replace(/([\x00-\x1f\\"])/g, function(a, b) { var c = m[b]; if (c) { return c; } c = b.charCodeAt(); return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16); }); } return '"' + x + '"'; }, object: function(x) { if (x) { var a = [], b, f, i, l, v; if (x instanceof Array) { a[0] = '['; l = x.length; for (i = 0; i < l; i += 1) { v = x[i]; f = s[typeof v]; if (f) { v = f(v); if (typeof v == 'string') { if (b) { a[a.length] = ','; } a[a.length] = v; b = true; } } } a[a.length] = ']'; } else if (x instanceof Date) { function p(n) { return n < 10 ? '0' + n : n; }; var tz = x.getTimezoneOffset(); if (tz != 0) { var tzh = Math.floor(Math.abs(tz) / 60); var tzm = Math.abs(tz) % 60; tz = (tz < 0 ? '+' : '-') + p(tzh) + ':' + p(tzm); } else { tz = 'Z'; } return '"' + x.getFullYear() + '-' + p(x.getMonth() + 1) + '-' + p(x.getDate()) + 'T' + p(x.getHours()) + ':' + p(x.getMinutes()) + ':' + p(x.getSeconds()) + tz + '"'; } else if (x instanceof Object) { a[0] = '{'; for (i in x) { v = x[i]; f = s[typeof v]; if (f) { v = f(v); if (typeof v == 'string') { if (b) { a[a.length] = ','; } a.push(s.string(i), ':', v); b = true; } } } a[a.length] = '}'; } else { return; } return a.join(''); } return 'null'; } }; return { copyright: '(c)2005 JSON.org', license: 'http://www.crockford.com/JSON/license.html', /* Stringify a JavaScript value, producing a JSON text. */ stringify: function(v) { var f = s[typeof v]; if (f) { v = f(v); if (typeof v == 'string') { return v; } } return null; }, /* Parse a JSON text, producing a JavaScript value. It returns false if there is a syntax error. */ eval: function(text) { try { //if (/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(text)) { return eval('(' + text + ')'); //} } catch (e) {} throw new SyntaxError("eval"); }, parse: function(text) { var at = 0; var ch = ' '; function error(m) { throw { name: 'JSONError', message: m, at: at - 1, text: text }; } function next() { ch = text.charAt(at); at += 1; return ch; } function white() { while (ch) { if (ch <= ' ') { next(); } else if (ch == '/') { switch (next()) { case '/': while (next() && ch != '\n' && ch != '\r') { } break; case '*': next(); for (; ; ) { if (ch) { if (ch == '*') { if (next() == '/') { next(); break; } } else { next(); } } else { error("Unterminated comment"); } } break; default: error("Syntax error"); } } else { break; } } } function string() { var i, s = '', t, u; if (ch == '"') { outer: while (next()) { if (ch == '"') { next(); return s; } else if (ch == '\\') { switch (next()) { case 'b': s += '\b'; break; case 'f': s += '\f'; break; case 'n': s += '\n'; break; case 'r': s += '\r'; break; case 't': s += '\t'; break; case 'u': u = 0; for (i = 0; i < 4; i += 1) { t = parseInt(next(), 16); if (!isFinite(t)) { break outer; } u = u * 16 + t; } s += String.fromCharCode(u); break; default: s += ch; } } else { s += ch; } } } error("Bad string"); } function array() { var a = []; if (ch == '[') { next(); white(); if (ch == ']') { next(); return a; } while (ch) { a.push(value()); white(); if (ch == ']') { next(); return a; } else if (ch != ',') { break; } next(); white(); } } error("Bad array"); } function object() { var k, o = {}; if (ch == '{') { next(); white(); if (ch == '}') { next(); return o; } while (ch) { k = string(); white(); if (ch != ':') { break; } next(); o[k] = value(); white(); if (ch == '}') { next(); return o; } else if (ch != ',') { break; } next(); white(); } } error("Bad object"); } function number() { var n = '', v; if (ch == '-') { n = '-'; next(); } while (ch >= '0' && ch <= '9') { n += ch; next(); } if (ch == '.') { n += '.'; while (next() && ch >= '0' && ch <= '9') { n += ch; } } if (ch == 'e' || ch == 'E') { n += 'e'; next(); if (ch == '-' || ch == '+') { n += ch; next(); } while (ch >= '0' && ch <= '9') { n += ch; next(); } } v = +n; if (!isFinite(v)) { ////error("Bad number"); } else { return v; } } function word() { switch (ch) { case 't': if (next() == 'r' && next() == 'u' && next() == 'e') { next(); return true; } break; case 'f': if (next() == 'a' && next() == 'l' && next() == 's' && next() == 'e') { next(); return false; } break; case 'n': if (next() == 'u' && next() == 'l' && next() == 'l') { next(); return null; } break; } error("Syntax error"); } function value() { white(); switch (ch) { case '{': return object(); case '[': return array(); case '"': return string(); case '-': return number(); default: return ch >= '0' && ch <= '9' ? number() : word(); } } return value(); } }; })() }); Jasp.resources.push(106); //Jasp.Native.Events.js // событийная модель джаспа // взято отсюда http://joshdavis.wordpress.com/2007/04/10/custom-event-listeners/ // немного переделано /** * Create a new instance of Jasp.event. * * @classDescription This class creates a new Jasp.event. * @return {Object} Returns a new Jasp.event object. * @constructor */ Jasp.extend(Jasp, { event: function(){ this.events = []; this.builtinEvts = []; } }); /** * Gets the index of the given action for the element * * @memberOf Jasp.event * @param {Object} obj The element attached to the action. * @param {String} evt The name of the event. * @param {Function} action The action to execute upon the event firing. * @param {Object} binding The object to scope the action to. * @return {Number} Returns an integer. */ Jasp.event.prototype.getActionIdx = function(obj,evt,action,binding) { if(obj && evt) { var curel = this.events[obj][evt]; if(curel) { var len = curel.length; for(var i = len-1;i >= 0;i--) { if(curel[i].action == action && curel[i].binding == binding) { return i; } } } else { return -1; } } return -1; }; /** * Adds a listener * * @memberOf Jasp.event * @param {Object} obj The element attached to the action. * @param {String} evt The name of the event. * @param {Function} action The action to execute upon the event firing. * @param {Object} binding The object to scope the action to. * @return {null} Returns null. */ Jasp.event.prototype.on = function(obj, evt, action, binding) { if(this.events[obj]) { if(this.events[obj][evt]) { if(this.getActionIdx(obj,evt,action,binding) == -1) { var curevt = this.events[obj][evt]; curevt[curevt.length] = {action:action,binding:binding}; } } else { this.events[obj][evt] = []; this.events[obj][evt][0] = {action:action,binding:binding}; } } else { this.events[obj] = []; this.events[obj][evt] = []; this.events[obj][evt][0] = {action:action,binding:binding}; } }; /** * Removes a listener * * @memberOf Event * @param {Object} obj The element attached to the action. * @param {String} evt The name of the event. * @param {Function} action The action to execute upon the event firing. * @param {Object} binding The object to scope the action to. * @return {null} Returns null. */ Jasp.event.prototype.remove = function(obj,evt,action,binding) { if(this.events[obj]) { if(this.events[obj][evt]) { var idx = this.actionExists(obj,evt,action,binding); if(idx >= 0) { this.events[obj][evt].splice(idx,1); } } } }; /** * Fires an event * * @memberOf Event * @param e [(event)] A builtin event passthrough * @param {Object} obj The element attached to the action. * @param {String} evt The name of the event. * @param {Object} args The argument attached to the event. * @return {null} Returns null. */ Jasp.event.prototype.fire = function(obj,evt,args) { if(obj && this.events) { var evtel = this.events[obj]; if(evtel) { var curel = evtel[evt]; if(curel) { Jasp.each(curel,function(c){ if(c.action){ c.action.call(obj, args); } }); } } } }; Jasp.extend(Jasp, new Jasp.event() ); Jasp.resources.push(103); //Jasp.Native.InitHandler.js // обработчик события, когда DOM модель построена и скрипты загружены (картинки, флеши и т.п. могут быть еще не загружены) // взято отсюда http://dean.edwards.name/weblog/2005/09/busted/ // немного переделано Jasp.extend(Jasp, { readyListiner: function(){ function init() { // quit if this function has already been called if (arguments.callee.done) return; // flag this function so we don't do the same thing twice arguments.callee.done = true; // kill the timer if (_timer) { clearInterval(_timer); _timer = null; } // вызывает событие готовности джаспа Jasp.fire(Jasp, 'ready'); }; /* for Mozilla */ if (document.addEventListener) { document.addEventListener("DOMContentLoaded", init, false); } /* for Internet Explorer */ /*@cc_on @*/ /*@if (@_win32) document.write("