Skip to content Explore Features Enterprise Blog 0 1 public maellak/openeclass-mobile openeclass-mobile / connect.js Achilleas Pipinellis axilleas an hour ago Fix identation. 1 contributor file 61 lines (56 sloc) 1.77 kb 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 function ilv__Connect () { var ilv__wsite = "http://snf-538265.vm.okeanos.grnet.gr"; // afisse to stin grammi 10 this._ilv__login = ilv__wsite+"/modules/rest/login"; this._ilv__courses = ilv__wsite+"/modules/rest/courses"; this._ilv__user = "admin"; this._ilv__passwd = "apostolos"; } ilv__Connect.prototype.ilv__getStatecallback = function(data) { this.ilv__access_token = data.access_token; this.ilv__status = data.status; //alert(this.ilv__status); } ilv__Connect.prototype.login = function() { var subject = this; var postdata = { "uname": this._ilv__user , "pass": this._ilv__passwd } ; $.ajax({ url: this._ilv__login, type: "POST", crossDomain: true, data: JSON.stringify(postdata) , contentType: "application/json; charset=utf-8", dataType: "json", success:function(result){ alert(JSON.stringify(result)); subject._token=result.access_token; subject.getCourses(); }, error:function(xhr,status,error){ alert(status); } }); } ilv__Connect.prototype.getCourses = function() { var subject = this; alert(this._token); var postdata = { "access_token": this._token } ; $.ajax({ url: this._ilv__courses, type: "GET", crossDomain: true, data: postdata, contentType: "application/json; charset=utf-8", dataType: "json", success:function(result){ alert(result[0].title); //var _token=result.access_token; }, error:function(xhr,status,error){ alert(status); } }); } Status API Training Shop Blog About © 2014 GitHub, Inc. Terms Privacy Security Contact