var MainScopePlus = this; var STATUS_UNKNOWN = 0; var STATUS_OFFLINE = 1; var STATUS_APPEAROFFLINE = 2; var STATUS_ONLINE = 3; var STATUS_BUSY = 4; var STATUS_BRB = 5; var STATUS_IDLE = 6; var STATUS_AWAY = 7; var STATUS_ONPHONE = 8; var STATUS_OUTLUNCH = 9; var EVENTICON_ONLINE = 0; var EVENTICON_OFFLINE = 1; var EVENTICON_AWAY = 2; var EVENTICON_BUSY = 3; var EVENTICON_BLOCKED = 4; var EVENTICON_PLUS = 5; var EVENTICON_NAMECHANGE = 6; var EVENTICON_PSMCHANGE = 7; var EVENTICON_MEDIACHANGE = 8; var EVENTICON_EMAIL = 9; var EVENTICON_MUSICCHANGE = 10; var MESSAGEKIND_UNKNOWN = 0; var MESSAGEKIND_SAYS = 1; var MESSAGEKIND_WINKS = 2; var MESSAGEKIND_VOICECLIPS = 3; var MESSAGEKIND_SEARCHING = 4; var MESSAGEKIND_FIND = 5; var MESSAGEKIND_SAYSOFFLINE = 6; var CREATEWNDOPT_NORMAL = 0; var CREATEWNDOPT_INVISIBLE = 1; var CREATEWNDOPT_DONTACTIVATE = 2; var WNDEXITCODE_OK = 1; var WNDEXITCODE_CANCEL = 2; var WNDEXITCODE_ABORT = 3; var WNDEXITCODE_RETRY = 4; var WNDEXITCODE_IGNORE = 5; var WNDEXITCODE_YES = 6; var WNDEXITCODE_NO = 7; var Class = { 'create' : function(){return function(){this.__construct.apply(this,arguments)}}, 'extend' : function(array1,array2){ for(var x in array2){array1[x] = array2[x]; } return array1;}, 'mergeArray' : function(array1,array2){for(var i=0;i < array2.length;i++){array1[array1.length] = array2[i];}return array1;} } function $A(ar){ var newvar = []; for(var i=0;i(.*?)\<\/\2\>)/ig,"[$2]$3[/$2]"); }, "replaceAll" : function(search,replace){ var s = this; if(TypeOf2(search) =='Array' && TypeOf2(replace)=='Array'){ for(var i=0;i', '\'', 'Œ', 'œ', 'Š', 'š', 'Ÿ', 'ˆ', '˜', '–', '—', '‘', '’', '‚', '“', '”', '„', '†', '‡', '‰', '‹', '›', '€' ]; return this.replaceAll(words,replace); } } ); // renamed base64Decode function from http://www.hw-group.com/support/tea/index_en.html#BASE64 function atob(str){ var result = ""; var i = 0; var x = 0; var y = 0; var z = 0; var count = -1; for (i=0; i < str.length; i++) { c = str.charAt(i); if ('A' <= c && c <= 'Z') x = str.charCodeAt(i) - 65; // 65 = 'A' else if ('a' <= c && c <= 'z') x = str.charCodeAt(i) - 97 + 26; // 97 = 'a' else if ('0' <= c && c <= '9') x = str.charCodeAt(i) - 48 + 52; // 48 = '0' else if (c == '+') x = 62; else if (c == '/') x = 63; else continue; count++; switch (count % 4) { case 0: y = x; continue; case 1: z = (y << 2) | (x >> 4); y = x & 0x0F; break; case 2: z = (y << 4) | (x >> 2); y = x & 0x03; break; case 3: z = (y << 6) | x; y = 0; break; } result = result + String.fromCharCode(z); } return result.toString(); } Function.prototype.bind = function(){ var __method = this; var object = arguments[0]; return function() {return __method.apply(object, arguments);} } /* var BoundArray = Array(); Function.prototype.bind = function(){ BoundArray[BoundArray.length] = [this, arguments[0]]; var num = BoundArray.length -1; return new Function('','BoundArray['+num+'][0].apply(BoundArray['+num+'][1],$A(arguments));'); } */ //AJAX class var Ajax = Class.create(); Ajax.prototype = { "options" : { 'method' : 'GET', 'data':'', "timeout" : 0, 'onComplete':function(){} , 'onError' : function(){}, 'onTimeout' : function(){}, 'contentType' : false }, "__construct" : function(url,options){ this.options = Class.extend(this.options , options); var onComplete = this.options.onComplete; var onError = this.options.onError; var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); xmlhttp.open(this.options.method, url, true); if(this.options.method=='POST' && !this.options.contentType){ xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); } if(this.options.contentType){ xmlhttp.setRequestHeader('Content-Type', this.options.contentType); } xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState==4) { if(xmlhttp.status == 200){ onComplete(xmlhttp.responseText,xmlhttp); }else{ //Debug.Trace(xmlhttp.status); onError(xmlhttp); } } }; //if(this.options.timeout > 0)this.startTimer(); //Debug.Trace(this.options.data); xmlhttp.send(this.options.data); }, "startTimer" : function(){ this.timer = new Timer(this.options.onTimeout,this.options.timeout); }, "stopTimer" : function(){ if(this.timer) this.timer.cancel(); } } //FILE class var File = Class.create(); File.prototype = { 'options' : {}, "__construct" : function(){ this.object = new ActiveXObject("Scripting.FileSystemObject"); }, 'getContents' : function(file){ var fO = this.getFileHandle(file); var text = fO.ReadAll(); fO.close(); return text; }, 'normalizePath' : function(path){ return path.replace(/\\/g,'\\\\'); }, 'fileExists' : function(file){ if(this.object.FileExists(this.normalizePath(file))){ return true; }else{ return false; } }, 'putContents' : function(file,data){ var fileO = this.getFileHandle(file,2); fileO.Write(data); fileO.close(); }, 'appendData' : function(file,data){ var fO = this.getFileHandle(file,8); fO.Write(data); fO.close(); }, 'unlink' : function(file){ var fO = this.getFileHandle(file); fO.Delete(); fO.close(); }, 'move' : function(file,to){ var fO = this.getFileHandle(file); fO.Move(this.normalizePath(to)); fO.close(); }, 'copy' : function(file,to){ var fO = this.getFileHandle(file); fO.Copy(this.normalizePath(to)); fO.close(); }, "folderExists" : function(folder){ return this.object.FolderExists(this.normalizePath(folder)); }, "createFolder" : function(folder){ if(!this.folderExists(folder)){ return this.object.CreateFolder(this.normalizePath(folder)); }else{ return false; } }, 'getFileHandle' : function(file,type){ var type = (typeof(type)=='undefined') ? 1 : type; if(this.fileExists(file)){ return this.object.OpenTextFile(this.normalizePath(file), type, 0); }else{ return this.object.CreateTextFile(this.normalizePath(file), true); } } } //TIMER var Timer = Class.create(); var RegisteredTimers = Array('') ; Timer.prototype = { "options" : {}, "__construct" : function(func,time,id){ this.options.func = func; this.options.time = time; this.register(id); }, "register" : function(id){ if(!id){ id = RegisteredTimers.length; //RegisteredTimers.foreach(function(value,num){if(value==this.options.func){id=num;return true;};return false;}.bind(this)) } this.id = id; RegisteredTimers[id] = this.options.func; MsgPlus.AddTimer(id,this.options.time); }, "cancel" : function(){ MsgPlus.CancelTimer(this.id); } } Timer.interval = Class.create(); Timer.interval.prototype = { "__construct" : function(func,time){ this.func = func; this.time = time; this.id = RegisteredTimers.length; this.register(); }, "register" : function(){ this.timer = new Timer(this.reapplytimer.bind(this),this.time,this.id); }, "cancel" : function(){ MsgPlus.CancelTimer(this.id); }, "reapplytimer" : function(){ this.func(); this.timer =''; this.register(); } } function OnEvent_Timer(sTimerId){ if(RegisteredTimers[sTimerId]){ RegisteredTimers[sTimerId](); //clean our RegisteredTimers array... //RegisteredTimers.splice(sTimerId,1); } } //these wrappers are to keep shawnz happy :P function setTimeout(func,time){ return new Timer(func,time); } function setInterval(func,time){ return new Timer.interval(func,time); } function clearTimeout(timer){ if(timer.cancel)timer.cancel(); } function clearInterval(timer){ if(timer.cancel)timer.cancel(); } // EVENT LISTENER var EventListenerEvents = { 'OnEvent_Initialize' : Array(), 'OnEvent_Uninitialize' : Array(), 'OnEvent_Signin' : Array(), 'OnEvent_Signout' : Array(), 'OnEvent_MyStatusChange' : Array(), 'OnEvent_MyNameChange' : Array(), 'OnEvent_MyPsmChange' : Array(), 'OnEvent_MyMediaChange' : Array(), 'OnEvent_ContactSignin' : Array(), 'OnEvent_ContactStatusChange' : Array(), 'OnEvent_ContactNameChange' : Array(), 'OnEvent_ContactPsmChange' : Array(), 'OnEvent_ContactMediaChange' : Array(), 'OnEvent_ContactBlocked' : Array(), 'OnEvent_ContactUnblocked' : Array(), 'OnEvent_MessengerLocked' : Array(), 'OnEvent_MessengerUnlocked' : Array(), 'OnEvent_ChatWndCreated' : Array(), 'OnEvent_ContactListWndCreated' : Array(), 'OnEvent_ContactListWndDestroyed' : Array(), 'OnEvent_ChatWndSendMessage' : Array(), 'OnEvent_ChatWndReceiveMessage' : Array(), 'OnEvent_ChatWndCreated' : Array(), 'OnEvent_ChatWndDestroyed' : Array(), 'OnEvent_ChatWndContactAdded' : Array(), 'OnEvent_ChatWndContactRemoved' : Array() } AddEventListener = Class.create(); AddEventListener.prototype = { 'event' : '', '__construct' : function(type,func){ //plus event if(EventListenerEvents['OnEvent_'+type]){ this.event = 'OnEvent_'+type; if(EventListenerEvents[this.event].length==0){ this.createEventFunc(); } EventListenerEvents[this.event][EventListenerEvents[this.event].length] = func; }else{ //non plus event this.event = type; if(!EventListenerEvents[this.event])EventListenerEvents[this.event] = Array(); EventListenerEvents[this.event][EventListenerEvents[this.event].length] = func; } }, "createEventFunc" : function(){ //create the function // Debug.Trace('plus function' + this.event +' hooked'); var bindedEvent = this.binded.bind(this); MainScopePlus[this.event] = bindedEvent; }, 'binded' : function(){ var x = new CallEventListener(this.event,true); return x.call.apply(this,arguments); } } CallEventListener = Class.create(); CallEventListener.prototype = { '__construct' : function(event,wait){ this.event = event; var args = $A(arguments); args.shift(); args.shift(); if(!wait)return this.call.apply(this,args); }, "call" : function(){ // Debug.Trace(this.event); // Debug.Trace(EventListenerEvents[this.event].length); if(EventListenerEvents[this.event]){ var args = $A(arguments); for(var i=0;i 1){ bodyNode = bodyNode.childNodes[0]; } this.returnArray = Array(); if(bodyNode.hasChildNodes){ for(var i=0;i"+bodyNode.childNodes[i].tagName + '->'+bodyNode.childNodes[i].childNodes.length); this.returnArray = this.parseNode(bodyNode.childNodes[i],this.returnArray); } } } if(this.returnArray['return']){ this.returnArray = this.returnArray['return']; } this.onComplete(this.returnArray); }, "parseNode" : function(node,array,inArray){ if(node.getAttribute('xsi:type').match('Array')){ //Debug.trace('IsArray'); array[node.tagName] = new Array(); for(var i=0;i"+node.childNodes[i].tagName + '->'+node.childNodes[i].childNodes.length); array[node.tagName][i] = this.parseNode(node.childNodes[i],array[node.tagName][i]); } } }else{ if(node.childNodes.length > 1){ for(var i=0;i"+node.childNodes[i].tagName + '->'+node.childNodes[i].childNodes.length); if(node.childNodes[i].childNodes.length == 1){ var d = node.childNodes[i].childNodes[0].text; array[node.childNodes[i].tagName] = d; }else if(node.childNodes[i].childNodes.length ==0){ array[node.childNodes[i].tagName] = ''; }else{ // Debug.Trace('->->lower->->' + node.childNodes[i].childNodes.length); array[node.childNodes[i].tagName] = Array(); for(var x=0;x->->"+node.childNodes[i].childNodes[x].tagName) array[node.childNodes[i].tagName] = this.parseNode(node.childNodes[i].childNodes[x],array[node.childNodes[i].tagName]); } } } } }else{ if(node.childNodes.length <= 1){ if(node.getAttribute('xsi:type').match('base64')){ var text = atob(node.text); }else{ var text = node.text; } if(!inArray){ array[node.tagName] = text; }else{ array[array.length] = text } }else{ // Debug.Trace('lower in l'); } } } return array; } } // example to search google with the above class. /* var parameters = { "key" : "", "q" : "porn", "start" : 0, "maxResults" : 3, "filter" : false, "restrict" : "", "safeSearch" : false, "lr" : "lang_en", "ie" : "", "oe" : "" }; var testSoap = function(xxx){ Debug.Trace('x'); } var soapClient = new SoapRequest("http://api.google.com/search/beta2"); soapClient.call("doGoogleSearch",parameters,"urn:GoogleSearch", testSoap); */