main.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. function Proxy() {};
  2. Proxy.prototype.root = function(){
  3. return www + '/main/inc/ajax/link.ajax.php';
  4. }
  5. Proxy.prototype.post = function(data, f){
  6. if(typeof(sec_token)!=='undefined'){
  7. data.sec_token = sec_token;
  8. }
  9. $.post(this.root(), data, f, 'json');
  10. }
  11. var Link = new Proxy();
  12. Link.hide = function(c_id, id, f)
  13. {
  14. var data = {
  15. c_id: c_id,
  16. id: id,
  17. action: 'hide_link'
  18. };
  19. this.post(data, f);
  20. };
  21. Link.show = function(c_id, id, f)
  22. {
  23. var data = {
  24. c_id: c_id,
  25. id: id,
  26. action: 'show_link'
  27. };
  28. this.post(data, f);
  29. };
  30. Link.del = function(c_id, id, f)
  31. {
  32. var data = {
  33. c_id: c_id,
  34. id: id,
  35. action: 'delete_link'
  36. };
  37. this.post(data, f);
  38. };
  39. Link.delete_by_course = function(c_id, session_id, f)
  40. {
  41. var data = {
  42. c_id: c_id,
  43. session_id: session_id,
  44. action: 'delete_by_course'
  45. };
  46. this.post(data, f);
  47. };
  48. Link.sort = function(c_id, ids, f){
  49. var data = {
  50. c_id: c_id,
  51. ids: ids,
  52. action: 'sort_links'
  53. };
  54. this.post(data, f);
  55. };
  56. Link.validate = function(c_id, id, f)
  57. {
  58. var data = {
  59. c_id: c_id,
  60. id: id,
  61. action: 'validate_link'
  62. };
  63. this.post(data, f);
  64. };
  65. var LinkCategory = new Proxy();
  66. LinkCategory.del = function(c_id, id, f)
  67. {
  68. var data = {
  69. c_id: c_id,
  70. id: id,
  71. action: 'delete_category'
  72. };
  73. this.post(data, f);
  74. };
  75. LinkCategory.sort = function(c_id, ids, f){
  76. var data = {
  77. c_id: c_id,
  78. ids: ids,
  79. action: 'sort_categories'
  80. };
  81. this.post(data, f);
  82. };
  83. var message = {};
  84. message.update = function(data){
  85. text = typeof(data)=='string' ? data : data.message;
  86. $('#messages').html(text)
  87. }