// // Copyright GpsGate AB // http://gpsgate.com // // Autogenerated by GpsGate Server. Module: Franson.Json.Rpc.JsonRpcCrossSiteProxyGenerator, Franson.Json.Rpc, Version=3.0.0.2583, Culture=neutral, PublicKeyToken=9e4b59507d3e1a4f, on: 5/2/2024 7:39:49 PM // (function() { if (typeof(GpsGate) == 'undefined') GpsGate = {}; GpsGate.Server = GpsGate.Server || {}; if (typeof(GpsGate.Server.MyService) != 'undefined') { alert('Warning: GpsGate Server - Duplicate namespaces (MyService)'); // or wait with warning until an actual method collides? (in merge) } else { GpsGate.Server.MyService = {}; } var _scriptCounter = 0; var _appId = 1; function merge(baseModule, newModule) { for (var key in newModule) { baseModule[key] = newModule[key]; // todo: log or filter collisions? } return baseModule; } function buildQueryString(params) { var strParams = ''; for (prop in params) { strParams += '&' + encodeURIComponent(prop) + '=' + encodeURIComponent(params[prop]); } return strParams; } function toISOTime(date) { var hh = date.getHours(); var mm = date.getMinutes(); var ss = date.getSeconds(); return [ (hh < 10) ? '0' + hh : hh, (mm < 10) ? '0' + mm : mm, (ss < 10) ? '0' + ss : ss ].join(':'); } function toISODate(date) { var m = date.getMonth() + 1; var d = date.getDate(); var y = date.getFullYear(); // handle veeery old dates correctly if (y < 1000) y = '0' + y; if (y < 100) y = '0' + y; if (y < 10) y = '0' + y; return [ y, (m < 10) ? '0' + m : m, (d < 10) ? '0' + d : d ].join('-'); } function toISOTimestamp(date) { date = new Date(date.getTime() + (date.getTimezoneOffset() * 60000)); return toISODate(date) + 'T' + toISOTime(date) + 'Z'; } // todo: return a handle to the callback to enable cancelling? // todo: add a timeout value to be used to cancel a request? function xssCall(methodName, params, callback, onError) // onError is optional, if not specified the namespace-global version is called { onError = onError || GpsGate.Server.MyService.onError; var id = _scriptCounter++; var scriptNodeId = 'GpsGate_MyService_' + _appId + '_XSS_' + id; var poolName = '_' + id; GpsGate.Server.MyService._callback[poolName] = function(/*arguments*/) // in the jayrock case only one argument { var scriptNode = document.getElementById(scriptNodeId); scriptNode.parentNode.removeChild(scriptNode); script = scriptNode = null; delete GpsGate.Server.MyService._callback[poolName]; // drop the JayRock ret.result parent obj (on the server) if (typeof(arguments[0].error) != 'undefined') { try { var baseErr = arguments[0].error; var err0 = baseErr.errors[0]; // ok? onError(baseErr.name + ':' + err0.name, err0.message); } catch(e) { // .. } } else { callback(arguments[0].result); } }; var callUrl = 'http://www.cnetsat.com/GpsGateServer/Services/Auth.ashx/' + methodName + '?jsonp=GpsGate.Server.MyService._callback.' + poolName + buildQueryString(params); var script = document.createElement('script'); script.type = 'text/javascript'; script.id = scriptNodeId; var timeHashId = (new Date()).getTime().toString().substr(5); // drop unnecessary digits (this still leaves more than 24h timespan) script.src = callUrl + '&noCache=' + (timeHashId + id); document.getElementsByTagName('head')[0].appendChild(script); script = null; // don't leak } // todo: expose versioninfo and system-tests (ping?) in the base GpsGate.Server namespace // API merge(GpsGate.Server.MyService, { url: 'http://www.cnetsat.com/GpsGateServer/Services/Auth.ashx', onError: function(name, message) { alert('GpsGate error: ' + name + ' / ' + message); }, login: function(strUsername, strPassword, callback, onError) { xssCall('login', { 'appId': _appId, 'strUsername': strUsername, 'strPassword': strPassword }, callback, onError); }, _callback: {} }); })(); // GpsGate