import stdlib JQuery = $ listDiv = ['raph','fam','baby'] pathTemplates = "/Gallerie/static/templates/" def rpcCall(meth, params): d = $.Deferred() _url = '/Gallerie/default/call/jsonrpc' _data = JSON.stringify ({jsonrpc:'2.0',method:meth, params:[params],id:"jsonrpc"} ) _type = "POST" _dataType: "json" _success = def (result): d.resolve(result) _error = def (err, status, thrown): alert("Error") _complete = def (xhr, status): data = JQuery.parseJSON(xhr.responseText) param = { url : _url, data : _data, type : _type, success : _success, error : _error, complete:_complete } JQuery.ajax(param) return d.promise() def getPhotos(arg, theme = "Hyeddd...;"): hideAllDivs() if (window.sessionStorage[arg] == 'loaded') : showDiv(arg) return alert("loading " + arg) request = rpcCall('getPhotos',{nom : arg}) request.done( def (r): #alert(r.result) showDiv(arg,r.result) window.sessionStorage[arg] = "loaded" ) def hideAllDivs(): for div in listDiv: $("#" + div).hide() def showDiv(div,result): data = {title : "ALBUM", theme : result} html = new EJS({url: pathTemplates + 'displayphoto.ejs'}).render(data) elt = "#" + div $(elt).html(html) $(elt).show() alert("main") #Exported functions window.getPhotos = getPhotos
jeudi 6 juin 2013
RapydScript : RPC Call
pre { white-space: pre-wrap; font-family: monospace; color: #ffffff; background-color: #333333; }
body { font-family: monospace; color: #ffffff; background-color: #333333; }
.Comment { color: #87ceeb; }
.Identifier { color: #98fb98; }
.Statement { color: #f0e68c; font-weight: bold; }
.Constant { color: #ffa0a0; }
.PreProc { color: #cd5c5c; }
-->
Inscription à :
Publier les commentaires (Atom)
Aucun commentaire:
Enregistrer un commentaire