main.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. (function () {
  2. $("[data-toggle='tooltip']").tooltip();
  3. })();
  4. function showError($msg,$id) {
  5. if(!$id){
  6. $id = "#form-error-message"
  7. }
  8. $($id).addClass("error-message").removeClass("success-message").text($msg);
  9. return false;
  10. }
  11. function showSuccess($msg,$id) {
  12. if(!$id){
  13. $id = "#form-error-message"
  14. }
  15. $($id).addClass("success-message").removeClass("error-message").text($msg);
  16. return true;
  17. }
  18. Date.prototype.format = function(fmt) {
  19. var o = {
  20. "M+" : this.getMonth()+1, //月份
  21. "d+" : this.getDate(), //日
  22. "h+" : this.getHours(), //小时
  23. "m+" : this.getMinutes(), //分
  24. "s+" : this.getSeconds(), //秒
  25. "q+" : Math.floor((this.getMonth()+3)/3), //季度
  26. "S" : this.getMilliseconds() //毫秒
  27. };
  28. if(/(y+)/.test(fmt)) {
  29. fmt=fmt.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
  30. }
  31. for(var k in o) {
  32. if(new RegExp("("+ k +")").test(fmt)){
  33. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length==1) ? (o[k]) : (("00"+ o[k]).substr((""+ o[k]).length)));
  34. }
  35. }
  36. return fmt;
  37. };