base.dev.js 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. "use strict";
  2. var Config = {
  3. title: "陕西广电融媒体集团",
  4. logoUrl: "http://zyx-data-base.oss-cn-beijing.aliyuncs.com/img/logonew2.png",
  5. baseUrl: "http://zyx-data-base.oss-cn-beijing.aliyuncs.com"
  6. };
  7. document.title = Config.title;
  8. $(".proName").append($("<img src='" + Config.logoUrl + "' alt='" + Config.title + "' class='img-rounded'>"));
  9. var pageName = getPageName();
  10. if (/skeleton/.test(pageName) && !localStorage.login) {
  11. location.href = "./index.html";
  12. }
  13. function getPageName() {
  14. var pathList = location.href.split('/');
  15. return pathList[pathList.length - 1];
  16. }
  17. function showAlert(text, s) {
  18. var ele = $("<div id='local-alert'><i class='glyphicon glyphicon-info-sign'></i>" + text + "</div>");
  19. $(document.body).prepend(ele);
  20. var timeout;
  21. timeout = window.setTimeout(function () {
  22. window.clearTimeout(timeout);
  23. $("#local-alert").addClass("fadeOutRightBig animated infinite");
  24. timeout = window.setTimeout(function () {
  25. window.clearTimeout(timeout);
  26. $("#local-alert").remove();
  27. }, 500);
  28. }, s || 2000);
  29. }
  30. function createTable(ele, theadList, list) {
  31. $(ele + " .localtable").remove();
  32. var pele = $(ele);
  33. var table = $("<table class='table localtable'></table>");
  34. var thead = $("<thead></thead>");
  35. var tbody = $("<tbody></tbody>");
  36. var trHead = $("<tr></tr>");
  37. var theadListL = theadList || [];
  38. var listL = list || [];
  39. theadListL.map(function (v, i) {
  40. var td = $("<td class='" + v.className + " " + (i % 2 === 1 ? 'deepBlue' : '') + "'>" + v.title + "</td>");
  41. trHead.append(td);
  42. });
  43. listL.map(function (v, o) {
  44. var className = o % 2 === 1 ? "oddRow" : "";
  45. var trBody = $("<tr class='" + className + "'></tr>");
  46. theadListL.map(function (titleI) {
  47. var val = titleI.value === "#index" ? o + 1 : v[titleI.value];
  48. titleI.formatValue && (val = titleI.formatValue(val));
  49. var td = $("<td class='" + titleI.className + "'>" + val + "</td>");
  50. trBody.append(td);
  51. });
  52. tbody.append(trBody);
  53. });
  54. thead.append(trHead);
  55. table.append(thead);
  56. table.append(tbody);
  57. pele.append(table);
  58. }
  59. function createPager(totalPage, pageIndex, pele, section) {
  60. $("nav.localnavigation").remove();
  61. var sectionReal = section || 2;
  62. var nav = $("<nav class='localnavigation' aria-label='Page navigation'></nav>");
  63. var ul = $("<ul class='pagination'><li class='proPage'><a href='##' aria-label='Previous'><span aria-hidden='true'>&laquo;</span></a></li></ul>");
  64. var next = $('<li class="nextPage"><a href="##" aria-label="Next"><span aria-hidden="true">&raquo;</span></a></li>');
  65. var minPage = pageIndex - sectionReal > 1 ? pageIndex - sectionReal : 1;
  66. var maxPage = pageIndex + sectionReal < totalPage ? pageIndex + sectionReal : totalPage;
  67. if (minPage !== 1) {
  68. ul.append($("<li class='inPage'><a href='##'>1</a></li>"));
  69. ul.append($("<li><a href='##'>...</a></li>"));
  70. }
  71. for (var i = minPage; i <= maxPage; i++) {
  72. var li = $("<li class='inPage " + (i == pageIndex ? "selectPage" : "") + "'><a href='##'>" + i + "</a></li>");
  73. ul.append(li);
  74. }
  75. if (maxPage !== totalPage) {
  76. ul.append($("<li><a href='##'>...</a></li>"));
  77. ul.append($("<li class='inPage'><a href='##'>" + totalPage + "</a></li>"));
  78. }
  79. ul.append(next);
  80. nav.append(ul);
  81. $(pele).append(nav);
  82. }