storageapi.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. // Storage API
  2. // JavaScript API
  3. // CBlue SPRL, Jean-Karim Bockstael <jeankarim@cblue.be>
  4. lms_storage_testCall = function(content) {
  5. alert(content);
  6. }
  7. lms_storage_setValue_user = function(sv_key, sv_value, sv_user) {
  8. var result;
  9. $.ajax({
  10. async: false,
  11. type: "POST",
  12. url: "storageapi.php",
  13. data: {
  14. action: "set",
  15. svkey: sv_key,
  16. svvalue: sv_value,
  17. svuser: sv_user,
  18. svcourse: sv_course,
  19. svsco: sv_sco
  20. },
  21. success: function(data) {
  22. result = (data != '0');
  23. }
  24. });
  25. return result;
  26. }
  27. lms_storage_getValue_user = function(sv_key, sv_user) {
  28. var result;
  29. $.ajax({
  30. async: false,
  31. type: "POST",
  32. url: "storageapi.php",
  33. data: {
  34. action: "get",
  35. svkey: sv_key,
  36. svuser: sv_user,
  37. svcourse: sv_course,
  38. svsco: sv_sco
  39. },
  40. success: function(data) {
  41. result = data;
  42. }
  43. });
  44. return result;
  45. }
  46. lms_storage_getPosition_user = function(sv_key, sv_user, sv_asc) {
  47. var result;
  48. $.ajax({
  49. async: false,
  50. type: "POST",
  51. url: "storageapi.php",
  52. data: {
  53. action: "getposition",
  54. svkey: sv_key,
  55. svuser: sv_user,
  56. svcourse: sv_course,
  57. svsco: sv_sco,
  58. svasc: sv_asc
  59. },
  60. success: function(data) {
  61. result = data;
  62. }
  63. });
  64. return result;
  65. }
  66. lms_storage_getLeaders_user = function(sv_key, sv_user, sv_asc, sv_length) {
  67. var result;
  68. $.ajax({
  69. async: false,
  70. type: "POST",
  71. url: "storageapi.php",
  72. data: {
  73. action: "getleaders",
  74. svkey: sv_key,
  75. svuser: sv_user,
  76. svcourse: sv_course,
  77. svsco: sv_sco,
  78. svasc: sv_asc,
  79. svlength: sv_length
  80. },
  81. success: function(data) {
  82. result = eval("("+data+")");
  83. }
  84. });
  85. return result;
  86. }
  87. lms_storage_getAll_user = function(sv_user) {
  88. var result;
  89. $.ajax({
  90. async: false,
  91. type: "POST",
  92. url: "storageapi.php",
  93. data: {
  94. action: "getall",
  95. svuser: sv_user,
  96. svcourse: sv_course,
  97. svsco: sv_sco
  98. },
  99. success: function(data) {
  100. result = eval("("+data+")");
  101. }
  102. });
  103. return result;
  104. }
  105. lms_storage_stack_push_user = function(sv_key, sv_value, sv_user) {
  106. var result;
  107. $.ajax({
  108. async: false,
  109. type: "POST",
  110. url: "storageapi.php",
  111. data: {
  112. action: "stackpush",
  113. svvalue: sv_value,
  114. svkey: sv_key,
  115. svuser: sv_user,
  116. svcourse: sv_course,
  117. svsco: sv_sco
  118. },
  119. success: function(data) {
  120. result = (data != '0');
  121. }
  122. });
  123. return result;
  124. }
  125. lms_storage_stack_pop_user = function(sv_key, sv_user) {
  126. var result;
  127. $.ajax({
  128. async: false,
  129. type: "POST",
  130. url: "storageapi.php",
  131. data: {
  132. action: "stackpop",
  133. svkey: sv_key,
  134. svuser: sv_user,
  135. svcourse: sv_course,
  136. svsco: sv_sco
  137. },
  138. success: function(data) {
  139. result = data;
  140. }
  141. });
  142. return result;
  143. }
  144. lms_storage_stack_length_user = function(sv_key, sv_user) {
  145. var result;
  146. $.ajax({
  147. async: false,
  148. type: "POST",
  149. url: "storageapi.php",
  150. data: {
  151. action: "stacklength",
  152. svkey: sv_key,
  153. svuser: sv_user,
  154. svcourse: sv_course,
  155. svsco: sv_sco
  156. },
  157. success: function(data) {
  158. result = data;
  159. }
  160. });
  161. return result;
  162. }
  163. lms_storage_stack_clear_user = function(sv_key, sv_user) {
  164. var result;
  165. $.ajax({
  166. async: false,
  167. type: "POST",
  168. url: "storageapi.php",
  169. data: {
  170. action: "stackclear",
  171. svkey: sv_key,
  172. svuser: sv_user,
  173. svcourse: sv_course,
  174. svsco: sv_sco
  175. },
  176. success: function(data) {
  177. result = data;
  178. }
  179. });
  180. return result;
  181. }
  182. lms_storage_stack_getAll_user = function(sv_key, sv_user) {
  183. var result;
  184. $.ajax({
  185. async: false,
  186. type: "POST",
  187. url: "storageapi.php",
  188. data: {
  189. action: "stackgetall",
  190. svkey: sv_key,
  191. svuser: sv_user,
  192. svcourse: sv_course,
  193. svsco: sv_sco
  194. },
  195. success: function(data) {
  196. result = eval("("+data+")");
  197. }
  198. });
  199. return result;
  200. }
  201. lms_storage_getAllUsers = function() {
  202. var result;
  203. $.ajax({
  204. async: false,
  205. type: "POST",
  206. url: "storageapi.php",
  207. data: {
  208. action: "usersgetall"
  209. },
  210. success: function(data) {
  211. result = eval("("+data+")");
  212. }
  213. });
  214. return result;
  215. }
  216. lms_storage_setValue = function(sv_key, sv_value) {
  217. return lms_storage_setValue_user(sv_key, sv_value, sv_user);
  218. }
  219. lms_storage_getValue = function(sv_key) {
  220. return lms_storage_getValue_user(sv_key, sv_user);
  221. }
  222. lms_storage_getPosition = function(sv_key, sv_asc) {
  223. return lms_storage_getPosition_user(sv_key, sv_user, sv_asc);
  224. }
  225. lms_storage_getLeaders = function(sv_key, sv_asc, sv_length) {
  226. return lms_storage_getLeaders_user(sv_key, sv_user, sv_asc, sv_length);
  227. }
  228. lms_storage_getAll = function() {
  229. return lms_storage_getAll_user(sv_user);
  230. }
  231. lms_storage_stack_push = function(sv_key, sv_value) {
  232. return lms_storage_stack_push_user(sv_key, sv_value, sv_user);
  233. }
  234. lms_storage_stack_pop = function(sv_key) {
  235. return lms_storage_stack_pop(sv_key, sv_user);
  236. }
  237. lms_storage_stack_length = function(sv_key) {
  238. return lms_storage_stack_length_user(sv_key, sv_user);
  239. }
  240. lms_storage_stack_clear = function(sv_key) {
  241. return lms_storage_stack_clear_user(sv_key, sv_user);
  242. }
  243. lms_storage_stack_getAll = function(sv_key) {
  244. return lms_storage_stack_getAll_user(sv_key, sv_user);
  245. }
  246. // Accessor object
  247. function STORAGEAPIobject() {
  248. this.testCall = lms_storage_testCall;
  249. this.setValue = lms_storage_setValue;
  250. this.setValue_user = lms_storage_setValue_user;
  251. this.getValue = lms_storage_getValue;
  252. this.getValue_user = lms_storage_getValue_user;
  253. this.getAll = lms_storage_getAll;
  254. this.getAll_user = lms_storage_getAll_user;
  255. this.getPosition_user = lms_storage_getPosition_user;
  256. this.getPosition = lms_storage_getPosition;
  257. this.getLeaders_user = lms_storage_getLeaders_user;
  258. this.getLeaders = lms_storage_getLeaders;
  259. this.stack_push = lms_storage_stack_push;
  260. this.stack_push_user = lms_storage_stack_push_user;
  261. this.stack_pop = lms_storage_stack_pop;
  262. this.stack_pop_user = lms_storage_stack_pop_user;
  263. this.stack_length = lms_storage_stack_length;
  264. this.stack_length_user = lms_storage_stack_length_user;
  265. this.stack_clear = lms_storage_stack_clear;
  266. this.stack_clear_user = lms_storage_stack_clear_user;
  267. this.stack_getAll = lms_storage_stack_getAll;
  268. this.stack_getAll_user = lms_storage_stack_getAll_user;
  269. this.getAllUsers = lms_storage_getAllUsers;
  270. this.sv_user = sv_user;
  271. this.sv_course = sv_course;
  272. this.sv_sco = sv_sco;
  273. }
  274. var STORAGEAPI = new STORAGEAPIobject();
  275. var STAPI = STORAGEAPI;