Skip to content

Commit

Permalink
add microgear.setConfig() function
Browse files Browse the repository at this point in the history
  • Loading branch information
chavee committed Apr 12, 2017
1 parent 1c2d629 commit 6e95eea
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions microgear.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Microgear-HTML5 communicates over TLS by default
* If you want to disable TLS, set USETLS to false
*/
const VERSION = '1.1.5';
const VERSION = '1.1.6';
const GEARAPIADDRESS = 'ga.netpie.io';
const GEARAPIPORT = '8080';
const GEARAPISECUREPORT = '8081';
Expand All @@ -48,6 +48,7 @@ const MESSAGEBUFFERSIZE = 20;
* Variables
*/
var toktime = MINTOKDELAYTIME;
var GEARAUTH = GEARAPIADDRESS;

/*******************************************************************************
* Copyright (c) 2013 IBM Corp.
Expand Down Expand Up @@ -2806,8 +2807,8 @@ Microgear.create = function(param) {
else {
var gearauthurl;

if (self.securemode) gearauthurl = 'https://'+GEARAPIADDRESS+':'+GEARAPISECUREPORT;
else gearauthurl = 'http://'+GEARAPIADDRESS+':'+GEARAPIPORT;
if (self.securemode) gearauthurl = 'https://'+GEARAUTH+':'+GEARAPISECUREPORT;
else gearauthurl = 'http://'+GEARAUTH+':'+GEARAPIPORT;

if (!self.requesttoken && validateLocalStorage()) {
var skey = storage.get("microgear."+self.gearkey+".key");
Expand Down Expand Up @@ -3236,7 +3237,7 @@ Microgear.create = function(param) {
};

var revokecode = atok.revokecode.replace(/\//g,'_');
var apiurl = 'http://'+GEARAPIADDRESS+':'+GEARAPIPORT+'/api/revoke/'+atok.token+'/'+revokecode;
var apiurl = 'http://'+GEARAUTH+':'+GEARAPIPORT+'/api/revoke/'+atok.token+'/'+revokecode;
xmlHttp.open("GET", apiurl, true); //true for asynchronous
xmlHttp.send(null);
}
Expand Down Expand Up @@ -3275,13 +3276,29 @@ Microgear.create = function(param) {
else return false;
}

_microgear.prototype.setconfig = function(key,value) {
switch(key) {
case 'GEARAUTH' : GEARAUTH = value.toString();
break;
}
}

_microgear.prototype.getconfig = function(key) {
switch(key) {
case 'GEARAUTH' : return GEARAUTH;
break;
}
}

_microgear.prototype.setName = _microgear.prototype.setname;
_microgear.prototype.unsetName = _microgear.prototype.unsetname;
_microgear.prototype.setAlias = _microgear.prototype.setalias;
_microgear.prototype.writeFeed = _microgear.prototype.writefeed;
_microgear.prototype.getToken = _microgear.prototype.gettoken;
_microgear.prototype.resetToken = _microgear.prototype.resettoken;
_microgear.prototype.useTLS = _microgear.prototype.usetls;
_microgear.prototype.setConfig = _microgear.prototype.setconfig;
_microgear.prototype.getConfig = _microgear.prototype.getconfig;

if (gkey && gsecret) {
var mg = new _microgear(gkey,gsecret,galias);
Expand Down

0 comments on commit 6e95eea

Please sign in to comment.