gis.common.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. var gis = gis || {};
  2. gis.script = function() {
  3. };
  4. gis.script.consolelog=function(t,o){
  5. //console.log(t,o);
  6. }
  7. gis.script.sqlProcessFailed=function(e){
  8. console.log('error',e.error.errorMsg);
  9. }
  10. /*
  11. * ajax封装函数
  12. */
  13. gis.script.jsonAjax= function(obj,exeJson){
  14. var ajaxInfo={
  15. type : 'post',
  16. dataType : 'json',
  17. //contentType : 'application/json;charset=utf-8',
  18. //timeout : 10000, //超时时间设置,单位毫秒
  19. cache : false,// 不从缓存中去数据
  20. async : true,
  21. //url : obj.url,
  22. //data : JSON.stringify(jsondate),
  23. //headers:headinfo,
  24. success : function(data) {
  25. if(exeJson){
  26. exeJson(data);
  27. }
  28. },
  29. error : function(jqXHR, textStatus, errorThrown) {
  30. //alert(jqXHR.responseText);
  31. }
  32. };
  33. ajaxInfo.url=obj.url;
  34. ajaxInfo.data=obj.data||{};
  35. if(typeof(obj.async)!="undefined"){
  36. ajaxInfo.async=obj.async
  37. }
  38. if(typeof(obj.contentType)!="undefined"){
  39. //alert(obj.contentType);
  40. ajaxInfo.contentType=obj.contentType;
  41. }
  42. //alert(ajaxInfo);
  43. $.ajax(ajaxInfo);
  44. }
  45. /*
  46. * 判断是数值
  47. */
  48. gis.script.isNum=function(value){
  49. if(typeof(value)!='undefined'){
  50. var result = true;
  51. var pattern = /^\d*(\.\d*)?$/;
  52. if (!pattern.test(value)) result = false;
  53. var num = parseFloat(value);
  54. if (isNaN(num)) result = false;
  55. return result;
  56. }
  57. return false;
  58. }
  59. /*
  60. * 判断是空字符串
  61. */
  62. gis.script.isBlank=function(value){
  63. if(value){
  64. value=value+"";
  65. for(var i=0; i<value.length; i++) {
  66. var c = value.charAt(i);
  67. if ((c!=' ')&&(c!='\n')&&(c!='\t')) return false;
  68. }
  69. }
  70. return true;
  71. }
  72. /*
  73. * 判断不是空字符串
  74. */
  75. gis.script.isNotBlank=function(value){
  76. if(typeof(value)!='undefined'){
  77. value=value+"";
  78. for(var i=0; i<value.length; i++) {
  79. var c = value.charAt(i);
  80. if ((c!=' ')&&(c!='\n')&&(c!='\t')) return true;
  81. }
  82. }
  83. return false;
  84. }