// // Copyright Franson Technology AB - GpsGate.com // franson.com - gpsgate.com // // Autogenerated by GpsGate Server. Module: Franson.Json.Rpc.JsonRpcCrossSiteProxyGenerator, Franson.Json.Rpc, Version=2.3.1.2076, Culture=neutral, PublicKeyToken=9e4b59507d3e1a4f, on: 9/8/2010 9:46:13 AM // (function() { if (typeof(GpsGate) == 'undefined') GpsGate = {}; GpsGate.Server = GpsGate.Server || {}; if (typeof(GpsGate.Server.SignUp) != 'undefined') { alert('Warning: GpsGate Server - Duplicate namespaces (SignUp)'); // or wait with warning until an actual method collides? (in merge) } else { GpsGate.Server.SignUp = {}; } function checkGpsGateLicence() { var gpsGateDiv = document.getElementById('gpsgate'); if (gpsGateDiv === null || !(gpsGateDiv.nodeType == 1 || gpsGateDiv.nodetype == 2 || gpsGateDiv.nodeType == 3) || typeof(gpsGateDiv.href) == 'undefined' || gpsGateDiv.href.toLowerCase().indexOf('gpsgate.com') == -1 || gpsGateDiv.style.display == 'none' || gpsGateDiv.style.visibility == 'hidden') // ok? { prompt('Error: You must link to GpsGate.com to use this service. Add this link to your page: ', 'GPS Tracking'); return false; } return true; } var _scriptCounter = 0; var _appId = 501; 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.SignUp.onError; if (_scriptCounter == 0) checkGpsGateLicence(); var id = _scriptCounter++; var scriptNodeId = 'GpsGate_SignUp_' + _appId + '_XSS_' + id; var poolName = '_' + id; GpsGate.Server.SignUp._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.SignUp._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://apps.gpsgate.com/Services/SignUp.ashx/' + methodName + '?jsonp=GpsGate.Server.SignUp._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.SignUp, { url: 'http://apps.gpsgate.com/Services/SignUp.ashx', onError: function(name, message) { alert('GpsGate error: ' + name + ' / ' + message); }, GetDevices: function(groupName, callback, onError) { xssCall('GetDevices', { 'appId': _appId, 'groupName': groupName }, callback, onError); }, GetOperatorCountries: function(groupName, callback, onError) { xssCall('GetOperatorCountries', { 'appId': _appId, 'groupName': groupName }, callback, onError); }, GetNetworksInCountry: function(groupName, strCountry, callback, onError) { xssCall('GetNetworksInCountry', { 'appId': _appId, 'groupName': groupName, 'strCountry': strCountry }, callback, onError); }, CommitSignUp: function(groupName, strUsername, strEmail, iDeviceDefinitionID, strIMEI, strMSISDN, strAPN, strGPRSUname, strGPRSPwd, iMobileNetworkId, callback, onError) { xssCall('CommitSignUp', { 'appId': _appId, 'groupName': groupName, 'strUsername': strUsername, 'strEmail': strEmail, 'iDeviceDefinitionID': iDeviceDefinitionID, 'strIMEI': strIMEI, 'strMSISDN': strMSISDN, 'strAPN': strAPN, 'strGPRSUname': strGPRSUname, 'strGPRSPwd': strGPRSPwd, 'iMobileNetworkId': iMobileNetworkId }, callback, onError); }, _callback: {} }); })(); // GpsGate