minor bug fixes and cloud-view framework

master
Steve L. Nyemba 7 years ago
parent c558ed2069
commit 7c2d581b17

@ -215,6 +215,9 @@ jx.dom.get.value = function(id){
*/ */
jx.dom.get.attribute = function(id,field){ jx.dom.get.attribute = function(id,field){
_dom = jx.dom.get.instance(id) _dom = jx.dom.get.instance(id)
if (_dom[field] != null) {
return _dom[field]
}
return _dom.getAttribute(field) ; return _dom.getAttribute(field) ;
} }
/** /**
@ -313,7 +316,12 @@ jx.dom.set.value= function(id,value){
*/ */
jx.dom.set.attribute = function(id,field,value){ jx.dom.set.attribute = function(id,field,value){
_dom = jx.dom.get.instance(id); _dom = jx.dom.get.instance(id);
if (value.constructor == Object) {
_dom[field] = value
} else {
_dom.setAttribute(field,value) ; _dom.setAttribute(field,value) ;
}
} }
/** /**

@ -0,0 +1,64 @@
/**
* This framework is intended to work and handle authentication with the cloud view engine
* DEPENDENCIES :
* rpc.js HttpClient, urlparser
* @TODO: A registration process maybe required
*/
/**
* @param id service identifier
* @param key callback/ user key
*/
jx.cloudview = { popup:null,cache: {},oauth:{}}
jx.cloudview.oauth.init = function (id, key,callback) {
var url = "https://the-phi.com/cloud-view/" +id+"/get"
var httpclient = HttpClient.instance()
httpclient.setHeader("platform",navigator.appName)
httpclient.post(url, function (x) {
var url = x.responseText
var oauth_uri = url.match(/redirect_uri=(.+)&/)[1];
url = url.replace(oauth_uri, key)
jx.cloudview.handler = null
jx.cloudview.popup = window.open(url, 'oauth', 'width=405, height=900')
jx.cloudview.oauth.listen(key,callback)
})
}
/**
* @param key
*/
jx.cloudview.oauth.listen = function (key,callback) {
if (jx.cloudview.handler != null) {
clearInterval(jx.cloudview.handler)
}
jx.cloudview.handler = setInterval(function () {
try {
if (jx.cloudview.popup.location.search.match(/code=/)) {
clearInterval(jx.cloudview.handler)
var p = urlparser(jx.cloudview.popup.location.search)
var url = (["https://the-phi.com/cloud-view/", p.state, "/set/authentication"]).join('')
var http = HttpClient.instance()
http.setHeader('code', encodeURIComponent(p.code))
http.setHeader('pid', 'authentication')
http.setHeader('platform', navigator.appName)
http.setHeader('redirect_uri', key)
http.post(url, function (x) {
var info = JSON.parse(x.responseText)
callback(info)
// jx.dom.set.value('name', info.user.uii)
})
}
jx.cloudview.popup.close()
} catch (error) {
// console.log(error)
}
},1500)
}

@ -106,7 +106,6 @@ jx.ajax.get.instance = function(){
http.setRequestHeader(key,value) http.setRequestHeader(key,value)
} }
http.send(this.obj.data) http.send(this.obj.data)
} }

Loading…
Cancel
Save