1// ã»ãã¥ã¢ãªãµãããã 2// http://www.strictly-software.com/scripts/downloads/encoder.js 3/** 4 * A Javascript object to encode and/or decode html characters using HTML or Numeric entities that handles double or partial encoding 5 * Author: R Reid 6 * source: http://www.strictly-software.com/htmlencode 7 * Licences: GPL, The MIT License (MIT) 8 * Copyright: (c) 2011 Robert Reid - Strictly-Software.com 9 * 10 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 11 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 13 * 14 * Revision: 15 * 2011-07-14, Jacques-Yves Bleau: 16 * - fixed conversion error with capitalized accentuated characters 17 * + converted arr1 and arr2 to object property to remove redundancy 18 * 19 * Revision: 20 * 2011-11-10, Ce-Yi Hio: 21 * - fixed conversion error with a number of capitalized entity characters 22 * 23 * Revision: 24 * 2011-11-10, Rob Reid: 25 * - changed array format 26 * 27 * Revision: 28 * 2012-09-23, Alex Oss: 29 * - replaced string concatonation in numEncode with string builder, push and join for peformance with ammendments by Rob Reid 30 */ 31 32Encoder = { 33 34 // When encoding do we convert characters into html or numerical entities 35 EncodeType : "entity", // entity OR numerical 36 37 isEmpty : function(val){ 38 if(val){ 39 return ((val===null) || val.length==0 || /^\s+$/.test(val)); 40 }else{ 41 return true; 42 } 43 }, 44 45 // arrays for conversion from HTML Entities to Numerical values 46 arr1: [' ','¡','¢','£','¤','¥','¦','§','¨','©','ª','«','¬','­','®','¯','°','±','²','³','´','µ','¶','·','¸','¹','º','»','¼','½','¾','¿','À','Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö','×','Ø','Ù','Ú','Û','Ü','Ý','Þ','ß','à','á','â','ã','ä','å','æ','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','÷','ø','ù','ú','û','ü','ý','þ','ÿ','"','&','<','>','Œ','œ','Š','š','Ÿ','ˆ','˜',' ',' ',' ','‌','‍','‎','‏','–','—','‘','’','‚','“','”','„','†','‡','‰','‹','›','€','ƒ','Α','Β','Γ','Δ','Ε','Ζ','Η','Θ','Ι','Κ','Λ','Μ','Ν','Ξ','Ο','Π','Ρ','Σ','Τ','Υ','Φ','Χ','Ψ','Ω','α','β','γ','δ','ε','ζ','η','θ','ι','κ','λ','μ','ν','ξ','ο','π','ρ','ς','σ','τ','υ','φ','χ','ψ','ω','ϑ','ϒ','ϖ','•','…','′','″','‾','⁄','℘','ℑ','ℜ','™','ℵ','←','↑','→','↓','↔','↵','⇐','⇑','⇒','⇓','⇔','∀','∂','∃','∅','∇','∈','∉','∋','∏','∑','−','∗','√','∝','∞','∠','∧','∨','∩','∪','∫','∴','∼','≅','≈','≠','≡','≤','≥','⊂','⊃','⊄','⊆','⊇','⊕','⊗','⊥','⋅','⌈','⌉','⌊','⌋','⟨','⟩','◊','♠
46','♣','♥','♦'], 47 arr2: [' ','¡','¢','£','¤','¥','¦','§','¨','©','ª','«','¬','­','®','¯','°','±','²','³','´','µ','¶','·','¸','¹','º','»','¼','½','¾','¿','À','Á','Â','Ã','Ä','Å','Æ','Ç','È','É','Ê','Ë','Ì','Í','Î','Ï','Ð','Ñ','Ò','Ó','Ô','Õ','Ö','×','Ø','Ù','Ú','Û','Ü','Ý','Þ','ß','à','á','â','ã','ä','å','æ','ç','è','é','ê','ë','ì','í','î','ï','ð','ñ','ò','ó','ô','õ','ö','÷','ø','ù','ú','û','ü','ý','þ','ÿ','"','&','<','>','Œ','œ','Š','š','Ÿ','ˆ','˜',' ',' ',' ','‌','‍','‎','‏','–','—','‘','’','‚','“','”','„','†','‡','‰','‹','›','€','ƒ','Α','Β','Γ','Δ','Ε','Ζ','Η','Θ','Ι','Κ','Λ','Μ','Ν','Ξ','Ο','Π','Ρ','Σ','Τ','Υ','Φ','Χ','Ψ','Ω','α','β','γ','δ','ε','ζ','η','θ','ι','κ','λ','μ','ν','ξ','ο','π','ρ','ς','σ','τ','υ','φ','χ','ψ','ω','ϑ','ϒ','ϖ','•','…','′','″','‾','⁄','℘','ℑ','ℜ','™','ℵ','←','↑','→','↓','↔','↵','⇐','⇑','⇒','⇓','⇔','∀','∂','∃','∅','∇','∈','∉','∋','∏','∑','−','∗','√','∝','∞','∠','∧','∨','∩','∪','∫','∴','∼','≅','≈','≠','≡','≤','≥','⊂','⊃','⊄','⊆','⊇','⊕','⊗','⊥','⋅','⌈','⌉','⌊','⌋','〈','〉','◊','♠','♣','♥','♦'], 48 49 // Convert HTML entities into numerical entities 50 HTML2Numerical : function(s){ 51 return this.swapArrayVals(s,this.arr1,this.arr2); 52 }, 53 54 // Convert Numerical entities into HTML entities 55 NumericalToHTML : function(s){ 56 return this.swapArrayVals(s,this.arr2,this.arr1); 57 }, 58 59 60 // Numerically encodes all unicode characters 61 numEncode : function(s){ 62 if(this.isEmpty(s)) return ""; 63 64 var a = [], 65 l = s.length; 66 67 for (var i=0;i<l;i++){ 68 var c = s.charAt(i); 69 if (c < " " || c > "~"){ 70 a.push("&#"); 71 a.push(c.charCodeAt()); //numeric value of code point 72 a.push(";"); 73 }else{ 74 a.push(c); 75 } 76 } 77 78 return a.join(""); 79 }, 80 81 // HTML Decode numerical and HTML entities back to original values 82 htmlDecode : function(s){ 83 84 var c,m,d = s; 85 86 if(this.isEmpty(d)) return ""; 87 88 // convert HTML entites back to numerical entites first 89 d = this.HTML2Numerical(d); 90 91 // look for numerical entities " 92 arr=d.match(/&#[0-9]{1,5};/g); 93 94 // if no matches found in string then skip 95 if(arr!=null){ 96 for(var x=0;x<arr.length;x++){ 97 m = arr[x]; 98 c = m.substring(2,m.length-1); //get numeric part which is refernce to unicode character 99 // if its a valid number we can decode 100 if(c >= -32768 && c <= 65535){ 101 // decode every single match within string 102 d = d.replace(m, String.fromCharCode(c)); 103 }else{ 104 d = d.replace(m, ""); //invalid so replace with nada 105 } 106 } 107 } 108 109 return d; 110 }, 111 112 // encode an input string into either numerical or HTML entities 113 htmlEncode : function(s,dbl){ 114 115 if(this.isEmpty(s)) return ""; 116 117 // do we allow double encoding? E.g will & be turned into &amp; 118 dbl = dbl || false; //default to prevent double encoding 119 120 // if allowing double encoding we do ampersands first 121 if(dbl){ 122 if(this.EncodeType=="numerical"){ 123 s = s.replace(/&/g, "&"); 124 }else{ 125 s = s.replace(/&/g, "&"); 126 } 127 } 128 129 // convert the xss chars to numerical entities ' " < > 130 s = this.XSSEncode(s,false); 131 132 if(this.EncodeType=="numerical" || !dbl){ 133 // Now call function that will convert any HTML entities to numerical codes 134 s = this.HTML2Numerical(s); 135 } 136 137 // Now encode all chars above 127 e.g unicode 138 s = this.numEncode(s); 139 140 // now we know anything that needs to be encoded has been converted to numerical entities we 141 // can encode any ampersands & that are not part of encoded entities 142 // to handle the fact that I need to do a negative check and handle multiple ampersands &&& 143 // I am going to use a placeholder 144 145 // if we don't want double encoded entities we ignore the & in existing entities 146 if(!dbl){ 147 s = s.replace(/&#/g,"##AMPHASH##"); 148 149 if(this.EncodeType=="numerical"){ 150 s = s.replace(/&/g, "&"); 151 }else{ 152 s = s.replace(/&/g, "&"); 153 } 154 155 s = s.replace(/##AMPHASH##/g,"&#"); 156 } 157 158 // replace any malformed entities 159 s = s.replace(/&#\d*([^\d;]|$)/g, "$1"); 160 161 if(!dbl){ 162 // safety check to correct any double encoded & 163 s = this.correctEncoding(s); 164 } 165 166 // now do we need to convert our numerical encoded string into entities 167 if(this.EncodeType=="entity"){ 168 s = this.NumericalToHTML(s); 169 } 170 171 return s; 172 }, 173 174 // Encodes the basic 4 characters used to malform HTML in XSS hacks 175 XSSEncode : function(s,en){ 176 if(!this.isEmpty(s)){ 177 en = en || true; 178 // do we convert to numerical or html entity? 179 if(en){ 180 s = s.replace(/\'/g,"'"); //no HTML equivalent as &apos is not cross browser supported 181 s = s.replace(/\"/g,"""); 182 s = s.replace(/</g,"<"); 183 s = s.replace(/>/g,">"); 184 }else{ 185 s = s.replace(/\'/g,"'"); //no HTML equivalent as &apos is not cross browser supported 186 s = s.replace(/\"/g,"""); 187 s = s.replace(/</g,"<"); 188 s = s.replace(/>/g,">"); 189 } 190 return s; 191 }else{ 192 return ""; 193 } 194 }, 195 196 // returns true if a string contains html or numerical encoded entities 197 hasEncoded : function(s){ 198 if(/&#[0-9]{1,5};/g.test(s)){ 199 return true; 200 }else if(/&[A-Z]{2,6};/gi.test(s)){ 201 return true; 202 }else{ 203 return false; 204 } 205 }, 206 207 // will remove any unicode characters 208 stripUnicode : function(s){ 209 return s.replace(/[^\x20-\x7E]/g,""); 210 }, 211 212 // corrects any double encoded & entities e.g &amp; 213 correctEncoding : function(s){ 214 return s.replace(/(&)(amp;)+/,"$1"); 215 }, 216 217 218 // Function to loop through an array swaping each item with the value from another array e.g swap HTML entities with Numericals 219 swapArrayVals : function(s,arr1,arr2){ 220 if(this.isEmpty(s)) return ""; 221 var re; 222 if(arr1 && arr2){ 223 //ShowDebug("in swapArrayVals arr1.length = " + arr1.length + " arr2.length = " + arr2.length) 224 // array lengths must match 225 if(arr1.length == arr2.length){ 226 for(var x=0,i=arr1.length;x<i;x++){ 227 re = new RegExp(arr1[x], 'g'); 228 s = s.replace(re,arr2[x]); //swap arr1 item with matching item from arr2 229 } 230 } 231 } 232 return s; 233 }, 234 235 inArray : function( item, arr ) { 236 for ( var i = 0, x = arr.length; i < x; i++ ){ 237 if ( arr[i] === item ){ 238 return i; 239 } 240 } 241 return -1; 242 } 243} 244 245// https://code.google.com/p/javascriptbase64/ 246/* 247Copyright (c) 2008 Fred Palmer fred.palmer_at_gmail.com 248 249Permission is hereby granted, free of charge, to any person 250obtaining a copy of this software and associated documentation 251files (the "Software"), to deal in the Software without 252restriction, including without limitation the rights to use, 253copy, modify, merge, publish, distribute, sublicense, and/or sell 254copies of the Software, and to permit persons to whom the 255Software is furnished to do so, subject to the following 256conditions: 257 258The above copyright notice and this permission notice shall be 259included in all copies or substantial portions of the Software. 260 261THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 262EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 263OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 264NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 265HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 266WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 267FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 268OTHER DEALINGS IN THE SOFTWARE. 269*/ 270function htmlspecialchars(str) { 271 str = str.replace(/&/g,"&"); 272 str = str.replace(/"/g,"""); 273 str = str.replace(/'/g,"'"); 274 str = str.replace(/</g,"<"); 275 str = str.replace(/>/g,">"); 276 return str ; 277} 278function html_sanitize(str) { 279 str = str.replace(/;/g,"!___escape_semicolon___!"); 280 str = htmlspecialchars(str); 281 str = str.replace(/!___escape_semicolon___!/g,";"); 282 str = str.replace(/\//g,"/"); 283 str = str.replace(/\\/g,"\"); 284 str = str.replace(/=/g,"="); 285 return str ; 286} 287 288function StringBuffer() 289{ 290 this.buffer = []; 291} 292 293StringBuffer.prototype.append = function append(string) 294{ 295 this.buffer.push(string); 296 return this; 297};
298 299StringBuffer.prototype.toString = function toString() 300{ 301 return this.buffer.join(""); 302}; 303 304var Base64 = 305{ 306 codex : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", 307 308 encode : function (input) 309 { 310 var output = new StringBuffer(); 311 312 var enumerator = new Utf8EncodeEnumerator(input); 313 while (enumerator.moveNext()) 314 { 315 var chr1 = enumerator.current; 316 317 enumerator.moveNext(); 318 var chr2 = enumerator.current; 319 320 enumerator.moveNext(); 321 var chr3 = enumerator.current; 322 323 var enc1 = chr1 >> 2; 324 var enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); 325 var enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); 326 var enc4 = chr3 & 63; 327 328 if (isNaN(chr2)) 329 { 330 enc3 = enc4 = 64; 331 } 332 else if (isNaN(chr3)) 333 { 334 enc4 = 64; 335 } 336 337 output.append(this.codex.charAt(enc1) + this.codex.charAt(enc2) + this.codex.charAt(enc3) + this.codex.charAt(enc4)); 338 } 339 340 return output.toString(); 341 }, 342 343 decode : function (input) 344 { 345 var output = new StringBuffer(); 346 347 var enumerator = new Base64DecodeEnumerator(input); 348 while (enumerator.moveNext()) 349 { 350 var charCode = enumerator.current; 351 352 if (charCode < 128) 353 output.append(String.fromCharCode(charCode)); 354 else if ((charCode > 191) && (charCode < 224)) 355 { 356 enumerator.moveNext(); 357 var charCode2 = enumerator.current; 358 359 output.append(String.fromCharCode(((charCode & 31) << 6) | (charCode2 & 63))); 360 } 361 else 362 { 363 enumerator.moveNext(); 364 var charCode2 = enumerator.current; 365 366 enumerator.moveNext(); 367 var charCode3 = enumerator.current; 368 369 output.append(String.fromCharCode(((charCode & 15) << 12) | ((charCode2 & 63) << 6) | (charCode3 & 63))); 370 } 371 } 372 373 return output.toString(); 374 } 375} 376 377 378function Utf8EncodeEnumerator(input) 379{ 380 this._input = input; 381 this._index = -1; 382 this._buffer = []; 383} 384 385Utf8EncodeEnumerator.prototype = 386{ 387 current: Number.NaN, 388 389 moveNext: function() 390 { 391 if (this._buffer.length > 0) 392 { 393 this.current = this._buffer.shift(); 394 return true; 395 } 396 else if (this._index >= (this._input.length - 1)) 397 { 398 this.current = Number.NaN; 399 return false; 400 } 401 else 402 { 403 var charCode = this._input.charCodeAt(++this._index); 404 405 // "\r\n" -> "\n" 406 // 407 if ((charCode == 13) && (this._input.charCodeAt(this._index + 1) == 10)) 408 { 409 charCode = 10; 410 this._index += 2; 411 } 412 413 if (charCode < 128) 414 { 415 this.current = charCode; 416 } 417 else if ((charCode > 127) && (charCode < 2048)) 418 { 419 this.current = (charCode >> 6) | 192; 420 this._buffer.push((charCode & 63) | 128); 421 } 422 else 423 { 424 this.current = (charCode >> 12) | 224; 425 this._buffer.push(((charCode >> 6) & 63) | 128); 426 this._buffer.push((charCode & 63) | 128); 427 } 428 429 return true; 430 } 431 } 432} 433 434function Base64DecodeEnumerator(input) 435{ 436 this._input = input; 437 this._index = -1; 438 this._buffer = []; 439} 440 441Base64DecodeEnumerator.prototype = 442{ 443 current: 64, 444 445 moveNext: function() 446 { 447 if (this._buffer.length > 0) 448 { 449 this.current = this._buffer.shift(); 450 return true; 451 } 452 else if (this._index >= (this._input.length - 1)) 453 { 454 this.current = 64; 455 return false; 456 } 457 else 458 { 459 var enc1 = Base64.codex.indexOf(this._input.charAt(++this._index)); 460 var enc2 = Base64.codex.indexOf(this._input.charAt(++this._index)); 461 var enc3 = Base64.codex.indexOf(this._input.charAt(++this._index)); 462 var enc4 = Base64.codex.indexOf(this._input.charAt(++this._index)); 463 464 var chr1 = (enc1 << 2) | (enc2 >> 4); 465 var chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); 466 var chr3 = ((enc3 & 3) << 6) | enc4; 467 468 this.current = chr1; 469 470 if (enc3 != 64) 471 this._buffer.push(chr2); 472 473 if (enc4 != 64) 474 this._buffer.push(chr3); 475 476 return true; 477 } 478 } 479}; 480 481 482// 社åã¨ã©ã¼è¡¨ç¤ºå¤å¥ 483function judgeViewCompanyError(key, val, maxlen){ 484 var msg = ""; 485 if( !checkNull(val) ){ 486 msg = "ä¼ç¤¾åãå ¥åãã¦ãã ãã"; 487 }else if( !checkMaxlen(val, maxlen)){ 488 msg = "ä¼ç¤¾åãé·ããã¾ã"; 489 } 490 if(msg != ""){ 491 viewError(key, msg); 492 return false; 493 }else{ 494 return true; 495 } 496} 497// 社åã«ã ã¨ã©ã¼è¡¨ç¤ºå¤å¥ 498function judgeViewCompanyKanaError(key, val, maxlen){ 499 var msg = ""; 500 if( !checkNull(val) ){ 501 msg = "ä¼ç¤¾ããªã¬ããå ¥åãã¦ãã ãã"; 502 }else if( !checkMaxlen(val, maxlen)){ 503 msg = "ä¼ç¤¾ããªã¬ããé·ããã¾ã"; 504 } 505 if(msg != ""){ 506 viewError(key, msg); 507 return false; 508 }else{ 509 return true; 510 } 511} 512// ååã¨ã©ã¼è¡¨ç¤ºå¤å¥ 513function judgeViewNameError(key, val, maxlen){ 514 var msg = ""; 515 if( !checkNull(val) ){ 516 msg = "ããªãã®ãååãå ¥åãã¦ãã ãã"; 517 }else if( !checkMaxlen(val, maxlen)){ 518 msg = "ãååãé·ããã¾ã"; 519 } 520 if(msg != ""){ 521 viewError(key, msg); 522 return false; 523 }else{ 524 return true; 525 } 526} 527// ããªã¬ãã¨ã©ã¼è¡¨ç¤ºå¤å¥ 528function judgeViewNameKanaError(key, val, maxlen){ 529 var msg = ""; 530 if( !checkNull(val) ){ 531 msg = "ããªã¬ããå ¥åãã¦ãã ãã"; 532 }else if( !checkMaxlen(val, maxlen)){ 533 msg = "ããªã¬ããé·ããã¾ã"; 534 } 535 if(msg != ""){ 536 viewError(key, msg); 537 return false; 538 }else{ 539 return true; 540 } 541} 542// 使ã¨ã©ã¼è¡¨ç¤ºå¤å¥ 543function judgeViewAddressError(key, val, maxlen){ 544 var msg = ""; 545 if( !checkNull(val) ){ 546 msg = "使ãå ¥åãã¦ãã ãã"; 547 }else if( !checkMaxlen(val, maxlen)){ 548 msg = "使ãé·ããã¾ã"; 549 } 550 if(msg != ""){ 551 viewError(key, msg); 552 return false; 553 }else{ 554 return true; 555 } 556} 557// é»è©±çªå·ã¨ã©ã¼è¡¨ç¤ºå¤å¥ 558function judgeViewTelError(key, val, maxlen, minlen){ 559 var msg = ""; 560 val = mb_convert_kana(val, "a").replace(/-/g, ""); 561 $('#contact_tel').val(val); 562 if( !checkNull(val) ){ 563 msg = "é£çµ¡ã®åããé»è©±çªå·ãå ¥åãã¦ãã ãã"; 564 }else if( !checkMaxlen(val, maxlen)){ 565 msg = "é»è©±çªå·ãé·ããã¾ã"; 566 }else if( !checkMinlen(val, minlen)){ 567 msg = "é»è©±çªå·ãçããã¾ã"; 568 }else if( !checkTel(val)){ 569 msg = "é»è©±çªå·ãç°å¸¸ã§ã"; 570 } 571 if(msg != ""){ 572 viewError(key, msg); 573 return false; 574 }else{ 575 return true; 576 } 577} 578// ã¡ã¼ã«ã¢ãã¬ã¹ã¨ã©ã¼è¡¨ç¤ºå¤å¥ 579function judgeViewEmailError(key, val, maxlen, minlen){ 580 var msg = ""; 581 val = mb_convert_kana(val, "a"); 582 $('#contact_'+key).val(val); 583 if( !checkNull(val) ){ 584 msg = "æ®æ®µã使ãã®ã¡ã¼ã«ã¢ãã¬ã¹ãå ¥åãã¦ãã ãã"; 585 }else if( !checkMaxlen(val, maxlen)){ 586 msg = "ã¡ã¼ã«ã¢ãã¬ã¹ãé·ããã¾ã"; 587 }else if( !checkMinlen(val, minlen)){ 588 msg = "ã¡ã¼ã«ã¢ãã¬ã¹ãçããã¾ã"; 589 }else if( !checkEmail(val)){ 590 msg = "ã¡ã¼ã«ã¢ãã¬ã¹ãç°å¸¸ã§ã"; 591 } 592 if(msg != ""){ 593 viewError(key, msg); 594 return false; 595 }else{ 596 return true; 597 } 598} 599// ã¡ã¼ã«ã¢ãã¬ã¹ä¸è´ã¨ã©ã¼è¡¨ç¤ºå¤å¥ 600function judgeViewEmailMatchError(email1, email2){ 601 var msg = ""; 602 if( email1 != email2 ){ 603 msg = "ã¡ã¼ã«ã¢ãã¬ã¹ãä¸è´ãã¾ãã"; 604 } 605 if(msg != ""){ 606 viewError("email_re", msg); 607 return false; 608 }else{ 609 return true; 610 } 611} 612// ããã¹ãã¨ãªã¢ã¨ã©ã¼è¡¨ç¤ºå¤å¥ 613function judgeViewBodyError(key, val, maxlen, minlen){ 614 var msg = ""; 615 if( !checkNull(val) ){ 616 msg = "ãåãåããå 容ãå ¥åãã¦ãã ãã"; 617 }else if( !checkMaxlen(val, maxlen)){ 618 msg = "æç« ãé·ããã¾ã"; 619 }else if( !checkMinlen(val, minlen)){ 620 msg = "æç« ãçããã¾ã"; 621 } 622 if(msg != ""){ 623 viewError(key, msg); 624 return false; 625 }else{ 626 return true; 627 } 628} 629// ã»ã¬ã¯ã鏿ã¨ã©ã¼è¡¨ç¤ºå¤å¥ 630function judgeViewSelectError(key, val){ 631 var msg = ""; 632 if( !checkNull(val) ){ 633 msg = "å¦å¹´ã鏿ãã¦ãã ãã"; 634 } 635 if(msg != ""){ 636 viewError(key, msg); 637 return false; 638 }else{ 639 return true; 640 } 641} 642// å人æ å ±åæ 643function judgeViewAcceptError(key, val){ 644 var msg = ""; 645 if( !val ){ 646 msg = 'ãå人æ å ±ä¿è·ã«åæãããã«ãã§ãã¯ããã¦ä¸ãã'; 647 } 648 if(msg != ""){ 649 viewError(key, msg); 650 return false; 651 }else{ 652 return true; 653 } 654} 655// å ¥åå¤ããã§ã㯠656// ç©ºç½ 657function checkNull(val){ 658 if(val == "" || stringRemoveSpace(val) == "" || stringRemoveBR(val) == ""){ 659 return false; 660 }else{ 661 return true; 662 } 663} 664// æåæ° 665function checkMaxlen(val, len){ 666 if(val.length > len){ 667 return false; 668 }else{ 669 return true; 670 } 671} 672function checkMinlen(val, len){ 673 if(val.length < len){ 674 return false; 675 }else{ 676 return true; 677 } 678} 679// Tel 680function checkTel(val){ 681 val = mb_convert_kana(val).replace(/-/g, ""); 682 if(val.match(/[^0-9]/)){ 683 return false; 684 }else{ 685 return true; 686 } 687} 688// Email 689function checkEmail(val){ 690 val = mb_convert_kana(val);
691 var tmp = val.match(/^[0-9a-zA-Z\-\+_\.]+@[0-9a-zA-Z\-\+_\.]+\.[0-9a-zA-Z\-\+_\.]+$/g); 692// console.log(tmp); 693 if(tmp){ 694 return true; 695 }else{ 696 return false; 697 } 698} 699// æååããåè§å ¨è§ã¹ãã¼ã¹ãé¤å» 700function stringRemoveSpace(str){ 701 if(str != null){ 702 return str.replace(/ /g, "").replace(/ã/g, ""); 703 }else{ 704 return ""; 705 } 706} 707// æååããæ¹è¡ãé¤å» 708function stringRemoveBR(str){ 709 if(str != null){ 710 return str.replace(/\n/g, "").replace(/\r/g, ""); 711 }else{ 712 return ""; 713 } 714} 715// ã¨ã©ã¼è¦å 716function viewError(inputName, msg){ 717 $('#error_' + inputName + ' .elm-error-input').text(msg); 718 $('#error_' + inputName).slideDown(200); 719 if(inputName == "accept"){ 720 var errorArea = '#contact_privacy_area'; 721 }else{ 722 var errorArea = '#contact_' + inputName; 723 } 724 725 if(inputName != "accept"){ 726 $(errorArea).stop(true).animate({backgroundColor: "#ffcccc"}, 500, "swing", function(){ 727 $(this).stop(true).animate({backgroundColor: "#c1beb1", color: '#ffffff'}, {duration: 2000, eeasing: "swing", complete: function(){ 728 $(this).removeAttr('style'); 729 }}); 730 }); 731 } 732} 733// è±æ°åãå ¨ã¦åè§ã«ãã 734function mb_convert_kana(val){ 735 if(val.length > 0){ 736 val = val.replace(/[^0-9a-zA-Z_@\-\.\,\%\&\$\#\"\'\(\)\!\+]/g, ""); 737 } 738 return val; 739} 740// ããã¹ãã¨ãªã¢ã®å ¥åæåæ°ãåå¾ãã 741function countTextLen(target){ 742 if($(target)){ 743 var val = $(target).val(); 744 if(val){ 745 return val.length; 746 } 747 } 748}
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.