Changeset 247 for Dev/branches
- Timestamp:
- 02/08/12 16:43:40 (13 years ago)
- bzr:base-revision:
- hendrik@van-antwerpen.net-20120207191752-mbokj4rwqv8oi8bk
- bzr:committer:
- Hendrik van Antwerpen <hendrik@van-antwerpen.net>
- bzr:file-ids:
Dev/branches/jQueryUI/api.php 244@e1b9dffa-5495-0410-85d9-cf58ec4b5d15:%2FDev%2Fbranches%2FjQueryUI%2Fapi.php
Dev/branches/jQueryUI/index.php 243@e1b9dffa-5495-0410-85d9-cf58ec4b5d15:%2FDev%2Fbranches%2FjQueryUI%2Findex.php
Dev/branches/jQueryUI/js/api.js api.js-20120207184802-m5kfm0pir6sqj2uh-2
Dev/branches/jQueryUI/js/jquery/plugins plugins-20120208154136-m6u6o9acix3zvony-2
Dev/branches/jQueryUI/js/jquery/plugins/jquery.ba-bbq.js jquery.babbq.js-20120208154136-m6u6o9acix3zvony-5
Dev/branches/jQueryUI/js/main.js 244@e1b9dffa-5495-0410-85d9-cf58ec4b5d15:%2FDev%2Fbranches%2FjQueryUI%2Fjs%2Fmain.js
Dev/branches/jQueryUI/pages/mainmenu/mainmenu.html mainmenu.html-20120207184802-m5kfm0pir6sqj2uh-4
Dev/branches/jQueryUI/pages/mainmenu/mainmenu.js mainmenu.js-20120207184802-m5kfm0pir6sqj2uh-5
Dev/branches/jQueryUI/pages/sessions sessions-20120208154136-m6u6o9acix3zvony-1
Dev/branches/jQueryUI/pages/sessions/sessions.html sessions.html-20120208154136-m6u6o9acix3zvony-3
Dev/branches/jQueryUI/pages/sessions/sessions.js sessions.js-20120208154136-m6u6o9acix3zvony-4- bzr:mapping-version:
- v4
- bzr:repository-uuid:
- e1b9dffa-5495-0410-85d9-cf58ec4b5d15
- bzr:revision-id:
- hendrik@van-antwerpen.net-20120208154334-gr4a79sgxd2lp6v0
- bzr:revno:
- 248
- bzr:revprop:branch-nick:
- RESEARCHTOOL
- bzr:testament:
bazaar-ng testament short form 2.1
revision-id: hendrik@van-antwerpen.net-20120208154334-gr4a79sgxd2lp6v0
sha1: 5521adbc27dd512aa1572cefe88d4c14770cb488- bzr:text-parents:
Dev/branches/jQueryUI/api.php hendrik@van-antwerpen.net-20120207191752-mbokj4rwqv8oi8bk
Dev/branches/jQueryUI/index.php hendrik@van-antwerpen.net-20120207191752-mbokj4rwqv8oi8bk
Dev/branches/jQueryUI/js/api.js hendrik@van-antwerpen.net-20120207191752-mbokj4rwqv8oi8bk
Dev/branches/jQueryUI/js/jquery/plugins/jquery.ba-bbq.js
Dev/branches/jQueryUI/js/main.js hendrik@van-antwerpen.net-20120207191752-mbokj4rwqv8oi8bk
Dev/branches/jQueryUI/pages/mainmenu/mainmenu.html hendrik@van-antwerpen.net-20120207191752-mbokj4rwqv8oi8bk
Dev/branches/jQueryUI/pages/mainmenu/mainmenu.js hendrik@van-antwerpen.net-20120207191752-mbokj4rwqv8oi8bk
Dev/branches/jQueryUI/pages/sessions/sessions.html
Dev/branches/jQueryUI/pages/sessions/sessions.js- bzr:timestamp:
- 2012-02-08 16:43:34.436000109 +0100
- bzr:user-agent:
- bzr2.4.1+bzr-svn1.1.0
- Location:
- Dev/branches/jQueryUI
- Files:
-
- 5 added
- 11 deleted
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/branches/jQueryUI/api.php
r246 r247 1 1 <?php 2 2 3 require_once 'classes/ /master.php';3 require_once 'classes/master.php'; 4 4 5 5 $rawInput = $HTTP_RAW_POST_DATA; … … 21 21 $user = $user_results[0]; 22 22 if ($password == $user->password) { 23 $output['uid'] = $user->uid; 23 24 $returnValue = 200; 24 25 } … … 36 37 $user->password = $password; 37 38 $user->save(); 39 $output['uid'] = $user->uid; 38 40 $returnValue = 200; 39 41 } 40 42 break; 41 43 } 44 45 if (isset($input->uid)) { 46 $user_results = User::get(array("uid" => $input->uid)); 47 if (!empty($user_results)) { 48 $user = $user_results[0]; 49 switch ($input->action) { 50 case "createObject": 51 $uid = null; 52 switch (strtolower($input->args->type)) { 53 case "application": 54 $newApp = new Application(null, 55 $input->args->values->title, 56 $input->args->values->description, 57 $input->args->values->style); 58 $newApp->save(); 59 $uid = $newApp->uid; 60 $returnValue = 200; 61 break; 62 case "survey": 63 $newSurvey = new Survey(null, 64 $input->args->values->title, 65 $input->args->values->description, 66 $user, null); 67 $newSurvey->save(); 68 $uid = $newSurvey->uid; 69 $returnValue = 200; 70 break; 71 case "dashboard": 72 //TODO 73 break; 74 case "question": 75 $newQuestion = new Question(null, 76 $input->args->values->qCode, 77 $input->args->values->title, 78 $input->args->values->dataType, 79 $input->args->values->description, 80 $input->args->values->category, 81 array()); 82 $newQuestion->save(); 83 $uid = $newQuestion->uid; 84 $returnValue = 200; 85 break; 86 case "session": 87 $newSession = new Session(null, 88 $input->args->values->title, 89 $user, new DateTime(), null, null); 90 $newSession->save(); 91 $uid = $newSession->uid; 92 $returnValue = 200; 93 break; 94 } 95 $output['uid'] = $uid; 96 break; 97 case "getObject": 98 $type = $input->args->type; 99 $objects = $type::get(array("uid" => $input->args->uid)); 100 if (!empty($objects)) { 101 $output->object = $objects[0]; 102 $returnValue = 200; 103 } 104 break; 105 case "getObjects": 106 $type = $input->args->type; 107 $output['objects'] = $type::get($input->args->predicates); 108 $returnValue = 200; 109 break; 110 } 111 } else { 112 $returnValue = 403; 113 } 114 } 42 115 } 43 116 44 header("HTTP/1.1 " .$returnValue);117 header("HTTP/1.1 " . $returnValue); 45 118 header("Content-Type: application/json"); 46 119 header("Cache-Control: no-cache, must-revalidate"); 47 120 header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); 48 121 echo(json_encode($output)); 49 50 122 ?> -
Dev/branches/jQueryUI/index.php
r246 r247 11 11 <script type="text/javascript" src="js/jquery/jquery-1.7.1.js"></script> 12 12 <script type="text/javascript" src="js/jquery/ui/jquery-ui-1.8.17.custom.js"></script> 13 <script type="text/javascript" src="js/jquery/plugins/jquery.ba-bbq.js"></script> 13 14 <script type="text/javascript" src="js/api.js"></script> 14 15 <script type="text/javascript" src="js/main.js"></script> 16 15 17 <?php new StyleSheet("visualeditors"); ?> 16 18 </head> … … 23 25 <form> 24 26 <fieldset> 25 <label for="username">Name</label><input id="username" type="text" /> 26 <label for="password">Password</label><input id="password" type=" text"/>27 <label for="username">Name</label><input id="username" type="text" /><br /> 28 <label for="password">Password</label><input id="password" type="password" /><br /> 27 29 </fieldset> 28 30 </form> -
Dev/branches/jQueryUI/js/api.js
r246 r247 1 1 $(function() { 2 3 jQuery.extend({ 4 getScript: function(url, callback) { 5 var d = $.Deferred(); 6 if (callback) 7 d.done(callback); 8 var head = document.getElementsByTagName("head")[0]; 9 var script = document.createElement("script"); 10 script.src = url; 11 12 // Handle Script loading 13 { 14 var done = false; 15 16 // Attach handlers for all browsers 17 script.onload = script.onreadystatechange = function(){ 18 if ( !done && (!this.readyState || 19 this.readyState == "loaded" || this.readyState == "complete") ) { 20 done = true; 21 d.resolve(); 22 23 // Handle memory leak in IE 24 script.onload = script.onreadystatechange = null; 25 } 26 }; 27 } 28 29 head.appendChild(script); 30 31 // We handle everything using the script element injection 32 return d; 33 } 34 }); 2 35 3 36 rft = { 4 37 api: { 5 post: function(action,args ,success,error) {6 $.ajax({38 post: function(action,args) { 39 return $.ajax({ 7 40 type: "POST", 8 41 url: "api.php", 9 42 contentType: "application/json", 10 data: JSON.stringify({ action:action, args:args }), 11 success: success, 12 error: error 43 data: JSON.stringify({ 44 uid:rft.auth.getUid(), 45 action:action, 46 args:args 47 }) 48 }); 49 }, 50 createObject: function(type, args) { 51 var d = $.Deferred(); 52 rft.api.post("createObject", 53 { 54 type: type, 55 values: args 56 }) 57 .done(function(data, textStatus, jqXHR) { 58 d.resolve(data.uid); 59 }) 60 .fail(function(jqXHR,textStatus,errorThrown){ 61 d.reject(); 62 }); 63 return d.promise(); 64 }, 65 getObject: function(type, uid, success) { 66 var d = $.Deferred(); 67 rft.api.post("getObject", 68 { 69 type: type, 70 uid: uid 71 }) 72 .done(function(data, textStatus, jqXHR) { 73 d.resolve(data.object); 74 }) 75 .fail(function(jqXHR,textStatus,errorThrown){ 76 d.reject(); 77 }); 78 return d.promise(); 79 }, 80 getObjects: function(type, predicates, success) { 81 var d = $.Deferred(); 82 rft.api.post("getObjects", 83 { 84 type: type, 85 predicates: predicates 86 }) 87 .done(function(data, textStatus, jqXHR) { 88 d.resolve(data.objects); 89 }) 90 .fail(function(jqXHR,textStatus,errorThrown){ 91 d.reject(); 92 }); 93 return d.promise(); 94 }, 95 deleteObject: function(type, uid, success) { 96 var d = $.Deferred(); 97 d.reject(); 98 return d.promise(); 99 100 } 101 }, 102 auth: new (function() { 103 var self = this; 104 var currentUid = null; 105 106 self.login = function(username,password,success,error) { 107 var d = $.Deferred(); 108 rft.api.post("login", 109 { 110 username:username, 111 password:password 112 }) 113 .done(function(data, textStatus, jqXHR) { 114 currentUid = data.uid; 115 d.resolve(data.uid); 116 }) 117 .fail(function(jqXHR,textStatus,errorThrown){ 118 d.reject(); 119 }); 120 return d.promise(); 121 }; 122 123 self.register = function(username,password,success,error) { 124 var d = $.Deferred(); 125 rft.api.post("register", 126 { 127 username:username, 128 password:password 129 }) 130 .done(function(data, textStatus, jqXHR) { 131 currentUid = data.uid; 132 d.resolve(data.uid); 133 }) 134 .fail(function(jqXHR,textStatus,errorThrown){ 135 d.reject(); 136 }); 137 return d.promise(); 138 }; 139 140 self.getUid = function(){ 141 return currentUid; 142 }; 143 })(), 144 content: new (function() { 145 var self = this; 146 var current = ""; 147 148 function init() { 149 $(window).bind( 'hashchange', function(e){ 150 var url = $.bbq.getState("content"); 151 self.goTo(url); 13 152 }); 14 153 } 15 }, 16 auth: { 17 login: function(username,password,success,error) { 18 rft.api.post("login", 19 {username:username,password:password}, 20 function(data,textStatus,jqXHR) { 21 success && success() 22 }, 23 function(jqXHR,textStatus,errorThrown) { 24 error && error() 25 } 26 ); 27 }, 28 register: function(username,password,success,error) { 29 rft.api.post("register", 30 {username:username,password:password}, 31 function(data,textStatus,jqXHR) { 32 success && success() 33 }, 34 function(jqXHR,textStatus,errorThrown) { 35 error && error() 36 } 37 ); 154 155 self.initial = function(location) { 156 if ( current ) { 157 self.goTo(location); 158 } 159 var url = $.bbq.getState("content"); 160 self.goTo(url || location); 38 161 } 39 } 162 163 self.goTo = function(location) { 164 if ( current == location ) { 165 return $.when(); 166 } 167 current = location; 168 var d = $.Deferred(); 169 $.get("pages/"+location+"/"+location+".html") 170 .done(function(html){ 171 $("#content").html(html); 172 $.getScript("pages/"+location+"/"+location+".js") 173 .done(function(){ 174 d.resolve(); 175 }) 176 .fail(function(){ 177 d.reject(); 178 }) 179 }) 180 .fail(function(){ 181 $("#content").html("Page "+location+" not found."); 182 d.reject(); 183 }).then(function(){ 184 $.bbq.pushState({ 185 "content": location 186 }); 187 }) 188 return d; 189 } 190 191 init(); 192 })() 40 193 }; 41 194 -
Dev/branches/jQueryUI/js/main.js
r246 r247 2 2 3 3 function loadMenu() { 4 $.get("pages/mainmenu/mainmenu.html",function(html){ 5 $("#content").html(html); 6 }); 7 $.getScript("pages/mainmenu/mainmenu.js"); 4 rft.content.initial("mainmenu"); 8 5 } 9 6 … … 11 8 buttons: { 12 9 "Login": function() { 13 rft.auth.login($("#username").val(),$("#password").val(), 14 function(){ 15 $("#info").html("Login succesful."); 16 $("#loginForm").dialog("close"); 17 loadMenu(); 18 }, 19 function(){ 20 $("#info").html("Login failed."); 21 } 22 ); 23 24 10 rft.auth.login($("#username").val(),$("#password").val()) 11 .done(function(){ 12 $("#info").html("Login succesful."); 13 $("#loginForm").dialog("close"); 14 loadMenu(); 15 }) 16 .fail(function(){ 17 $("#info").text("Login failed."); 18 }) 25 19 }, 26 20 "Register": function() { 27 rft.auth.register($("#username").val(),$("#password").val(), 28 function(){ 29 $("#info").val("Succesfully registered, please login now."); 30 }, 31 function(){ 32 $("#info").html("Register failed, username already in use."); 33 } 34 ); 21 rft.auth.register($("#username").val(),$("#password").val()) 22 .done(function(){ 23 $("#info").text("Succesfully registered, please login now."); 24 }) 25 .fail(function(){ 26 $("#info").text("Register failed, username already in use."); 27 }) 35 28 } 36 29 } 37 38 30 }); 31 39 32 }); -
Dev/branches/jQueryUI/pages/mainmenu/mainmenu.html
r246 r247 1 1 <div class="largeFrame side" id="adminPanel"> 2 2 <div class="largeTitle">Administrator</div> 3 <div class="innerLargeFrame"> 4 <p>Use the below buttons to access, edit and create new sessions and content.</p><br /> 5 <input type="button" class="bigButton vertical" value="Browse Sessions" id="btnBrowseSessions" onClick="browseSessions()" /><br /> 6 <input type="button" class="bigButton vertical" value="Browse Surveys" id="btnBrowseSurveys" onClick="browseSurveys()" /><br /> 7 <input type="button" class="bigButton vertical" value="Browse Questions" id="btnBrowseQuestions" onClick="browseQuestions()" /><br /> 8 <input type="button" class="bigButton vertical" value="Browse Applications" id="btnBrowseApplications" onClick="browseApplications()" /><br /> 9 </div> 10 <div class="controls"></div> 11 </div> 12 <div class="largeFrame side" id="facilitatorPanel"> 13 <div class="largeTitle">Facilitator</div> 14 <div class="innerLargeFrame"> 15 <p>Use the Start button below to start hosting a session.</p> 16 <input type="button" class="bigButton vertical" value="Start" id="btnFacStart" onClick="window.location='facpanel.php'" style="margin-top: 0.25em;"/> 3 <div class="innerLargeFrame"> 4 <p>Use the below buttons to access, edit and create new sessions and content.</p><br /> 5 <input type="button" class="bigButton vertical" value="Browse Sessions" id="btnBrowseSessions" /><br /> 6 <input type="button" class="bigButton vertical" value="Browse Surveys" id="btnBrowseSurveys" /><br /> 7 <input type="button" class="bigButton vertical" value="Browse Questions" id="btnBrowseQuestions" /><br /> 8 <input type="button" class="bigButton vertical" value="Browse Applications" id="btnBrowseApplications" /><br /> 17 9 </div> 18 10 <div class="controls"></div> 19 11 </div> 12 <div class="largeFrame side" id="facilitatorPanel"> 13 <div class="largeTitle">Facilitator</div> 14 <div class="innerLargeFrame"> 15 <p>Use the Start button below to start hosting a session.</p> 16 <input type="button" class="bigButton vertical" value="Start" id="btnFacStart" style="margin-top: 0.25em;"/> 17 </div> 18 <div class="controls"></div> 19 </div> -
Dev/branches/jQueryUI/pages/mainmenu/mainmenu.js
r246 r247 1 1 $(function(){ 2 $("#adminPanel div.largeTitle").html("Admin (by Javascript!)"); 2 $("#btnBrowseSessions").click(function(){ 3 rft.content.goTo("sessions"); 4 }) 5 $("#btnBrowseSurveys").click(function(){ 6 rft.content.goTo("browse",{type:"Survey"}); 7 }) 8 $("#btnBrowseQuestions").click(function(){ 9 rft.content.goTo("browse",{type:"Question"}); 10 }) 11 $("#btnBrowseApplications").click(function(){ 12 rft.content.goTo("browse",{type:"Application"}); 13 }) 3 14 });
Note: See TracChangeset
for help on using the changeset viewer.