proxy.js 748 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /**
  2. * Define a client proxy for ajax calls.
  3. */
  4. function Proxy() {};
  5. Proxy.prototype.root = function(){
  6. return context.ajax;
  7. }
  8. Proxy.prototype.post = function(data, f){
  9. if(typeof(context)!=='undefined' && typeof(context.sec_token)!=='undefined'){
  10. data.sec_token = context.sec_token;
  11. }
  12. $.post(this.root(), data, f, 'json');
  13. }
  14. var notebook = new Proxy();
  15. notebook.remove = function(c_id, id, f)
  16. {
  17. var data = {
  18. c_id: c_id,
  19. id: id,
  20. action: 'remove'
  21. };
  22. this.post(data, f);
  23. };
  24. notebook.remove_by_course = function(c_id, session_id, f)
  25. {
  26. var data = {
  27. c_id: c_id,
  28. session_id: session_id,
  29. action: 'remove_by_course'
  30. };
  31. this.post(data, f);
  32. };