bug fix & feature enhancement

master
Steve L. Nyemba 4 years ago
parent 8e82431a8f
commit 864dfaf5c6

@ -14,9 +14,14 @@ jx.cloudview.init = function(url,redir_url){//host,protocol){
// jx.cloudview.host = host // jx.cloudview.host = host
// jx.cloudview.protocol = protocol // jx.cloudview.protocol = protocol
jx.cloudview.url = url.trim().replace(/\/$/,'') jx.cloudview.url = url.trim().replace(/\/$/,'')
jx.cloudview.host = url.match(/^.+\/\/([a-z,0-9,.,-]+)\/.+$/)[1]
jx.cloudview.protocol = url.match(/^(https|http).+/)[1]
if(redir_url != null){ if(redir_url != null){
jx.cloudview.redirect_url = redir_url jx.cloudview.redirect_url = redir_url
} }
if(jx.cloudview.handler != null){
clearInterval(jx.cloudview.handler)
}
} }
jx.cloudview.oauth.init = function (id, key,callback,err) { jx.cloudview.oauth.init = function (id, key,callback,err) {
// var url = ":protocol://:host/cloud-view/" +id+"/get" // var url = ":protocol://:host/cloud-view/" +id+"/get"
@ -81,10 +86,17 @@ jx.cloudview.oauth.listen = function (key,callback,err) {
http.setHeader('platform', navigator.appName) http.setHeader('platform', navigator.appName)
http.setHeader('redirect_uri', key) http.setHeader('redirect_uri', key)
http.post(url, function (x) { http.post(url, function (x) {
try{
var info = JSON.parse(x.responseText) var info = JSON.parse(x.responseText)
callback(info) callback(info)
}catch(e){
if (err != null){
err(e)
}
}
// jx.dom.set.value('name', info.user.uii) // jx.dom.set.value('name', info.user.uii)
}) })
@ -99,8 +111,9 @@ jx.cloudview.oauth.listen = function (key,callback,err) {
if(jx.cloudview.popup != null){ if(jx.cloudview.popup != null){
if(jx.cloudview.popup.closed){ if(jx.cloudview.popup.closed){
clearInterval(jx.cloudview.handler) clearInterval(jx.cloudview.handler)
callback(null)
if (err != null){ if (err != null){
err() err(error)
} }
} }

@ -61,8 +61,16 @@ jx.ajax.get.instance = function(){
this.obj.headers[key] = value; this.obj.headers[key] = value;
} }
} }
this.setData = function(data){ this.setData = function(data,mimetype){
if(mimetype == null)
this.obj.data = data; this.obj.data = data;
else {
this.obj.headers['Content-Type'] = mimetype
if(mimetype.match(/application\/json/i)){
this.obj.data = JSON.stringify(data)
}
}
} }
this.setAsync = function(flag){ this.setAsync = function(flag){
this.obj.async = (flag == true) ; this.obj.async = (flag == true) ;

Loading…
Cancel
Save