1jQuery(function ($) { 2 jQuery(document).ready(function () { 3 $('#addRegBtn').on('click', function () { 4 $("body, input[type='button']").css('cursor', 'progress'); 5 var url = window.location.protocol + '//' + window.location.host + (window.location.href.includes('/wes/') ? '/wes' : '') + '/recaptcha'; 6 $.ajax({ 7 url: url, 8 method: 'POST', 9 //data: {data: grecaptcha.getResponse()}, 10 data: { data: $('#checkword').val() }, 11 }).done(function (response) { 12 var result = JSON.parse(response); 13 if (result.success == true) { 14 addReg(false); 15 } else { 16 $('body').css('cursor', 'default'); 17 $("input[type='button']").css('cursor', 'pointer'); 18 alert('è«è¼¸å ¥æ£ç¢ºçé©è碼ï¼'); 19 refresh_captcha(); 20 } 21 }); 22 }); 23 24 $('#isFirst').on('click', function () { 25 console.log('isFirst click'); 26 27 var phone = $('#txtPhone').val(); 28 var name = $('#txtName').val(); 29 var idNo = $('#txtId').val(); 30 31 console.log(phone + name + idNo); 32 33 if (!checkNameAndPhone(name, phone)) { 34 resetCursor(); 35 return; 36 } 37 38 $('#firstOrderError').css('display', 'none'); 39 $("body, input[type='button']").css('cursor', 'progress'); 40 41 // å æèï¼æèæåï¼çæ 碼 0 æ 1ï¼æå»ºç«åè¨ºè³æ 42 addReg(true, function (regStatus, xml) { 43 if (!isRegSuccess(regStatus)) { 44 resetCursor(); 45 showFirstOrderError(getRegMessage(xml) || 'å診é ç´å¤±æï¼è«ç¨å¾å試ï¼'); 46 return; 47 } 48 49 $.ajax({ 50 url: 'https://regweb.westgarden.com.tw/GetOrderV8/WebOrder.svc/FirstOrder', 51 method: 'POST', 52 // contentType: 'application/json', 53 data: JSON.stringify({ 54 order: { 55 IDNO: idNo, 56 NAME: name, 57 HTEL: phone, 58 }, 59 }), 60 }) 61 .done(function (response) { 62 displayAddResult(xml); 63 // æèå·²æç«ï¼å åè¨ºè³ææªå»ºæªï¼ä¿çæè並æç¤ºè³æ«æª¯è£ä»¶ 64 if (!response || response.d !== 'OK') { 65 appendFirstOrderNotice(); 66 } 67 resetCursor(); 68 }) 69 .fail(function () { 70 displayAddResult(xml); 71 appendFirstOrderNotice(); 72 resetCursor(); 73 }); 74 }); 75 }); 76 77 $('#queryRegBtn').on('click', function () { 78 $("body, input[type='button']").css('cursor', 'progress'); 79 var url = window.location.protocol + '//' + window.location.host + (window.location.href.includes('/wes/') ? '/wes' : '') + '/recaptcha'; 80 $.ajax({ 81 url: url, 82 method: 'POST', 83 //data: {data: grecaptcha.getResponse()}, 84 data: { data: $('#checkword').val() }, 85 }).done(function (response) { 86 var result = JSON.parse(response); 87 if (result.success == true) { 88 queryReg(false); 89 } else { 90 $('body').css('cursor', 'default'); 91 $("input[type='button']").css('cursor', 'pointer'); 92 alert('è«è¼¸å ¥æ£ç¢ºçé©è碼ï¼'); 93 refresh_captcha(); 94 } 95 }); 96 }); 97 98 $('#isFirstQuery').on('click', function () { 99 $("body, input[type='button']").css('cursor', 'progress'); 100 queryReg(true); 101 }); 102 103 $('#notFirst').on('click', function () { 104 //grecaptcha.reset(); 105 refresh_captcha(); 106 $('#checkFirst').css('display', 'none'); 107 $('#notFirstNote, #notFirstNote p').css('display', 'block'); 108 $('#regSubmit').css('display', 'block'); 109 110 scrollToMiddle('#notFirstNote'); 111 }); 112 113 $('#cancelRegBtn').on('click', function () { 114 $('#cancelRegBtn').css('display', 'none'); 115 $('#confirmCancel').css('display', 'block'); 116 }); 117 118 $('#confirmNo').on('click', function () { 119 $('#cancelRegBtn').css('display', 'block'); 120 $('#confirmCancel').css('display', 'none'); 121 }); 122 123 $('#confirmYes').on('click', function () { 124 $("body, input[type='button']").css('cursor', 'progress'); 125 $.each($('.appointment:checked'), function (i, ap) { 126 var self = this; 127 var info = $(this).parent().parent(); 128 var dr = info.attr('dr'); 129 var dept = info.attr('dept'); 130 var schAp = info.attr('schAp'); 131 var schDate = info.attr('schDate'); 132 var isFirst = info.attr('isFirst'); 133 var patNo = info.attr('patNo'); 134 var idNo = info.attr('idNo'); 135 var birth = info.attr('birth'); 136 137 $.ajax({ 138 url: window.location.protocol + '//' + window.location.host + (window.location.href.includes('/wes/') ? '/wes' : '') + '/process-reg', 139 method: 'POST', 140 data: { 141 data: { 142 type: 'cancel', 143 patNo: patNo, 144 idNo: idNo, 145 birth: birth, 146 schDate: schDate, 147 schAp: schAp, 148 dept: dept, 149 dr: dr, 150 isFirst: isFirst, 151 }, 152 }, 153 }).done(function (xml) { 154 $.each($(xml).find('Appointment'), function (i, ap) { 155 if (dr == $(ap).find('Dr')[0].innerHTML && dept == $(ap).find('Dept')[0].innerHTML && schAp == $(ap).find('SchAp')[0].innerHTML && schDate == $(ap).find('SchDateString')[0].innerHTML) { 156 var text = $(ap).find('Message')[0].innerHTML; 157 $(self) 158 .parent() 159 .html('<div>
159' + text + '</div>'); 160 return false; 161 } 162 }); 163 if ($(document).find('input.appointment').length == 0) { 164 $('#cancelRegBtn').css('display', 'none'); 165 } 166 }); 167 }); 168 if ($(document).find('input.appointment').length > 0) { 169 $('#cancelRegBtn').css('display', 'block'); 170 } 171 $('#confirmCancel').css('display', 'none'); 172 $('body').css('cursor', 'default'); 173 $("input[type='button']").css('cursor', 'pointer'); 174 }); 175 176 $('#refresh-captcha').on('click', function () { 177 refresh_captcha(); 178 }); 179 }); 180 181 function addReg(isFirst, onBooked) { 182 var dr = $('#bookDr').text(); 183 var dept = $('#bookDept').text(); 184 var schDate = $('#bookSchDate').text(); 185 var schAp = $('#bookSchAp').text(); 186 187 var textBirth = $('#txtBirth').val(); 188 var textId = $('#txtId').val(); 189 190 if (checkIdAndBirth(textId, textBirth) == false) { 191 //grecaptcha.reset(); 192 refresh_captcha(); 193 $('body').css('cursor', 'default'); 194 $("input[type='button']").css('cursor', 'pointer'); 195 return; 196 } 197 198 var birth = verifyBirth(textBirth); 199 var isIdno = verifyId(textId); 200 var patNo = '', 201 idNo = ''; 202 if (isIdno == false) { 203 patNo += textId; 204 } else { 205 idNo += textId; 206 } 207 let protocol = window.location.protocol; // æ¹çºç¶åé£ç·å¾éè¨åå®ï¼é¿å å §ç¶²ç¡æ³æèï¼ 208 var url = protocol + '//regweb.westgarden.com.tw/Regsource/regws.asmx/Reg_Book?strPatno=' + patNo + '&strIdno=' + idNo + '&strBirth=' + birth + '&strWebword=&strSchdate=' + schDate + '&strSchap=' + schAp + '&strDept=' + dept + '&strDr=' + dr + '&strFirstvisit='; 209 // var url = "http://regweb.westgarden.com.tw/Regsource/regws.asmx/Reg_Book?strPatno=" + patNo + "&strIdno=" + idNo + "&strBirth=" + birth + "&strWebword=&strSchdate=" + schDate + "&strSchap=" + schAp + "&strDept=" + dept + "&strDr=" + dr + "&strFirstvisit="; 210 211 if (isFirst) url += 'true'; 212 $.ajax({ 213 url: url, 214 // url: window.location.protocol + "//" + window.location.host + (window.location.href.includes('/wes/')) ? '/wes' : '' + "/process-reg", 215 // method: "POST", 216 // data: { 217 // data: { 218 // "type":"add", 219 // "patNo":patNo, 220 // "idNo":idNo, 221 // "birth":birth, 222 // "schDate":schDate, 223 // "schAp":schAp, 224 // "dept":dept, 225 // "dr":dr, 226 // "isFirst":(isFirst)?"true":"", 227 // } 228 // } 229 }) 230 .done(function (xml, status, jqXHR) { 231 xml = jqXHR.responseText; 232 233 // å診æèççµæäº¤ç±å¼å«ç«¯ä¾çæ ç¢¼å¤æ· 234 if (typeof onBooked === 'function') { 235 onBooked(getRegStatus(xml), xml); 236 return; 237 } 238 239 if ($(xml).find('Appointment').length == 0) { 240 var msg = $(xml).find('Message')[0].innerHTML; 241 if (msg.indexOf('ç¡ç æ·è') >= 0) { 242 $('#toSubmit').css('display', 'none'); 243 $('#regSubmit').css('display', 'none'); 244 $('#checkFirst').css('display', 'block'); 245 $('#first-fieldsets').css('display', 'block'); 246 $('#notFirstNote').css('display', 'none'); 247 $('input').prop('disabled', false); 248 resetCursor(); 249 250 scrollToMiddle('#checkFirst'); 251 252 return; 253 } else if (msg.indexOf('身åèèé¯èª¤') >= 0 || msg.indexOf('ç æ·è碼é¯èª¤') >= 0) { 254 $('#invalidId').css('display', 'block'); 255 resetCursor();
256 scrollToMiddle('#invalidId'); 257 return; 258 } 259 //grecaptcha.reset(); 260 refresh_captcha(); 261 } else { 262 if ($(xml).find('Appointment SchDate').length == 0) { 263 refresh_captcha(); 264 $('#checkFirst').css('display', 'none'); 265 $('#notFirstNote, #notFirstNote p').css('display', 'block'); 266 $('#regSubmit').css('display', 'block'); 267 return; 268 } 269 displayAddResult(xml); 270 } 271 resetCursor(); 272 }) 273 .fail(function () { 274 resetCursor(); 275 if (typeof onBooked === 'function') { 276 onBooked('', ''); 277 return; 278 } 279 alert('æè失æï¼è«ç¨å¾å試ï¼'); 280 }); 281 } 282 283 function queryReg(isFirst) { 284 var textBirth = $('#txtBirth').val(); 285 var textId = $('#txtId').val(); 286 287 if (checkIdAndBirth(textId, textBirth) == false) { 288 //grecaptcha.reset(); 289 refresh_captcha(); 290 $('body').css('cursor', 'default'); 291 $("input[type='button']").css('cursor', 'pointer'); 292 return; 293 } 294 295 var birth = verifyBirth(textBirth); 296 var isIdno = verifyId(textId); 297 var patNo = '', 298 idNo = ''; 299 if (isIdno == false) { 300 patNo += textId; 301 } else { 302 idNo += textId; 303 } 304 let queryRegUrl = window.location.protocol + '//' + window.location.host + (window.location.href.includes('/wes/') ? '/wes' : '') + '/process-reg'; 305 306 $.ajax({ 307 url: window.location.protocol + '//' + window.location.host + (window.location.href.includes('/wes/') ? '/wes' : '') + '/process-reg', 308 method: 'POST', 309 data: { 310 data: { 311 type: 'query', 312 patNo: patNo, 313 idNo: idNo, 314 birth: birth, 315 isFirst: isFirst ? 'true' : '', 316 }, 317 }, 318 }).done(function (xml) { 319 if ($(xml).find('Appointment').length == 0) { 320 var msg = $(xml).find('Message')[0].innerHTML; 321 if (msg.indexOf('ç¡ç æ·è') >= 0) { 322 $('#regSubmit').css('display', 'none'); 323 $('#checkFirst').css('display', 'block'); 324 $('#notFirstNote').css('display', 'none'); 325 $('input').prop('disabled', false); 326 $('body').css('cursor', 'default'); 327 $("input[type='button']").css('cursor', 'pointer'); 328 329 scrollToMiddle('#checkFirst'); 330 return; 331 } else if (msg.indexOf('身åèèé¯èª¤') >= 0 || msg.indexOf('ç æ·è碼é¯èª¤') >= 0) { 332 $('#invalidId').css('display', 'block'); 333 $('body').css('cursor', 'default'); 334 $("input[type='button']").css('cursor', 'pointer'); 335 scrollToMiddle('#invalidId'); 336 return; 337 } else if (msg.indexOf('ç¡é ç´è³æ') >= 0) { 338 $('#patName').text($(xml).find('PatInfo Name')[0].innerHTML); 339 $('#tblInput').css('display', 'none'); 340 $('#tblList').css('display', 'table'); 341 $('#queryMsg').css('display', 'block'); 342 scrollToMiddle('#tblInput'); 343 } 344 //grecaptcha.reset(); 345 refresh_captcha(); 346 } else { 347 displayQueryResult(xml); 348 } 349 $('body').css('cursor', 'default'); 350 $("input[type='button']").css('cursor', 'pointer'); 351 }); 352 } 353 354 function displayAddResult(xml) { 355 var name; 356 var resultMsg = ''; 357 var isFirstVisit = $(xml).find('PatInfo FirstVisit').length > 0 && $(xml).find('PatInfo FirstVisit')[0].innerHTML === 'true'; 358 var topNotice = ''; 359 var num; 360 var isFail = false;
361 362 if (isFirstVisit) { 363 name = $('#txtName').val(); 364 // 便èçæ ç¢¼å¤æ·ææï¼ä¸è½åªç Message ç¯é»æ¯å¦åå¨ï¼å¤±ææå樣æè©²ç¯é»ï¼ 365 if (isRegSuccess(getRegStatus(xml))) { 366 resultMsg += 'å診æèãåèæå'; 367 // æ°å¢å診æéè¨æ¯ 368 topNotice = '<p>溫馨æéï¼å診æè åèæåï¼</p>'; 369 topNotice += '<p>è«åè¨ºç æ£ï¼çè¨ºç¶æ¥å è³1Fæ«æª¯å¡«å¯«åè¨ºè³æï¼å ±å°æµç¨ï¼è«è¦ä¸æ¹èªªæã</p>'; 370 topNotice += '<div class="yellow">åè¨ºå ±å°æµç¨ï¼</br>(1) 1æ¨åèæ©ãæèãåè</br>(2) ä¾èè³æ«æª¯å¡«åè¨ºå®æ¥é©èä»¶</br>(3) 診éå ±å°æ©ãæå¥ä¿å¡ãå ±å°</br></br>å診æåæä»¶ï¼</br>身åèãå¥ä¿å¡åç¸é身åæä»¶</div>'; 371 } else { 372 resultMsg += getRegMessage(xml) || 'å診æè失æ'; 373 topNotice = ''; 374 isFail = true; 375 } 376 377 num = '--'; 378 } else { 379 name = $(xml).find('PatInfo Name').length > 0 ? $(xml).find('PatInfo Name')[0].innerHTML : ''; 380 if ($(xml).find('Appointment Message').length > 0) { 381 resultMsg += $(xml).find('Appointment Message')[0].innerHTML; 382 } 383 num = $(xml).find('Appointment DigNo').length > 0 ? parseInt($(xml).find('Appointment DigNo')[0].innerHTML) + ' è' : ''; 384 } 385 386 $('#regTopNotes').html(topNotice); 387 388 // var num = $(xml).find('Appointment DigNo').length > 0 ? parseInt($(xml).find('Appointment DigNo')[0].innerHTML) + ' è' : ''; 389 390 var place = ''; 391 if ($(xml).find('Appointment Location').length > 0) { 392 place = $(xml).find('Appointment Location')[0].innerHTML; 393 } else if ($(xml).find('Appointment Room').length > 0) { 394 var room = $(xml).find('Appointment Room')[0].innerHTML; 395 if (room >= '01' && room <= '11') { 396 place = '1 æ¨ ' + room + ' 診'; 397 } else if (room >= '12' && room <= '24') { 398 place = '2 æ¨ ' + room + ' 診'; 399 } else if (room === '27') { 400 place = '6 æ¨ ' + room + ' 診'; 401 } else if (room === '28') { 402 place = 'B1 æ¨ ' + room + ' 診'; 403 } else { 404 place = room + ' 室'; 405 } 406 } 407 408 $('#regName').text(name); 409 $('#resultMsg').text(resultMsg); //æèæåæå¤±æ 410 $('#regNum').text(num); 411 $('#regPlace').text(place); 412 413 var notice = '<ul>'; 414 415 $.each($(xml).find('Notice Notice'), function (i, value) { 416 notice += '<li>' + value.innerHTML + '</li>'; 417 }); 418 419 if ($(xml).find('Notice Notice').length == 0) { 420 notice += '<li>å診åèæéï¼å¸¸æå ç¶æ¥é«å¸«çè¨ºçæ³èç°åï¼å»ºè°å 以網路æé»è©±æ¥è©¢ç診é²åº¦ï¼é¸æé©ç¶æéå°é¢ã</li>'; 421 } 422 notice += '</ul>'; 423 424 $('#regNotes').html(notice); 425 $('#regContentInput').css('display', 'none'); 426 $('#regSubmit').css('display', 'none'); 427 $('#tblInput').css('display', 'none'); 428 $('#tblResult').css('display', 'block'); 429 if (isFail || resultMsg.indexOf('失æ') >= 0) { 430 // æ¶åå¾åªæçä¸ç¬¬ä¸åï¼#regTopNotesï¼ï¼å¤±æè¨æ¯åæ¬å¯«å¨ç¬¬ä¸åç 431 // #resultMsg æä¸ä½µè¢«èèµ·ä¾ï¼å°è´ç«é¢å ¨ç½ãå æ¤æ¶ååå æè¨æ¯è£é²ç¬¬ä¸åã 432 if (resultMsg !== '') { 433 $('#regTopNotes').html('<p style="color:red;">' + resultMsg + '</p>'); 434 } 435 $('#tblResult tr').css('display', 'none'); 436 $('#tblResult tr:first-child').css('display', 'block'); 437 } 438 439 $('#checkFirst').css('display', 'none'); 440 scrollToMiddle('#tblResult'); 441 } 442 443 function displayQueryResult(xml) { 444 var name = $(xml).find('PatInfo Name')[0].innerHTML; 445 var isFirst = $(xml).find('PatInfo FirstVisit')[0].innerHTML; 446 var patNo = $(xml).find('PatInfo PatNo')[0].innerHTML; 447 var IDNo = $(xml).find('PatInfo IDNo')[0].innerHTML; 448 var birth = $(xml).find('PatInfo BirthString')[0].innerHTML; 449 var arr = ['ä¸å', 'ä¸å', 'å¤è¨º']; 450 451 $.each($(xml).find('Appointment'), function (i, ap) { 452 var date = $(ap).find('SchDateString')[0].innerHTML; 453 var dept = $(ap).find('Dept')[0].innerHTML; 454 var deptName = $(ap).find('DeptName')[0].innerHTML; 455 var dr = $(ap).find('Dr')[0].innerHTML; 456 var drName = $(ap).find('DrName')[0].innerHTML; 457 var room = $(ap).find('Room')[0].innerHTML; 458 var digNo = $(ap).find('DigNo')[0].innerHTML; 459 var schAp = $(ap).find('SchAp')[0].innerHTML; 460 461 if (deptName === 'å §ç§') { 462 deptName = 'è¸è ' + deptName; 463 } 464 465 var html = '<tr schDate="' + date + '" schAp="' + schAp + '" dept="' + dept + '" dr="' + dr + '" isFirst="' + isFirst + '" patNo="' + patNo + '" idNo="' + IDNo + '" birth="' + birth + '">'; 466 html += '<td width="12%"><input type="checkbox" name="cbx-' + (i + 1) + '" class="appointment"></td>'; 467 html += '<td width="18%">' + transDate(date) + ' ' + arr[schAp - 1] + '</td>'; 468 html += '<td width="18%">' + deptName + '(' + dept + ')</td>'; 469 html += '<td width="18%">' + drName + '(' + dr + ')</td>'; 470 html += '<td width="15%">' + room + '</td>'; 471 html += '<td width="15%">' + digNo + '</td>'; 472 html += '</tr>'; 473 474 $('#tblList').append(html); 475 }); 476 $('#patName').text(name); 477 $('#tblInput').css('display', 'none'); 478 $('#tblList').css('display', 'table'); 479 $('#cancelRegBtn').css('display', 'block'); 480 scrollToMiddle('#tblList'); 481 } 482 483 function scrollToMiddle(element) { 484 var offset = $(element).offset().top; 485 var elementHeight = $(element).height(); 486 var headerHeight = $('header').height(); 487 var windowHeight = $(window).height() - headerHeight; 488 var newOffset = offset - headerHeight; 489 if (elementHeight >= windowHeight) { 490 newOffset -= 50; 491 } else { 492 newOffset -= (windowHeight - elementHeight) / 2; 493 } 494 $('html, body').animate({ scrollTop: newOffset }, 500); 495 } 496 497 function checkIdAndBirth(textId, textBirth) { 498 var result = true; 499 var birth = verifyBirth(textBirth); 500 var target = ''; 501 if (birth == 'error') {
502 $('#invalidBirth').css('display', 'inline'); 503 result = false; 504 target += '#invalidBirth'; 505 } else { 506 $('#invalidBirth').css('display', 'none'); 507 } 508 509 if (textId == '') { 510 $('#invalidId').css('display', 'inline'); 511 result = false; 512 if (target == '') { 513 target += '#invalidId'; 514 } 515 } else { 516 $('#invalidId').css('display', 'none'); 517 } 518 519 if (!result) scrollToMiddle(target); 520 521 return result; 522 } 523 524 function checkNameAndPhone(name, phone) { 525 var result = true; 526 var target = ''; 527 528 if (!name) { 529 $('#invalidName').css('display', 'inline'); 530 result = false; 531 target += '#invalidName'; 532 } else { 533 $('#invalidName').css('display', 'none'); 534 } 535 536 if (!phone) { 537 $('#invalidPhone').css('display', 'inline'); 538 result = false; 539 if (target == '') { 540 target += '#invalidPhone'; 541 } 542 } else { 543 $('#invalidPhone').css('display', 'none'); 544 } 545 546 if (!result) scrollToMiddle(target); 547 548 return result; 549 } 550 551 // éåçå¾ ä¸ç游æ¨çæ 552 function resetCursor() { 553 $('body').css('cursor', 'default'); 554 $("input[type='button']").css('cursor', 'pointer'); 555 } 556 557 // Reg_Book åå³çæèçæ ç¢¼ï¼Appointment > Statusï¼ 558 function getRegStatus(xml) { 559 var node = $(xml).find('Appointment Status'); 560 return node.length > 0 ? $.trim(node.first().text()) : ''; 561 } 562 563 // å 0ï¼é ç´æèæåï¼è 1ï¼é ç´æèæåï¼ä»£è¨ºï¼è¦çºæåï¼å ¶é¤ä¸å¾ç¶å¤±æ 564 function isRegSuccess(regStatus) { 565 return regStatus === '0' || regStatus === '1'; 566 } 567 568 // åå¯é¡¯ç¤ºçµ¦æ°ç¾çè¨æ¯ï¼åªå åæèçµæï¼å ¶æ¬¡åç æ£è³æçè¨æ¯ 569 // 以 text() åå¼ï¼è¨æ¯å« & çåå ææä¸æé¡¯ç¤ºæ HTML é¸åºå串 570 function getRegMessage(xml) { 571 var nodes = [$(xml).find('Appointment Message'), $(xml).find('Message')]; 572 573 for (var i = 0; i < nodes.length; i++) { 574 if (nodes[i].length > 0 && $.trim(nodes[i].first().text()) !== '') { 575 return $.trim(nodes[i].first().text()); 576 } 577 } 578 579 return ''; 580 } 581 582 function showFirstOrderError(msg) { 583 $('#firstOrderError').text(msg).css('display', 'block'); 584 scrollToMiddle('#firstOrderError'); 585 } 586 587 // æèå·²æç«ãå åè¨ºè³ææªå»ºæªæçè£ä»¶æç¤º 588 function appendFirstOrderNotice() { 589 $('#regTopNotes').append('<p style="color:red;">æèå·²æåï¼ä½åè¨ºè³æå»ºç«å¤±æï¼è«æ¼çè¨ºç¶æ¥ææ©è³ 1F æ«æª¯å¡«å¯«å診å®ã</p>'); 590 } 591 592 function refresh_captcha() { 593 $('#imgcode').attr('src', (window.location.href.includes('/wes/') ? '/wes' : '') + '/generate-captcha?' + Math.floor(Math.random() * 10000 + 1) + '">'); 594 $('#checkword').val(''); 595 } 596}); 597 598function verifyBirth(textBirth) { 599 if (/\D/.test(textBirth)) return 'error'; 600 var day = textBirth.slice(-2); 601 var month = textBirth.slice(-4, -2); 602 var year = textBirth.slice(0, -4); 603 var num_d, num_m, num_y; 604 605 num_d = parseInt(day); 606 num_m = parseInt(month); 607 num_y = parseInt(year); 608 609 if (isNaN(num_d) || isNaN(num_m) || isNaN(num_y)) return 'error'; 610 if (num_y < 0 || num_y > new Date().getFullYear() - 1911) return 'error'; 611 if (num_m < 1 || num_m > 12) return 'error'; 612 var days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; 613 if (num_d > days[num_m - 1]) { 614 if (num_m !== 2 || num_d !== 29) return 'error'; 615 } 616 617 var str = num_y + 1911 + '' + month + '' + day; 618 return str; 619} 620 621function verifyId(textId) { 622 /* 623 //建ç«åæ¯åæ¸é£å(A~Z) 624 var city = [ 625 1,10,19,28,37,46,55,64,39,73,82, 2,11, 626 20,48,29,38,47,56,65,74,83,21, 3,12,30 627 ]; 628 var id = textId.toUpperCase(); 629 630 // 使ç¨ãæ£è¦è¡¨éå¼ãæª¢é©æ ¼å¼ 631 if (id.search(/^[A-Z](1|2)\d{8}$/i) == -1) { 632 return false;
633 } else { 634 //å°å串åå²çºé£å(IEå¿ éé麼åæä¸æåºé¯) 635 id = id.split(''); 636 //è¨ç®ç¸½å 637 var total = city[id[0].charCodeAt(0)-65]; 638 for(var i = 1; i <= 8; i++){ 639 total += eval(id[i]) * (9 - i); 640 } 641 642 //è£ä¸æª¢æ¥ç¢¼(æå¾ä¸ç¢¼) 643 total += eval(id[9]); 644 645 //æª¢æ¥æ¯å°ç¢¼(餿¸æçº0); 646 return ((total%10 == 0 )); 647 } 648 */ 649 650 if (IdCardNumberCheck(textId) == false) { 651 if (IdTextNumberCheck(textId) == false) { 652 return false; 653 } 654 } 655 return true; 656} 657 658function IdCardNumberCheck(id) { 659 var city = new Array(1, 10, 19, 28, 37, 46, 55, 64, 39, 73, 82, 2, 11, 20, 48, 29, 38, 47, 56, 65, 74, 83, 21, 3, 12, 30); 660 id = id.toUpperCase(); 661 // 使ç¨ãæ£è¦è¡¨éå¼ãæª¢é©æ ¼å¼ 662 if (!id.match(/^[A-Z]\d{9}$/) && !id.match(/^[A-Z][A-D]\d{8}$/)) { 663 return false; 664 } else { 665 var total = 0; 666 if (id.match(/^[A-Z]\d{9}$/)) { 667 //身åèåè 668 //å°å串åå²çºé£å(IEå¿ éé麼åæä¸æåºé¯) 669 id = id.split(''); 670 //è¨ç®ç¸½å 671 total = city[id[0].charCodeAt(0) - 65]; 672 for (var i = 1; i <= 8; i++) { 673 total += eval(id[i]) * (9 - i); 674 } 675 } else { 676 // å¤ä¾äººå£çµ±ä¸èè 677 //å°å串åå²çºé£å(IEå¿ éé麼åæä¸æåºé¯) 678 id = id.split(''); 679 //è¨ç®ç¸½å 680 total = city[id[0].charCodeAt(0) - 65]; 681 // å¤ä¾äººå£ç第2碼çºè±æA-D(10~13)ï¼é裡æä»è½çºå碼並åå使¸ï¼ä¹å¾å°±å¯ä»¥åä¸è¬èº«åèçè¨ç®æ¹å¼ä¸æ¨£äºã 682 id[1] = id[1].charCodeAt(0) - 65; 683 for (var i = 1; i <= 8; i++) { 684 total += eval(id[i]) * (9 - i); 685 } 686 } 687 //è£ä¸æª¢æ¥ç¢¼(æå¾ä¸ç¢¼) 688 total += eval(id[9]); 689 //æª¢æ¥æ¯å°ç¢¼(餿¸æçº0); 690 if (total % 10 == 0) { 691 return true; 692 } else { 693 return false; 694 } 695 } 696} 697 698function IdTextNumberCheck(id) { 699 var invalidList = '00000000,11111111'; 700 if (/^\d{8}$/.test(id) == false || invalidList.indexOf(id) != -1) { 701 return false; 702 } 703 704 var validateOperator = [1, 2, 1, 2, 1, 2, 4, 1], 705 sum = 0, 706 calculate = function (product) { 707 // å使¸ + å使¸ 708 var ones = product % 10, 709 tens = (product - ones) / 10; 710 return ones + tens; 711 }; 712 for (var i = 0; i < validateOperator.length; i++) { 713 sum += calculate(id[i] * validateOperator[i]); 714 } 715 716 if (sum % 10 == 0 || (id[6] == '7' && (sum + 1) % 10 == 0)) { 717 return true; 718 } else { 719 return false; 720 } 721} 722 723function transDate(date) { 724 var day = date.slice(-2); 725 var month = date.slice(-4, -2); 726 var year = date.slice(0, -4); 727 728 return parseInt(year) - 1911 + '/' + month + '/' + day; 729}
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.