25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

handler.js 2.0 KiB

13 yıl önce
13 yıl önce
13 yıl önce
13 yıl önce
13 yıl önce
13 yıl önce
13 yıl önce
13 yıl önce
13 yıl önce
13 yıl önce
13 yıl önce
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
  2. // MIT License. See license.txt
  3. function $c(command, args, callback, error, no_spinner, freeze_msg, btn) {
  4. return wn.request.call({
  5. args: $.extend(args, {cmd: command}),
  6. success: callback,
  7. error: error,
  8. btn: btn,
  9. freeze: freeze_msg,
  10. show_spinner: !no_spinner
  11. })
  12. }
  13. // For calling an object
  14. function $c_obj(doclist, method, arg, callback, no_spinner, freeze_msg, btn) {
  15. if(arg && typeof arg!='string') arg = JSON.stringify(arg);
  16. args = {
  17. cmd:'runserverobj',
  18. args: arg,
  19. method: method
  20. };
  21. if(typeof doclist=='string')
  22. args.doctype = doclist;
  23. else
  24. args.docs = wn.model.compress(doclist)
  25. return wn.request.call({
  26. args: args,
  27. success: callback,
  28. btn: btn,
  29. freeze: freeze_msg,
  30. show_spinner: !no_spinner
  31. });
  32. }
  33. // For call a page metho
  34. function $c_page(module, page, method, arg, callback, no_spinner, freeze_msg, btn) {
  35. if(arg && typeof arg!='string') arg = JSON.stringify(arg);
  36. return wn.request.call({
  37. args: {
  38. cmd: module+'.page.'+page+'.'+page+'.'+method,
  39. arg: arg,
  40. method: method
  41. },
  42. success: callback,
  43. btn: btn,
  44. freeze: freeze_msg,
  45. show_spinner: !no_spinner
  46. });
  47. }
  48. // For calling an for output as csv
  49. function $c_obj_csv(doclist, method, arg) {
  50. // single
  51. var args = {}
  52. args.cmd = 'runserverobj';
  53. args.as_csv = 1;
  54. args.method = method;
  55. args.arg = arg;
  56. if(doclist.substr)
  57. args.doctype = doclist;
  58. else
  59. args.docs = wn.model.compress(doclist);
  60. // open
  61. open_url_post(wn.request.url, args);
  62. }
  63. // call a url as POST
  64. function open_url_post(URL, PARAMS, new_window) {
  65. var temp=document.createElement("form");
  66. temp.action=URL;
  67. temp.method="POST";
  68. temp.style.display="none";
  69. if(new_window){
  70. temp.target = '_blank';
  71. }
  72. for(var x in PARAMS) {
  73. var opt=document.createElement("textarea");
  74. opt.name=x;
  75. var val = PARAMS[x];
  76. if(typeof val!='string')
  77. val = JSON.stringify(val);
  78. opt.value=val;
  79. temp.appendChild(opt);
  80. }
  81. document.body.appendChild(temp);
  82. temp.submit();
  83. return temp;
  84. }