/rabbitmq-server-2.8.4/plugins-src/rabbitmq-jsonrpc-channel/priv/www/rabbitmq-jquery.js

# · JavaScript · 48 lines · 31 code · 2 blank · 15 comment · 2 complexity · c6200fe28bab8aff553488ef2eb1a459 MD5 · raw file

  1. // The contents of this file are subject to the Mozilla Public License
  2. // Version 1.1 (the "License"); you may not use this file except in
  3. // compliance with the License. You may obtain a copy of the License
  4. // at http://www.mozilla.org/MPL/
  5. //
  6. // Software distributed under the License is distributed on an "AS IS"
  7. // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
  8. // the License for the specific language governing rights and
  9. // limitations under the License.
  10. //
  11. // The Original Code is RabbitMQ.
  12. //
  13. // The Initial Developer of the Original Code is VMware, Inc.
  14. // Copyright (c) 2007-2012 VMware, Inc. All rights reserved.
  15. //
  16. var JsonRpc;
  17. var RabbitMQ;
  18. (function () {
  19. var Support = {
  20. extend: jQuery.extend,
  21. bindEvent: function (elt, event, cb) {
  22. jQuery(elt).bind(event, cb);
  23. },
  24. each: function (collection, callback) {
  25. jQuery.each(collection, function (key, value) { callback(value) });
  26. },
  27. ajaxPost: function (url, customHeaders, bodyString, callback) {
  28. return new jQuery.ajax({ url: url,
  29. type: 'post',
  30. beforeSend: function (xhr) {
  31. for (var header in customHeaders) {
  32. if (customHeaders.hasOwnProperty(header)) {
  33. xhr.setRequestHeader(header,
  34. customHeaders[header]);
  35. }
  36. }
  37. },
  38. contentType: 'application/json',
  39. accepts: {json: 'application/json'},
  40. data: bodyString,
  41. complete: callback });
  42. }
  43. };
  44. JsonRpc = JsonRpc_ModuleFactory(Support);
  45. RabbitMQ = RabbitMQ_ModuleFactory(JsonRpc, Support);
  46. })();