1/** 2 * 表å®é©è 3 * required data-check="å¯ç¨,åé" data-text="" data-check_min="" data-check_max="" 4 */ 5 6/** 7 * è¡¨å®æ¸ é¤ è¨è¨å¸«ä½¿ç¨a tagæç¨ 8 */ 9function formReset(index){ 10 if(typeof(index) == "undefined"){ 11 index = 0; 12 } 13 $("form:eq("+index+")")[0].reset(); 14 return false; 15} 16setTimeout(function(){ 17 $('input').on('keydown', function(e){ 18 if((e.which == 13 || (e.which == 83 && e.ctrlKey)) && $(this).attr("name")){ 19 if(typeof($(this).form)=="undefined"){return false;} 20 formSubmit($("form").index($(this).form())); 21 } 22 return e.which !== 13; 23 }); 24 $('textarea').on('keydown', function(e){ 25 if(((e.which == 83 && e.ctrlKey)) && $(this).attr("name")){ 26 if(typeof($(this).form)=="undefined"){return false;} 27 formSubmit($("form").index($(this).form())); 28 } 29 }); 30}, 500);//æäºinputæ¯è¼æåºç¾ 31 32$(window).keydown(function(event) { 33 if ((event.which == 83 && event.ctrlKey)){ 34 event.preventDefault(); 35 } 36}); 37 38/** 39 * å³éè¡¨å® 40 */ 41var onlyValues=[]; 42function formSubmit(index) { 43 if((typeof(tinymce) != "undefined")){ 44 tinymce.triggerSave(); 45 } 46 onlyValues=[]; 47 if((typeof(index) == "undefined") || isNaN(index)){ 48 index = 0; 49 } 50 51 tempInput = []; 52 msg = ""; 53 $(".chosen-container").removeClass("is-invalid"); 54 $("div").removeClass("is-invalid"); 55 $("form:eq("+index+")").find('input,textarea,select').removeClass("is-invalid"); 56 $("form:eq("+index+")").find('input,textarea,select').each(function(index) { 57 if(!$(this).attr("name")){ 58 return ; 59 } 60 if($(this).data("limit_ch_en")){ 61 msg += " [" + ($(this).data("text")?$(this).data("text"):$(this).attr("name")) + "] " + _jsMsg["LEAST_SELECT"] + " " + $(this).data("check_min") + " " + _jsMsg["ITEM"] + "\n"; 62 $(this).addClass("is-invalid"); 63 } 64 if($(this).attr("type") == "checkbox" || $(this).attr("type") == "radio"){ 65 if($(this).data("check_min")){ 66 if($("input[name='"+$(this).attr("name")+"']:checked").length < $(this).data("check_min")){ 67 msg += " [" + ($(this).data("text")?$(this).data("text"):$(this).attr("name")) + "] " + _jsMsg["LEAST_SELECT"] + " " + $(this).data("check_min") + " " + _jsMsg["ITEM"] + "\n"; 68 $(this).parents("div:eq(0)").addClass("is-invalid"); 69 } 70 } 71 if($(this).data("check_need")){ 72 if($("input[name='"+$(this).attr("name")+"']:checked").length < $(this).data("check_need")){ 73 msg += " [" + ($(this).data("text")?$(this).data("text"):$(this).attr("name")) + "] " + _jsMsg["CHECK_NEED"] + $(this).data("text") + "\n"; 74 $(this).parents("div:eq(0)").addClass("is-invalid"); 75 } 76 } 77 if($(this).data("check_max")){ 78 if($("input[name='"+$(this).attr("name")+"']:checked").length > $(this).data("check_max")){ 79 msg += " [" + ($(this).data("text")?$(this).data("text"):$(this).attr("name")) + "] " + _jsMsg["SELECT_ACHIEVE_MAX"] + " " + $(this).data("check_max") + " " + _jsMsg["ITEM"] + "\n"; 80 $(this).parents("div:eq(0)").addClass("is-invalid"); 81 } 82 } 83 }else{ 84 if($(this).attr("required") && $(this).val()==""){ 85 // if ($("<input />").prop("required") === undefined || $(this).data("type")=="chosen" || $(this).is(":hidden")){//測試çè¦½å¨æ¯å¦æ¯æ´HTML5çrequired 86 msg += " [" + ($(this).data("text")?$(this).data("text"):$(this).attr("name")) + "] " + _jsMsg["FIELD_REQURED"] + "\n"; 87 if($(this).data("type")=="chosen"){ 88 $(this).next("div").addClass("is-invalid"); 89 }else{ 90 tempInput.push(this); 91 $(this).addClass("is-invalid"); 92 } 93 // } 94 } 95 if($(this).data("check") && $(this).val()){ 96 var check = $(this).data("check").split(","); 97 var dataText = $(this).data("text"); 98 var dataName = $(this).attr("name"); 99 var dataVal = $(this).val(); 100 var dataObj = $(this); 101 check.forEach(function(value){ 102 fun = "is" + value; 103 fun1 = "msg" + value; 104 if(typeof(window[fun]) == "function" && typeof(window[fun1]) == "function"){ 105 try{ 106 if(!eval(fun+"('"+dataVal+"')")){ 107 msg += " [" + (dataText?dataText:dataName) + "] " + _jsMsg["FIELD_FORMAT_ERROR"] + " " + eval(fun1+"()") + "\n"; 108 tempInput.push(dataObj); 109 dataObj.addClass("is-invalid"); 110 } 111 }catch(exception){ 112 msg += " [" + (dataText?dataText:dataName) + "] " + _jsMsg["FIELD_FORMAT_ERROR"] + " " + eval(fun1+"()") + "\n"; 113 tempInput.push(dataObj); 114 dataObj.addClass("is-invalid"); 115 } 116 }else{ 117 console.error("data-check error : "+fun+" is not funtion"); 118 } 119 }); 120 } 121 } 122 }); 123 if($("form:eq("+index+")").find('input[data-check="Password"]')){ 124 parent = ""; 125 $("form:eq("+index+")").find('input[data-check="Password"]').each(function(index){ 126 if(parent && (parent!=$(this).val())){ 127 msg += _jsMsg["USER_PASSWORD_CHECK_ERROR"]; 128 $(this).addClass("is-invalid"); 129 tempInput.push(this); 130 } 131 parent = $(this).val(); 132 }); 133 } 134 135 if(msg){ 136 $(tempInput).each(function(){ 137 if($(this).is(":visible")){ 138 $(this).focus(); 139 return false; 140 } 141 }); 142 alert(msg); 143 return false; 144 }else{ 145 var f = $("form:eq("+index+")");//$('#hiddenSubmitButton'+index).closest("form"); 146 if((f.attr("method")=="post" || f.attr("method")=="POST") && (window.location.pathname.indexOf("/serback/")>=0) && (window.location.pathname.indexOf("/add")==-1)){ 147 $.ajax({
148 type : "POST", 149 url : f.attr('action'), 150 data : f.serialize(), 151 success: function(data){ 152 toastr.options = {"positionClass": "toast-bottom-right","progressBar": true}; 153 var temp = data; 154 if(typeof(data)!="object"){ 155 try{ 156 temp = JSON.parse(data); 157 }catch(exception){ 158 temp.message = data; 159 } 160 } 161 if(temp.response){ 162 toastr.success(temp.message); 163 }else{ 164 toastr.error(temp.message); 165 } 166 } 167 }); 168 }else{ 169 $("form:eq("+index+")").find("button[type='submit']").trigger('click');;//$('#hiddenSubmitButton'+index).trigger('click'); 170 setTimeout(loadingStart, 100); 171 } 172 } 173} 174 175/** 176 * 鲿¢éè¤æäº¤&表å®ç¢ºèª 177 */ 178$(function(){ 179 $("form").each(function(index,el){ 180 $("form:eq("+index+")").append('<button type="submit" style="display:none" id="hiddenSubmitButton'+index+'"></button>'); 181 $("form:eq("+index+")").on('submit', function(){ 182 return oneSubmit(); 183 }); 184 185 }); 186}); 187var oneSubmitCount = 0; 188function oneSubmit() { 189 oneSubmitCount++; 190 return (oneSubmitCount==1); 191} 192 193 194 195function isIDCard(id){ 196 var head = "ABCDEFGHJKLMNPQRSTUVXYWZIO"; 197 var A1 = new Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3); 198 var A2 = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5); 199 var Mx = new Array(0, 8, 7, 6, 5, 4, 3, 2, 1, 1); 200 var i = head.indexOf(id.charAt(0)); 201 if((id.length != 10) || (i == -1)){ 202 return false; 203 } 204 205 var sum = A1[i] + A2[i] * 9; 206 207 for(i = 1; i < 10; i++){ 208 v = parseInt(id.charAt(i)); 209 if(isNaN(v)){ 210 return false; 211 } 212 sum = sum + v * Mx[i]; 213 } 214 215 return ((sum % 10) == 0); 216} 217 218function msgIDCard(){ 219 return ""; 220} 221 222function isAccount(account){ 223 var checkString=/[^a-zA-Z0-9_@.]/g; 224 return (account.length > 4) && 225 (account.length < 191) && 226 (!account.match(checkString)); 227} 228 229function msgAccount(){ 230 return _jsMsg["LAN_5_49_AND_SYMBOL"]; 231} 232 233function isEnglishNumber(string){ 234 var checkString=/[\W]/g; 235 return (!string.match(checkString)); 236} 237 238function msgEnglishNumber(){ 239 return _jsMsg["IS_ENGLISH_OR_NUMBER"]; 240} 241 242function isPassword(password){ 243 var checkString = /^(?=^.{8,255}$)((?=.*[A-Za-z0-9])(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9]))^.*$/; 244 return password.match(checkString); 245} 246 247function isLimitChEn(string){ 248 var checkString=/[^\a-\z\A-\Z\u4E00-\u9FA5]/g; 249 return (!string.match(checkString)); 250} 251 252function msgLimitChEn(){ 253 return _jsMsg["IS_ENGLISH_OR_CHINESE"]; 254} 255 256function msgPassword(){ 257 return _jsMsg["PASSWORD_MSG"]; 258} 259 260function isEmail(email){ 261 var checkString = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z]+$/; 262 if(email.match(checkString)){ 263 var result; 264 $.ajax({ 265 url: _jsPath+"/ajax.php", 266 type: "GET", 267 data: { 268 isEmail: email 269 }, 270 dataType:'text', 271 async: false, 272 success: function(msg){ 273 result = (msg == "ok"); 274 } 275 }); 276 return result; 277 }else{ 278 return false; 279 } 280} 281 282function msgEmail(){ 283 return ""; 284} 285 286function isNumber(number){ 287 return !isNaN(number); 288} 289 290function msgNumber(){ 291 return _jsMsg["IS_NUMBER"]; 292} 293 294function isNumberMin450(number){ 295 return !isNaN(number) && (number>=450 || number==0); 296} 297 298function msgNumberMin450(){ 299 return _jsMsg["IS_NUMBER_MIN450"]; 300} 301 302function isOnly(data){ 303 if(onlyValues.indexOf(data)>=0){ 304 return false; 305 } 306 onlyValues.push(data); 307 return true; 308} 309 310function msgOnly(){ 311 return _jsMsg["IS_ONLY"]; 312} 313 314 315function isSenderName(data){ 316 var checkString=/['`!ï¼ #%&*+\""<>|_\[\],ï¼]/g; 317 return (stringBytes(data)<=10) && 318 (!data.match(checkString)); 319} 320 321function msgSenderName(){ 322 return _jsMsg["IS_10SIZE_NOT_SPECIAL"]; 323} 324 325function isSenderPhone(data){ 326 var checkString=/[^0-9_()#-]/g; 327 return (stringBytes(data)<=20) && 328 (!data.match(checkString)); 329} 330 331function msgSenderPhone(){ 332 return _jsMsg["IS_20SIZE_NOT_SPECIAL"]; 333} 334 335function isSenderCellPhone(data){ 336 var checkString = /^09[0-9]{8}$/; 337 return !!data.match(checkString); 338} 339 340function msgSenderCellPhone(){ 341 return _jsMsg["IS_NUMBER_10SIZE_09HEAD"]; 342} 343
344function isSenderZipCode(data){ 345 return !isNaN(data) && (stringBytes(data)<=5); 346} 347 348function msgSenderZipCode(){ 349 return _jsMsg["IS_NUMBER_5SIZE"]; 350} 351 352function isSenderAddress(data){ 353 return (stringBytes(data)<=60); 354} 355 356function msgSenderAddress(){ 357 return _jsMsg["IS_60SIZE"]; 358} 359 360 361 362 363 364/** 365 * è¨ç®é·åº¦ (䏿2 è±æ1) 366 */ 367function stringBytes(c) { 368 var n = c.length,s; 369 var len = 0; 370 for (var i = 0; i < n; i++) { 371 s = c.charCodeAt(i); 372 while (s > 0) { 373 len++; 374 s = s >> 8; 375 } 376 } 377 return len; 378}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.