base.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. var ajaxRequest = function (url) {
  2. var params = arguments[1] ? arguments[1] : {};
  3. var method = arguments[2] ? arguments[2] : "post";
  4. method = method != "post" && method != "get" ? "post" : method;
  5. var datatype = arguments[3] ? arguments[3] : "json";
  6. for (var key in params) {
  7. if (params[key]) {
  8. params[key] = (params[key])
  9. }
  10. }
  11. var result = {};
  12. $.ajax({
  13. type: method,
  14. url: url,
  15. data: params,
  16. async: false,
  17. dataType: datatype,
  18. success: function (ret_data) {
  19. switch (datatype) {
  20. case "text":
  21. result = ret_data;
  22. break;
  23. default:
  24. result = eval(ret_data);
  25. break
  26. }
  27. },
  28. error: function (XMLHttpRequest, textStatus, errorThrown) {
  29. result = false
  30. }
  31. });
  32. return result
  33. };
  34. var storage = {
  35. isLocalStorage: (window.localStorage ? true : false),
  36. set: function (a, b) {
  37. if (this.isLocalStorage) {
  38. try {
  39. localStorage[a] = b
  40. } catch (c) {
  41. return
  42. }
  43. }
  44. },
  45. get: function (a) {
  46. if (this.isLocalStorage) {
  47. return localStorage[a]
  48. }
  49. },
  50. del: function (a) {
  51. if (this.isLocalStorage) {
  52. localStorage.removeItem(a)
  53. }
  54. },
  55. clear: function () {
  56. if (this.isLocalStorage) {
  57. localStorage.clear()
  58. }
  59. },
  60. json_set: function (a, b) {
  61. if (this.isLocalStorage) {
  62. try {
  63. localStorage[a] = JSON.stringify(b)
  64. } catch (c) {
  65. return
  66. }
  67. }
  68. },
  69. json_get: function (a) {
  70. if (this.isLocalStorage) {
  71. var b = localStorage[a] ? JSON.parse(localStorage[a]) : "";
  72. return b
  73. }
  74. },
  75. display: function () {
  76. if (this.isLocalStorage) {
  77. var b = "";
  78. for (var a = 0; a < localStorage.length; a++) {
  79. key = localStorage.key(a);
  80. value = localStorage.getItem(key);
  81. b += "\nkey:" + key + " value:" + value
  82. }
  83. return b
  84. }
  85. }
  86. };
  87. var filterTitle = function (a) {
  88. if (a.val() == a.attr("title")) {
  89. return ""
  90. } else {
  91. return a.val()
  92. }
  93. };
  94. $(".selt select ").change(function () {
  95. var a = "";
  96. $(this).find("option").each(function () {
  97. if ($(this).attr("selected") == true) {
  98. a = $(this).html();
  99. return false
  100. }
  101. });
  102. $(this).siblings().removeClass("c_default").html(a)
  103. });
  104. $(".selt select ").click(function () {
  105. if ($(".calendar ").css("display") == "block") {
  106. $(".calendar ").hide()
  107. }
  108. });
  109. $(function () {
  110. $("a[tag],span[tag],i[tag]").click(function () {
  111. var b = $(this).attr("tag");
  112. if (b != "") {
  113. var a = $_CONFIG.domain + "ajax/in/trace.ajax.php?jsoncallback=?&tag=" + b;
  114. $.getJSON(a)
  115. }
  116. })
  117. });