1/* 2* Title : DOP Prototypes (JavaScript class) 3* Version : 1.0.3 4* File : dop-prototypes.js 5* File Version : 1.0.3 6* Created / Last Modified : 29 March 2016 7* Author : Dot on Paper 8* Copyright : © 2014 Dot on Paper 9* Website : http://www.dotonpaper.net 10* Description : List of general functions that we use at Dot on Paper. 11* Licence : MIT 12*/ 13 14var DOPPrototypes = new function(){ 15 /* 16 * Private variables 17 */ 18 var $ = jQuery.noConflict(); 19 20 /* 21 * Public variables 22 */ 23 24 /* 25 * Constructor 26 */ 27 this.__construct = function(){ 28 }; 29 30// Actions 31 32 /* 33 * Make all parents & current item visible. 34 * 35 * @param item (element): item for which all parens are going to be made visible 36 * 37 * @return list of parents 38 */ 39 this.doHiddenBuster = function(item){ 40 var parent = item.parent(), 41 items = new Array(); 42 43 if (item.prop('tagName') !== undefined 44 && item.prop('tagName').toLowerCase() !== 'body'){ 45 items = this.doHiddenBuster(parent); 46 } 47 48 if (item.css('display') === 'none'){ 49 item.css('display', 'block'); 50 items.push(item); 51 } 52 53 return items; 54 }; 55 56 /* 57 * Hide all items from list. The list is returned by function doHiddenBuster(). 58 * 59 * @param items (Array): list of items to be hidden 60 */ 61 this.undoHiddenBuster = function(items){ 62 var i; 63 64 for (i=0; i<items.length; i++){ 65 items[i].css('display', 'none'); 66 } 67 }; 68 69 /* 70 * Open a link. 71 * 72 * @param url (String): link URL 73 * @param target (String): link target (_blank, _parent, _self, _top) 74 */ 75 this.openLink = function(url, 76 target){ 77 switch (target.toLowerCase()){ 78 case '_blank': 79 window.open(url); 80 break; 81 case '_parent': 82 parent.location.href = url; 83 break; 84 case '_top': 85 top.location.href = url; 86 break; 87 default: 88 window.location = url; 89 } 90 }; 91 92 /* 93 * Randomize the items of an array. 94 * 95 * @param theArray (Array): the array to be mixed 96 * 97 * return array with mixed items 98 */ 99 this.randomizeArray = function(theArray){ 100 theArray.sort(function(){ 101 return 0.5-Math.random(); 102 }); 103 return theArray; 104 }; 105 106 /* 107 * Scroll vertically to position. 108 * 109 * @param position (Number): position to scroll to 110 * @param speed (Number): scroll speed 111 */ 112 this.scrollToY = function(position, 113 speed){ 114 speed = speed !== undefined ? speed: 300; 115 116 $('html').stop(true, true) 117 .animate({'scrollTop': position}, 118 speed); 119 $('body').stop(true, true) 120 .animate({'scrollTop': position}, 121 speed); 122 }; 123 124 /* 125 * One finger navigation for touchscreen devices. 126 * 127 * @param parent (element): parent item 128 * @param child (element): child item 129 */ 130 this.touchNavigation = function(parent, 131 child){ 132 var prevX, 133 prevY, 134 currX, 135 currY, 136 touch, 137 childX, 138 childY; 139 140 parent.bind('touchstart', function(e){ 141 touch = e.originalEvent.touches[0]; 142 prevX = touch.clientX; 143 prevY = touch.clientY; 144 }); 145 146 parent.bind('touchmove', function(e){ 147 touch = e.originalEvent.touches[0]; 148 currX = touch.clientX; 149 currY = touch.clientY; 150 childX = currX>prevX ? parseInt(child.css('margin-left'))+(currX-prevX):parseInt(child.css('margin-left'))-(prevX-currX); 151 childY = currY>prevY ? parseInt(child.css('margin-top'))+(currY-prevY):parseInt(child.css('margin-top'))-(prevY-currY); 152 153 if (childX < (-1)*(child.width()-parent.width())){ 154 childX = (-1)*(child.width()-parent.width()); 155 } 156 else if (childX > 0){ 157 childX = 0; 158 } 159 else{ 160 e.preventDefault(); 161 } 162 163 if (childY < (-1)*(child.height()-parent.height())){ 164 childY = (-1)*(child.height()-parent.height()); 165 } 166 else if (childY > 0){ 167 childY = 0; 168 } 169 else{ 170 e.preventDefault(); 171 } 172 173 prevX = currX; 174 prevY = currY; 175 176 if (parent.width() < child.width()){ 177 child.css('margin-left', childX); 178 } 179 180 if (parent.height() < child.height()){ 181 child.css('margin-top', childY); 182 } 183 }); 184 185 parent.bind('touchstart', function(e){ 186 if (!this.isChromeMobileBrowser()){ 187 e.preventDefault(); 188 } 189 }); 190 }; 191 192// Browsers & devices 193 194 /* 195 * Check if operating system is Android. 196 * 197 * @return true/false 198 */ 199 this.isAndroid = function(){ 200 var isAndroid = false, 201 agent = navigator.userAgent.toLowerCase(); 202 203 if (agent.indexOf('android') !== -1){ 204 isAndroid = true; 205 } 206 return isAndroid; 207 }; 208 209 /* 210 * Check if browser is Chrome on mobile.. 211 * 212 * @return true/false 213 */ 214 this.isChromeMobileBrowser = function(){ 215 var isChromeMobile = false, 216 agent = navigator.userAgent.toLowerCase(); 217 218 if ((agent.indexOf('chrome') !== -1 219 || agent.indexOf('crios') !== -1) 220 && this.isTouchDevice()){ 221 isChromeMobile = true; 222 } 223 return isChromeMobile; 224 }; 225 226 /* 227 * Check if browser is IE8. 228 * 229 * @return true/false 230 */ 231 this.isIE8Browser = function(){ 232 var isIE8 = false, 233 agent = navigator.userAgent.toLowerCase(); 234 235 if (agent.indexOf('msie 8') !== -1){ 236 isIE8 = true; 237 } 238 return isIE8; 239 }; 240 241 /* 242 * Check if browser is IE.. 243 * 244 * @return true/false 245 */ 246 this.isIEBrowser = function(){ 247 var isIE = false, 248 agent = navigator.userAgent.toLowerCase(); 249 250 if (agent.indexOf('msie') !== -1){ 251 isIE = true; 252 } 253 return isIE; 254 }; 255 256 /* 257 * Detect touchscreen devices. 258 * 259 * @return true/false 260 */ 261 this.isTouchDevice = function(){ 262 var os = navigator.platform; 263 264 if (os.toLowerCase().indexOf('win') !== -1){ 265 return window.navigator.msMaxTouchPoints; 266 } 267 else { 268 return 'ontouchstart' in document; 269 } 270 }, 271 272// Cookies 273 274 /* 275 * Delete cookie. 276 * 277 * @param name (String): cookie name 278 * @param path (String): cookie path 279 * @param domain (String): cookie domain 280 */ 281 this.deleteCookie = function(name, 282 path, 283 domain){ 284 if (this.getCookie(name)){ 285 document.cookie = name+'='+((path) ? ';path='+path:'')+((domain) ? ';domain='+domain:'')+';expires=Thu, 01-Jan-1970 00:00:01 GMT'; 286 } 287 }; 288 289 /* 290 * Get cookie. 291 * 292 * @param name (String): cookie name 293 */ 294 this.getCookie = function(name){ 295 var namePiece = name+"=", 296 cookie = document.cookie.split(";"), 297 i; 298 299 for (i=0; i<cookie.length; i++){ 300 var cookiePiece = cookie[i]; 301 302 while (cookiePiece.charAt(0) === ' '){ 303 cookiePiece = cookiePiece.substring(1,cookiePiece .length); 304 } 305 306 if (cookiePiece.indexOf(namePiece) === 0){ 307 return unescape(cookiePiece.substring(namePiece.length, cookiePiece.length)); 308 } 309 } 310 return null; 311 }; 312 313 /* 314 * Set cookie. 315 * 316 * @param name (String): cookie name 317 * @param value (String): cookie value 318 * @param expire (String): the number of days after which the cookie will expire 319 */ 320 this.setCookie = function(name, 321 value, 322 expire){ 323 var expirationDate = new Date(); 324 325 expirationDate.setDate(expirationDate.getDate()+expire); 326 document.cookie = name+'='+escape(value)+((expire === null) ? '': ';expires='+expirationDate.toUTCString())+';javahere=yes;path=/'; 327 }; 328 329// Date & time 330 331 /* 332 * Converts time to AM/PM format. 333 * 334 * @param time (String): the time that will be converted (HH:MM) 335 * 336 * @return time to AM/PM format 337 */ 338 this.getAMPM = function(time){ 339 var hour = parseInt(time.split(':')[0], 10), 340 minutes = time.split(':')[1], 341 result = ''; 342 343 if (hour === 0){ 344 result = '12'; 345 } 346 else if (hour > 12){ 347 result = this.getLeadingZero(hour-12); 348 } 349 else{ 350 result = this.getLeadingZero(hour); 351 } 352 353 result += ':'+minutes+' '+(hour < 12 ? 'AM':'PM'); 354 355 return result; 356 }; 357 358 /* 359 * Returns difference between 2 dates. 360 * 361 * @param date1 (Date): first date (JavaScript date) 362 * @param date2 (Date): second date (JavaScript date) 363 * @param type (String): diference type 364 * "seconds" 365 * "minutes" 366 * "hours" 367 * "days" 368 * @param valueType (String): type of number returned 369 * "float" 370 * "integer" 371 * @param noDecimals (Number): number of decimals returned with the float value (-1 to display all decimals) 372 * 373 * @return dates diference 374 */ 375 this.getDatesDifference = function(date1, 376 date2, 377 type, 378 valueType, 379 noDecimals){ 380 var y1 = date1.split('-')[0], 381 m1 = date1.split('-')[1], 382 d1 = date1.split('-')[2], 383 y2 = date2.split('-')[0], 384 m2 = date2.split('-')[1], 385 d2 = date2.split('-')[2],
386 time1 = (new Date(y1, m1-1, d1)).getTime(), 387 time2 = (new Date(y2, m2-1, d2)).getTime(), 388 diff = Math.abs(time1-time2); 389 390 if (type === undefined){ 391 type = 'seconds'; 392 } 393 394 if (valueType === undefined){ 395 valueType = 'float'; 396 } 397 398 if (noDecimals === undefined){ 399 noDecimals = -1; 400 } 401 402 switch (type){ 403 case 'days': 404 diff = diff/(1000*60*60*24); 405 break; 406 case 'hours': 407 diff = diff/(1000*60*60); 408 break; 409 case 'minutes': 410 diff = diff/(1000*60); 411 break; 412 default: 413 diff = diff/(1000); 414 } 415 416 if (valueType === 'float'){ 417 return noDecimals === -1 ? diff:DOPPrototypes.getWithDecimals(diff, noDecimals); 418 } 419 else{ 420 return Math.ceil(diff); 421 } 422 }; 423 424 /* 425 * Returns difference between 2 hours. 426 * 427 * @param hour1 (Date): first hour (HH:MM, HH:MM:SS) 428 * @param hour2 (Date): second hour (HH:MM, HH:MM:SS) 429 * @param type (String): diference type 430 * "seconds" 431 * "minutes" 432 * "hours" 433 * @param valueType (String): type of number returned 434 * "float" 435 * "integer" 436 * @param noDecimals (Number): number of decimals returned with the float value (-1 to display all decimals) 437 * 438 * @return hours difference 439 */ 440 this.getHoursDifference = function(hour1, 441 hour2, 442 type, 443 valueType, 444 noDecimals){ 445 var hours1 = parseInt(hour1.split(':')[0], 10), 446 minutes1 = parseInt(hour1.split(':')[1], 10), 447 seconds1 = hour1.split(':')[2] !== undefined ? parseInt(hour1.split(':')[2], 10):0, 448 hours2 = parseInt(hour2.split(':')[0], 10), 449 minutes2 = parseInt(hour2.split(':')[1], 10), 450 seconds2 = hour2.split(':')[2] !== undefined ? parseInt(hour2.split(':')[2], 10):0, 451 time1, 452 time2, 453 diff; 454 455 if (type === undefined){ 456 type = 'seconds'; 457 } 458 459 if (valueType === undefined){ 460 valueType = 'float'; 461 } 462 463 if (noDecimals === undefined){ 464 noDecimals = -1; 465 } 466 467 switch (type){ 468 case 'hours': 469 time1 = hours1+minutes1/60+seconds1/60/60; 470 time2 = hours2+minutes2/60+seconds2/60/60; 471 break; 472 case 'minutes': 473 time1 = hours1*60+minutes1+seconds1/60; 474 time2 = hours2*60+minutes2+seconds2/60; 475 break; 476 default: 477 time1 = hours1*60*60+minutes1*60+seconds1; 478 time2 = hours2*60*60+minutes2*60+seconds2; 479 } 480 481 diff = Math.abs(time1-time2); 482 483 if (valueType === 'float'){ 484 return noDecimals === -1 ? diff:DOPPrototypes.getWithDecimals(diff, noDecimals); 485 } 486 else{ 487 return Math.ceil(diff); 488 } 489 }; 490 491 /* 492 * Returns next day. 493 * 494 * @param date (Date): current date (YYYY-MM-DD) 495 * 496 * @return next day (YYYY-MM-DD) 497 */ 498 this.getNextDay = function(date){ 499 var nextDay = new Date(), 500 parts = date.split('-'); 501 502 nextDay.setFullYear(parts[0], parts[1], parts[2]); 503 nextDay.setTime(nextDay.getTime()+86400000); 504 505 return nextDay.getFullYear()+'-'+DOPPrototypes.getLeadingZero(nextDay.getMonth())+'-'+DOPPrototypes.getLeadingZero(nextDay.getDate()); 506 }; 507 508 /* 509 * Returns number of days between 2 dates. 510 * 511 * @param date1 (Date): first date (YYYY-MM-DD) 512 * @param date2 (Date): second date (YYYY-MM-DD) 513 * 514 * @return number of days 515 */ 516 this.getNoDays = function(date1, 517 date2){ 518 var y1 = date1.split('-')[0], 519 m1 = date1.split('-')[1], 520 d1 = date1.split('-')[2], 521 y2 = date2.split('-')[0], 522 m2 = date2.split('-')[1], 523 d2 = date2.split('-')[2],
524 time1 = (new Date(y1, m1-1, d1)).getTime(), 525 time2 = (new Date(y2, m2-1, d2)).getTime(), 526 diff = Math.abs(time1-time2); 527 528 return Math.round(diff/(1000*60*60*24))+1; 529 }; 530 531 /* 532 * Returns the number of months between 2 dates. 533 * 534 * @param date1 (Date): first date (YYYY-MM-DD) 535 * @param date2 (Date): second date (YYYY-MM-DD) 536 * 537 * @return the number of months 538 */ 539 this.getNoMonths = function(date1, 540 date2){ 541 var firstMonth, 542 lastMonth, 543 m, 544 month1, 545 month2, 546 noMonths = 0, 547 y, 548 year1, 549 year2; 550 551 date1 = date1 <= date2 ? date1:date2; 552 month1 = parseInt(date1.split('-')[1], 10); 553 year1 = parseInt(date1.split('-')[0], 10); 554 month2 = parseInt(date2.split('-')[1], 10); 555 year2 = parseInt(date2.split('-')[0], 10); 556 557 for (y=year1; y<=year2; y++){ 558 firstMonth = y === year1 ? month1:1; 559 lastMonth = y === year2 ? month2:12; 560 561 for (m=firstMonth; m<=lastMonth; m++){ 562 noMonths++; 563 } 564 } 565 566 return noMonths; 567 }; 568 569 /* 570 * Returns previous day. 571 * 572 * @param date (Date): current date (YYYY-MM-DD) 573 * 574 * @return previous day (YYYY-MM-DD) 575 */ 576 this.getPrevDay = function(date){ 577 var previousDay = new Date(), 578 parts = date.split('-'); 579 580 previousDay.setFullYear(parts[0], parseInt(parts[1])-1, parts[2]); 581 previousDay.setTime(previousDay.getTime()-86400000); 582 583 return previousDay.getFullYear()+'-'+DOPPrototypes.getLeadingZero(previousDay.getMonth()+1)+'-'+DOPPrototypes.getLeadingZero(previousDay.getDate()); 584 }; 585 586 /* 587 * Returns previous time by hours, minutes, seconds. 588 * 589 * @param time (String): time (HH, HH:MM, HH:MM:SS) 590 * @param diff (Number): diference for previous time 591 * @param diffBy (Number): diference by 592 * "hours" 593 * "minutes" 594 * "seconds" 595 * 596 * @return previus hour (HH, HH:MM, HH:MM:SS) 597 */ 598 this.getPrevTime = function(time, 599 diff, 600 diffBy){ 601 var timePieces = time.split(':'), 602 hours = parseInt(timePieces[0], 10), 603 minutes = timePieces[1] === undefined ? 0:parseInt(timePieces[1], 10), 604 seconds = timePieces[2] === undefined ? 0:parseInt(timePieces[2], 10); 605 606 switch (diffBy){ 607 case 'seconds': 608 seconds = seconds-diff; 609 610 if (seconds < 0){ 611 seconds = 60+seconds; 612 minutes = minutes-1; 613 614 if (minutes < 0){ 615 minutes = 60+minutes; 616 hours = hours-1 < 0 ? 0:hours-1; 617 } 618 } 619 break; 620 case 'minutes': 621 minutes = minutes-diff; 622 623 if (minutes < 0){ 624 minutes = 60+minutes; 625 hours = hours-1 < 0 ? 0:hours-1; 626 } 627 break; 628 default: 629 hours = hours-diff < 0 ? 0:hours-diff; 630 } 631 632 return this.getLeadingZero(hours)+(timePieces[1] === undefined ? '':':'+this.getLeadingZero(minutes)+(timePieces[2] === undefined ? '':':'+this.getLeadingZero(seconds))); 633 }; 634 635 /* 636 * Returns today date. 637 * 638 * @return today (YYYY-MM-DD) 639 */ 640 this.getToday = function(){ 641 var today = new Date(); 642 643 return today.getFullYear()+'-'+DOPPrototypes.getLeadingZero(today.getMonth()+1)+'-'+DOPPrototypes.getLeadingZero(today.getDate()); 644 }; 645 646 /* 647 * Returns week day. 648 * 649 * @param date (String): date for which the function get day of the week (YYYY-MM-DD) 650 * 651 * @return week day index (0 for Sunday) 652 */ 653 this.getWeekDay = function(date){ 654 var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], 655 year = date.split('-')[0],
656 month = date.split('-')[1], 657 day = date.split('-')[2], 658 newDate = new Date(eval('"'+day+' '+months[parseInt(month, 10)-1]+', '+year+'"')); 659 660 return newDate.getDay(); 661 }; 662 663// Domains & URLs 664 665 /* 666 * Parse a $_GET variable. 667 * 668 * @param name (String): variable name 669 * 670 * @return variable vaue or "undefined" if it doesn't exist 671 */ 672 this.$_GET = function(name){ 673 var url = window.location.href.split('?')[1], 674 variables = url !== undefined ? url.split('&'):[], 675 i; 676 677 for (i=0; i<variables.length; i++){ 678 if (variables[i].indexOf(name) !== -1){ 679 return variables[i].split('=')[1]; 680 break; 681 } 682 } 683 684 return undefined; 685 }; 686 687 /* 688 * Access-Control-Allow-Origin buster. Modifies URL to be the same as browser URL. 689 * 690 * @param url (String): URL 691 * 692 * @return modified URL 693 */ 694 this.acaoBuster = function(url){ 695 var browserURL = window.location.href, 696 pathPiece1 = '', pathPiece2 = ''; 697 698 if (this.getDomain(browserURL) === this.getDomain(url)){ 699 if (url.indexOf('https') !== -1 700 || url.indexOf('http') !== -1){ 701 if (browserURL.indexOf('http://www.') !== -1){ 702 pathPiece1 = 'http://www.'; 703 } 704 else if (browserURL.indexOf('http://') !== -1){ 705 pathPiece1 = 'http://'; 706 } 707 else if (browserURL.indexOf('https://www.') !== -1){ 708 pathPiece1 = 'https://www.'; 709 } 710 else if (browserURL.indexOf('https://') !== -1){ 711 pathPiece1 = 'https://'; 712 } 713 714 if (url.indexOf('http://www.') !== -1){ 715 pathPiece2 = url.split('http://www.')[1]; 716 } 717 else if (url.indexOf('http://') !== -1){ 718 pathPiece2 = url.split('http://')[1]; 719 } 720 else if (url.indexOf('https://www.') !== -1){ 721 pathPiece2 = url.split('https://www.')[1]; 722 } 723 else if (url.indexOf('https://') !== -1){ 724 pathPiece2 = url.split('https://')[1]; 725 } 726 727 return pathPiece1+pathPiece2; 728 } 729 else{ 730 return url; 731 } 732 } 733 else{ 734 return url; 735 } 736 }; 737 738 /* 739 * Get current domain. 740 * 741 * @param url (String): the URL from which the domain will be extracted 742 * 743 * @return current domain 744 */ 745 this.getDomain = function(url){ 746 var domain = url; 747 748 /* 749 * Remove white spaces from the begining of the URL. 750 */ 751 domain = domain.replace(new RegExp(/^\s+/),""); 752 753 /* 754 * Remove white spaces from the end of the URL. 755 */ 756 domain = domain.replace(new RegExp(/\s+$/),""); 757 758 /* 759 * If found , convert back slashes to forward slashes. 760 */ 761 domain = domain.replace(new RegExp(/\\/g),"/"); 762 763 /* 764 * If there, removes "http://", "https://" or "ftp://" from the begining. 765 */ 766 domain = domain.replace(new RegExp(/^http\:\/\/|^https\:\/\/|^ftp\:\/\//i),""); 767 768 /* 769 * If there, removes 'www.' from the begining. 770 */ 771 domain = domain.replace(new RegExp(/^www\./i),""); 772 773 /* 774 * Remove complete string from first forward slash on. 775 */ 776 domain = domain.replace(new RegExp(/\/(.*)/),""); 777 778 return domain; 779 }; 780 781 /* 782 * Check if current URL has a subdomain. 783 * 784 * @param url (String): URL that will be checked 785 * 786 * @return true/false 787 */ 788 this.hasSubdomain = function(url){ 789 var subdomain; 790 791 /* 792 * Remove white spaces from the begining of the URL. 793 */ 794 url = url.replace(new RegExp(/^\s+/),""); 795 796 /* 797 * Remove white spaces from the end of the URL. 798 */ 799 url = url.replace(new RegExp(/\s+$/),""); 800 801 /* 802 * If found , convert back slashes to forward slashes. 803 */ 804 url = url.replace(new RegExp(/\\/g),"/"); 805 806 /* 807 * If there, removes 'http://', 'https://' or 'ftp://' from the begining. 808 */ 809 url = url.replace(new RegExp(/^http\:\/\/|^https\:\/\/|^ftp\:\/\//i),""); 810 811 /* 812 * If there, removes 'www.' from the begining. 813 */ 814 url = url.replace(new RegExp(/^www\./i),""); 815 816 /*
817 * Remove complete string from first forward slaash on. 818 */ 819 url = url.replace(new RegExp(/\/(.*)/),""); // 820 821 if (url.match(new RegExp(/\.[a-z]{2,3}\.[a-z]{2}$/i))){ 822 /* 823 * Remove ".??.??" or ".???.??" from end - e.g. ".CO.UK", ".COM.AU" 824 */ 825 url = url.replace(new RegExp(/\.[a-z]{2,3}\.[a-z]{2}$/i),""); 826 } 827 else if (url.match(new RegExp(/\.[a-z]{2,4}$/i))){ 828 /* 829 * Removes ".??" or ".???" or ".????" from end - e.g. ".US", ".COM", ".INFO" 830 */ 831 url = url.replace(new RegExp(/\.[a-z]{2,4}$/i),""); 832 } 833 834 /* 835 * Check to see if there is a dot "." left in the string. 836 */ 837 subdomain = (url.match(new RegExp(/\./g))) ? true : false; 838 839 return(subdomain); 840 }; 841 842// Resize & position 843 844 /* 845 * Resize & position an item inside a parent. 846 * 847 * @param parent (element): parent item 848 * @param child (element): child item 849 * @param pw (Number): parent width 850 * @param ph (Number): parent height 851 * @param cw (Number): child width 852 * @param ch (Number): child height 853 * @param pos (String): set child position in parent (bottom, bottom-center, bottom-left, bottom-right, center, left, horizontal-center, middle-left, middle-right, right, top, top-center, top-left, top-right, vertical-center) 854 * @param type (String): resize type 855 * "fill" fill parent (child will be cropped) 856 * "fit" child resize to fit in parent 857 */ 858 this.rp = function(parent, 859 child, 860 pw, 861 ph, 862 cw, 863 ch, 864 pos, 865 type){ 866 var newW = 0, 867 newH = 0; 868 869 /* 870 * Resize child. 871 */ 872 if (cw <= pw 873 && ch <= ph){ 874 newW = cw; 875 newH = ch; 876 } 877 else{ 878 switch (type){ 879 case 'fill': 880 newH = ph; 881 newW = (cw*ph)/ch; 882 883 if (newW < pw){ 884 newW = pw; 885 newH = (ch*pw)/cw; 886 } 887 break; 888 default: 889 newH = ph; 890 newW = (cw*ph)/ch; 891 892 if (newW > pw){ 893 newW = pw; 894 newH = (ch*pw)/cw; 895 } 896 break; 897 } 898 } 899 900 child.width(newW); 901 child.height(newH); 902 903 /* 904 * Position child. 905 */ 906 switch(pos.toLowerCase()){ 907 case 'bottom': 908 this.rpBottom(parent, 909 child, 910 ph); 911 break; 912 case 'bottom-center': 913 this.rpBottomCenter(parent, 914 child, 915 pw, 916 ph); 917 break; 918 case 'bottom-left': 919 this.rpBottomLeft(parent, 920 child, 921 pw, 922 ph); 923 break; 924 case 'bottom-right': 925 this.rpBottomRight(parent, 926 child, 927 pw, 928 ph); 929 break; 930 case 'center': 931 this.rpCenter(parent, 932 child, 933 pw, 934 ph); 935 break; 936 case 'left': 937 this.rpLeft(parent, 938 child, 939 pw); 940 break; 941 case 'horizontal-center': 942 this.rpCenterHorizontally(parent, 943 child, 944 pw); 945 break; 946 case 'middle-left': 947 this.rpMiddleLeft(parent, 948 child, 949 pw, 950 ph); 951 break; 952 case 'middle-right': 953 this.rpMiddleRight(parent, 954 child, 955 pw, 956 ph); 957 break; 958 case 'right': 959 this.rpRight(parent, 960 child, 961 pw); 962 break; 963 case 'top': 964 this.rpTop(parent, 965 child, 966 ph); 967 break; 968 case 'top-center': 969 this.rpTopCenter(parent, 970 child, 971 pw, 972 ph); 973 break; 974 case 'top-left': 975 this.rpTopLeft(parent, 976 child, 977 pw, 978 ph); 979 break; 980 case 'top-right': 981 this.rpTopRight(parent, 982 child, 983 pw, 984 ph); 985 break; 986 case 'vertical-center': 987 this.rpCenterVertically(parent, 988 child, 989 ph); 990 break; 991 } 992 }; 993 994 /* 995 * Position item on bottom. 996 * 997 * @param parent (element): parent item 998 * @param child (element): child item 999 * @param ph (Number): height to which the parent is going to be set 1000 */ 1001 this.rpBottom = function(parent, 1002 child, 1003 ph){ 1004 if (ph !== undefined){ 1005 parent.height(ph); 1006 } 1007 child.css('margin-top', parent.height()-child.height()); 1008 }; 1009 1010 /* 1011 * Position item on bottom-left. 1012 * 1013 * @param parent (element): parent item 1014 * @param child (element): child item 1015 * @param pw (Number): width to which the parent is going to be set 1016 * @param ph (Number): height to which the parent is going to be set 1017 */ 1018 this.rpBottomCenter = function(parent, 1019 child, 1020 pw, 1021 ph){ 1022 this.rpBottom(parent, 1023 child, 1024 ph); 1025 this.rpCenterHorizontally(parent, 1026 child, 1027 pw); 1028 }; 1029 1030 /* 1031 * Position item on bottom-left. 1032 * 1033 * @param parent (element): parent item 1034 * @param child (element): child item 1035 * @param pw (Number): width to which the parent is going to be set 1036 * @param ph (Number): height to which the parent is going to be set 1037 */ 1038 this.rpBottomLeft = function(parent, 1039 child, 1040 pw, 1041 ph){ 1042 this.rpBottom(parent, 1043 child, 1044 ph); 1045 this.rpLeft(parent, 1046 child, 1047 pw); 1048 }; 1049 1050 /* 1051 * Position item on bottom-left. 1052 * 1053 * @param parent (element): parent item 1054 * @param child (element): child item 1055 * @param pw (Number): width to which the parent is going to be set 1056 * @param ph (Number): height to which the parent is going to be set 1057 */ 1058 this.rpBottomRight = function(parent, 1059 child, 1060 pw, 1061 ph){ 1062 this.rpBottom(parent, 1063 child, 1064 ph); 1065 this.rpRight(parent, 1066 child, 1067 pw); 1068 }; 1069 1070 /* 1071 * Position item on center. 1072 * 1073 * @param parent (element): parent item 1074 * @param child (element): child item 1075 * @param pw (Number): width to which the parent is going to be set 1076 * @param ph (Number): height to which the parent is going to be set 1077 */ 1078 this.rpCenter = function(parent, 1079 child, 1080 pw, 1081 ph){ 1082 this.rpCenterHorizontally(parent, 1083 child, 1084 pw); 1085 this.rpCenterVertically(parent, 1086 child, 1087 ph); 1088 }; 1089 1090 /* 1091 * Center item horizontally. 1092 * 1093 * @param parent (element): parent item 1094 * @param child (element): child item 1095 * @param pw (Number): width to which the parent is going to be set 1096 */ 1097 this.rpCenterHorizontally = function(parent, 1098 child, 1099 pw){ 1100 if (pw !== undefined){ 1101 parent.width(pw); 1102 } 1103 child.css('margin-left', (parent.width()-child.width())/2); 1104 }; 1105 1106 /* 1107 * Center item vertically. 1108 * 1109 * @param parent (element): parent item 1110 * @param child (element): child item 1111 * @param ph (Number): height to which the parent is going to be set 1112 */ 1113 this.rpCenterVertically = function(parent, 1114 child, 1115 ph){ 1116 if (ph !== undefined){ 1117 parent.height(ph); 1118 } 1119 child.css('margin-top', (parent.height()-child.height())/2); 1120 }; 1121 1122 /* 1123 * Position item on left. 1124 * 1125 * @param parent (element): parent item 1126 * @param child (element): child item 1127 * @param pw (Number): width to which the parent is going to be set 1128 */ 1129 this.rpLeft = function(parent, 1130 child, 1131 pw){ 1132 if (pw !== undefined){ 1133 parent.width(pw); 1134 } 1135 child.css('margin-left', 0); 1136 }; 1137 1138 /* 1139 * Position item on middle-left. 1140 * 1141 * @param parent (element): parent item 1142 * @param child (element): child item 1143 * @param pw (Number): width to which the parent is going to be set 1144 * @param ph (Number): height to which the parent is going to be set 1145 */ 1146 this.rpMiddleLeft = function(parent, 1147 child, 1148 pw, 1149 ph){ 1150 this.rpCenterVertically(parent, 1151 child, 1152 ph); 1153 this.rpLeft(parent, 1154 child, 1155 pw); 1156 }; 1157 1158 /* 1159 * Position item on middle-right. 1160 * 1161 * @param parent (element): parent item 1162 * @param child (element): child item 1163 * @param pw (Number): width to which the parent is going to be set 1164 * @param ph (Number): height to which the parent is going to be set 1165 */ 1166 this.rpMiddleRight = function(parent, 1167 child, 1168 pw, 1169 ph){ 1170 this.rpCenterVertically(parent, 1171 child, 1172 ph); 1173 this.rpRight(parent, 1174 child, 1175 pw); 1176 }; 1177 1178 /* 1179 * Position item on right. 1180 * 1181 * @param parent (element): parent item 1182 * @param child (element): child item 1183 * @param pw (Number): width to which the parent is going to be set 1184 */ 1185 this.rpRight = function(parent, 1186 child, 1187 pw){ 1188 if (pw !== undefined){ 1189 parent.width(pw); 1190 } 1191 child.css('margin-left', parent.width()-child.width()); 1192 }; 1193 1194 /* 1195 * Position item on top. 1196 * 1197 * @param parent (element): parent item 1198 * @param child (element): child item 1199 * @param ph (Number): height to which the parent is going to be set 1200 */ 1201 this.rpTop = function(parent, 1202 child, 1203 ph){ 1204 if (ph !== undefined){ 1205 parent.height(ph); 1206 } 1207 child.css('margin-top', 0); 1208 }; 1209 1210 /* 1211 * Position item on top-center. 1212 * 1213 * @param parent (element): parent item 1214 * @param child (element): child item 1215 * @param pw (Number): width to which the parent is going to be set 1216 * @param ph (Number): height to which the parent is going to be set 1217 */ 1218 this.rpTopCenter = function(parent, 1219 child, 1220 pw, 1221 ph){ 1222 this.rpTop(parent, 1223 child, 1224 ph); 1225 this.rpCenterHorizontally(parent, 1226 child, 1227 pw); 1228 }; 1229 1230 /* 1231 * Position item on top-left. 1232 * 1233 * @param parent (element): parent item 1234 * @param child (element): child item 1235 * @param pw (Number): width to which the parent is going to be set 1236 * @param ph (Number): height to which the parent is going to be set 1237 */ 1238 this.rpTopLeft = function(parent, 1239 child, 1240 pw, 1241 ph){ 1242 this.rpTop(parent, 1243 child, 1244 ph); 1245 this.rpLeft(parent, 1246 child, 1247 pw); 1248 }; 1249 1250 /* 1251 * Position item on top-right. 1252 * 1253 * @param parent (element): parent item 1254 * @param child (element): child item 1255 * @param pw (Number): width to which the parent is going to be set 1256 * @param ph (Number): height to which the parent is going to be set 1257 */ 1258 this.rpTopRight = function(parent, 1259 child, 1260 pw, 1261 ph){ 1262 this.rpTop(parent, 1263 child, 1264 ph); 1265 this.rpRight(parent, 1266 child, 1267 pw); 1268 }; 1269 1270// Strings & numbers 1271 1272 /* 1273 * Clean an input from unwanted characters. 1274 * 1275 * @param input (element): the input to be checked 1276 * @param allowedCharacters (String): the string of allowed characters 1277 * @param firstNotAllowed (String): the character which can't be on the first position 1278 * @param min (Number/String): the minimum value that is allowed in the input 1279 * 1280 * @return clean string 1281 */ 1282 this.cleanInput = function(input, 1283 allowedCharacters, 1284 firstNotAllowed, 1285 min){ 1286 var characters = input.val().split(''), 1287 returnStr = '', 1288 i, 1289 startIndex = 0; 1290 1291 /* 1292 * Check first character. 1293 */ 1294 if (characters.length > 1 1295 && characters[0] === firstNotAllowed){ 1296 startIndex = 1; 1297 } 1298 1299 /* 1300 * Check characters. 1301 */ 1302 for (i=startIndex; i<characters.length; i++){ 1303 if (allowedCharacters.indexOf(characters[i]) !== -1){ 1304 returnStr += characters[i]; 1305 } 1306 } 1307 1308 /* 1309 * Check the minimum value. 1310 */ 1311 if (min > returnStr){ 1312 returnStr = min; 1313 } 1314 1315 input.val(returnStr); 1316 }; 1317 1318 /* 1319 * Adds a leading 0 if number smaller than 10. 1320 * 1321 * @param no (Number): the number 1322 * 1323 * @return number with leading 0 if needed 1324 */ 1325 this.getLeadingZero = function(no){ 1326 if (no < 10){ 1327 return '0'+no; 1328 } 1329 else{ 1330 return no; 1331 } 1332 }; 1333 1334 /* 1335 * Creates a string with random characters. 1336 * 1337 * @param stringLength (Number): the length of the returned string 1338 * @param allowedCharacters (String): the string of allowed characters 1339 * 1340 * @return random string 1341 */ 1342 this.getRandomString = function(stringLength, 1343 allowedCharact
1343ers){ 1344 var randomString = '', 1345 charactersPosition, 1346 i; 1347 1348 allowedCharacters = allowedCharacters !== undefined ? allowedCharacters:'0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'; 1349 1350 for (i=0; i<stringLength; i++){ 1351 charactersPosition = Math.floor(Math.random()*allowedCharacters.length); 1352 randomString += allowedCharacters.substring(charactersPosition, charactersPosition+1); 1353 } 1354 return randomString; 1355 }; 1356 1357 /* 1358 * Returns a part of a string followed by 3 dots. 1359 * 1360 * @param str (String): the string 1361 * @param size (Number): the number of characters that will be displayed minus 3 dots 1362 * 1363 * @return short string ... 1364 */ 1365 this.getShortString = function(str, 1366 size){ 1367 var newStr = new Array(), 1368 pieces = str.split(''), 1369 i; 1370 1371 if (pieces.length <= size){ 1372 newStr.push(str); 1373 } 1374 else{ 1375 for (i=0; i<size-3; i++){ 1376 newStr.push(pieces[i]); 1377 } 1378 newStr.push('...'); 1379 } 1380 1381 return newStr.join(''); 1382 }; 1383 1384 /* 1385 * Returns a number with a predefined number of decimals. 1386 * 1387 * @param number (Number): the number 1388 * @param no (Number): the number of decimals 1389 * 1390 * @return string with number and decimals 1391 */ 1392 this.getWithDecimals = function(number, 1393 no){ 1394 no = no === undefined ? 2:no; 1395 return parseInt(number) === number ? String(number):parseFloat(number).toFixed(no); 1396 }; 1397 1398 /* 1399 * Verify if a string contains allowed characters. 1400 * 1401 * @param str (String): string to be checked 1402 * @param allowedCharacters (String): the string of allowed characters 1403 * 1404 * @return true/false 1405 */ 1406 this.validateCharacters = function(str, 1407 allowedCharacters){ 1408 var characters = str.split(''), 1409 i; 1410 1411 for (i=0; i<characters.length; i++){ 1412 if (allowedCharacters.indexOf(characters[i]) === -1){ 1413 return false; 1414 } 1415 } 1416 return true; 1417 }; 1418 1419 /* 1420 * Email validation. 1421 * 1422 * @param email (String): email to be checked 1423 * 1424 * @return true/false 1425 */ 1426 this.validEmail = function(email){ 1427 var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,16}(?:\.[a-z]{2})?)$/i; 1428 1429 if (filter.test(email)){ 1430 return true; 1431 } 1432 return false; 1433 }; 1434 1435 /* 1436 * Remove slashes from string. 1437 * 1438 * @param str (String): the string 1439 * 1440 * @return string without slashes 1441 */ 1442 this.stripSlashes = function(str){ 1443 return (str + '').replace(/\\(.?)/g, function (s, n1){ 1444 switch (n1){ 1445 case '\\': 1446 return '\\'; 1447 case '0': 1448 return '\u0000'; 1449 case '': 1450 return ''; 1451 default: 1452 return n1; 1453 } 1454 }); 1455 }; 1456 1457// Styles 1458 1459 /* 1460 * Convert RGB color to HEX. 1461 * 1462 * @param rgb (String): RGB color 1463 * 1464 * @return color HEX 1465 */ 1466 this.getHEXfromRGB = function(rgb){ 1467 var hexDigits = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'); 1468 1469 rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); 1470 1471 return (isNaN(rgb[1]) ? '00':hexDigits[(rgb[1]-rgb[1]%16)/16]+hexDigits[rgb[1]%16])+ 1472 (isNaN(rgb[2]) ? '00':hexDigits[(rgb[2]-rgb[2]%16)/16]+hexDigits[rgb[2]%16])+ 1473 (isNaN(rgb[3]) ? '00':hexDigits[(rgb[3]-rgb[3]%16)/16]+hexDigits[rgb[3]%16]); 1474 }; 1475 1476 /* 1477 * Set text color depending on the background color. 1478 * 1479 * @param bgColor(String): background color 1480 * 1481 * return white/black 1482 */ 1483 this.getIdealTextColor = function(bgColor){ 1484 var rgb = /rgb\((\d+).*?(\d+).*?(\d+)\)/.exec(bgColor); 1485 1486 if (rgb !== null){ 1487 return parseInt(rgb[1], 10)+parseInt(rgb[2], 10)+parseInt(rgb[3], 10) < 3*256/2 ? 'white' : 'black'; 1488 } 1489 else{ 1490 return parseInt(bgColor.substring(0, 2), 16)+parseInt(bgColor.substring(2, 4), 16)+parseInt(bgColor.substring(4, 6), 16) < 3*256/2 ? 'white' : 'black'; 1491 } 1492 }; 1493 1494 this.getCountries = function(){ 1495 return [{"code":"+93","code2":"AF","name":"Afghanistan"},{"code":"+355","code2":"AL","name":"Albania"},{"code":"+213","code2":"DZ","name":"Algeria"},{"code":"+1 684","code2":"AS","name":"American Samoa"},{"code":"+376","code2":"AD","name":"Andorra"},{"code":"+244","code2":"AO","name":"Angola"},{"code":"+1 264","code2":"AI","name":"Anguilla"},{"code":"+672","code2":"AQ","name":"Antarctica"},{"code":"+1 268","code2":"AG","name":"Antigua and Barbuda"},{"code":"+54","code2":"AR","name":"Argentina"},{"code":"+374","code2":"AM","name":"Armenia"},{"code":"+297","code2":"AW","name":"Aruba"},{"code":"+61","code2":"AU","name":"Australia"},{"code":"+43","code2":"AT","name":"Austria"},{"code":"+994","code2":"AZ","name":"Azerbaijan"},{"code":"+1 242","code2":"BS","name":"Bahamas"},{"code":"+973","code2":"BH","name":"Bahrain"},{"code":"+880","code2":"BD","name":"Bangladesh"},{"code":"+1 246","code2":"BB","name":"Barbados"},{"code":"+375","code2":"BY","name":"Belarus"},{"code":"+32","code2":"BE","name":"Belgium"},{"code":"+501","code2":"BZ","name":"Belize"},{"code":"+229","code2":"BJ","name":"Benin"},{"code":"+1 441","code2":"BM","name":"Bermuda"},{"code":"+975","code2":"BT","name":"Bhutan"},{"code":"+591","code2":"BO","name":"Bolivia"},{"code":"+387","code2":"BA","name":"Bosnia and Herzegovina"},{"code":"+267","code2":"BW","name":"Botswana"},{"code":"+55","code2":"BR","name":"Brazil"},{"code":"+246","code2":"IO","name":"British Indian Ocean Territory"},{"code":"+1 284","code2":"VG","name":"British Virgin Islands"},{"code":"+673","code2":"BN","name":"Brunei"},{"code":"+359","code2":"BG","name":"Bulgaria"},{"code":"+226","code2":"BF","name":"Burkina Faso"},{"code":"+257","code2":"BI","name":"Burundi"},{"code":"+855","code2":"KH","name":"Cambodia"},{"code":"+237","code2":"CM","name":"Cameroon"},{"code":"+1","code2":"CA","name":"Canada"},{"code":"+238","code2":"CV","name":"Cape Verde"},{"code":"+ 345","code2":"KY","name":"Cayman Islands"},{"code":"+236","code2":"CF","name":"Central African Republic"},{"code":"+235","code2":"TD","name":"Chad"},{"code":"+56","code2":"CL","name":"Chile"},{"code":"+86","code2":"CN","name":"China"}
1495,{"code":"+61","code2":"CX","name":"Christmas Island"},{"code":"+61","code2":"CC","name":"Cocos-Keeling Islands"},{"code":"+57","code2":"CO","name":"Colombia"},{"code":"+269","code2":"KM","name":"Comoros"},{"code":"+242","code2":"CG","name":"Congo"},{"code":"+243","code2":"CD","name":"Congo, Dem. Rep. of (Zaire)"},{"code":"+682","code2":"CK","name":"Cook Islands"},{"code":"+506","code2":"CR","name":"Costa Rica"},{"code":"+385","code2":"HR","name":"Croatia"},{"code":"+53","code2":"CU","name":"Cuba"},{"code":"+357","code2":"CY","name":"Cyprus"},{"code":"+420","code2":"CZ","name":"Czech Republic"},{"code":"+45","code2":"DK","name":"Denmark"},{"code":"+253","code2":"DJ","name":"Djibouti"},{"code":"+1 767","code2":"DM","name":"Dominica"},{"code":"+1 809","code2":"DO","name":"Dominican Republic"},{"code":"+670","code2":"TL","name":"East Timor"},{"code":"+593","code2":"EC","name":"Ecuador"},{"code":"+20","code2":"EG","name":"Egypt"},{"code":"+503","code2":"SV","name":"El Salvador"},{"code":"+240","code2":"GQ","name":"Equatorial Guinea"},{"code":"+291","code2":"ER","name":"Eritrea"},{"code":"+372","code2":"EE","name":"Estonia"},{"code":"+251","code2":"ET","name":"Ethiopia"},{"code":"+500","code2":"FK","name":"Falkland Islands"},{"code":"+298","code2":"FO","name":"Faroe Islands"},{"code":"+679","code2":"FJ","name":"Fiji"},{"code":"+358","code2":"FI","name":"Finland"},{"code":"+33","code2":"FR","name":"France"},{"code":"+594","code2":"GF","name":"French Guiana"},{"code":"+689","code2":"PF","name":"French Polynesia"},{"code":"+241","code2":"GA","name":"Gabon"},{"code":"+220","code2":"GM","name":"Gambia"},{"code":"+995","code2":"GE","name":"Georgia"},{"code":"+49","code2":"DE","name":"Germany"},{"code":"+233","code2":"GH","name":"Ghana"},{"code":"+350","code2":"GI","name":"Gibraltar"},{"code":"+30","code2":"GR","name":"Greece"},{"code":"+299","code2":"GL","name":"Greenland"},{"code":"+1 473","code2":"GD","name":"Grenada"},{"code":"+590","code2":"GP","name":"Guadeloupe"},{"code":"+1 671","code2":"GU","name":"Guam"},{"code":"+502","code2":"GT","name":"Guatemala"},{"code":"+224","code2":"GN","name":"Guinea"},{"code":"+245","code2":"GW","name":"Guinea-Bissau"},{"code":"+595","code2":"GY","name":"Guyana"},{"code":"+509","code2":"HT","name":"Haiti"},{"code":"+379","code2":"VA","name":"Holy See(Vatican)"},{"code":"+504","code2":"HN","name":"Honduras"},{"code":"+852","code2":"HK","name":"Hong Kong SAR China"},{"code":"+36","code2":"HU","name":"Hungary"},{"code":"+354","code2":"IS","name":"Iceland"},{"code":"+91","code2":"IN","name":"India"},{"code":"+62","code2":"ID","name":"Indonesia"},{"code":"+98","code2":"IR","name":"Iran"},{"code":"+964","code2":"IQ","name":"Iraq"},{"code":"+353","code2":"IE","name":"Ireland"},{"code":"+972","code2":"IR","name":"Israel"},{"code":"+39","code2":"IT","name":"Italy"},{"code":"+225","code2":"CI","name":"Ivory Coast"},{"code":"+1 876","code2":"JM","name":"Jamaica"},{"code":"+81","code2":"JP","name":"Japan"},{"code":"+962","code2":"JO","name":"Jordan"},{"code":"+7","code2":"KZ","name":"Kazakhstan"},{"code":"+254","code2":"KE","name":"Kenya"},{"code":"+686","code2":"KI","name":"Kiribati"},{"code":"+965","code2":"KW","name":"Kuwait"},{"code":"+996","code2":"KG","name":"Kyrgyzstan"},{"code":"+856","code2":"LA","name":"Laos"},{"code":"+371","code2":"LV","name":"Latvia"},{"code":"+961","code2":"LB","name":"Lebanon"},{"code":"+266","code2":"LS","name":"Lesotho"},{"code":"+231","code2":"LR","name":"Liberia"},{"code":"+218","code2":"LY","name":"Libya"},{"code":"+423","code2":"LI","name":"Liechtenstein"},{"code":"+370","code2":"LT","name":"Lithuania"},{"code":"+352","code2":"LU","name":"Luxembourg"},{"code":"+853","code2":"MO","name":"Macau SAR China"},{"code":"+389","code2":"MK","name":"Macedonia"},{"code":"+261","code2":"MG","name":"Madagascar"},{"code":"+265","code2":"MW","name":"Malawi"},{"code":"+60","code2":"MY","name":"Malaysia"},{"code":"+960","code2":"MV","name":"Maldives"},{"code":"+223","code2":"ML","name":"Mali"},{"code":"+356","code2":"MT","name":"Malta"},{"code":"+692","code2":"MH","name":"Marshall Islands"},{"code":"+596","code2":"MQ","name":"Martinique"},{"code":"+222","code2":"MR","name":"Mauritania"},{"code":"+230","code2":"MU","name":"Mauritius"},{"code":"+262","code2":"YT","name":"Mayotte"},{"code":"+52","code2":"MX","name":"Mexico"},{"code":"+691","code2":"FM","name":"Micronesia"},{"code":"+373","code2":"MD","name":"Moldova"},{"code":"+377","code2":"MC","name":"Monaco"},{"code":"+976","code2":"MN","name":"Mongolia"},{"code":"+382","code2":"ME","name":"Montenegro"},{"code":"+1664","code2":"MS","name":"Montserrat"},{"code":"+212","code2":"MA","name":"Morocco"},{"code":"+258","code2":"MZ","name":"Mozambique"},{"code":"+95","code2":"MM","name":"Myanmar"},{"code":"+264","code2":"NA","name":"Namibia"},{"code":"+674","code2":"NR","name":"Nauru"},{"code":"+977","code2":"NP","name":"Nepal"},{"code":"+31","code2":"NL","name":"Netherlands"},{"code":"+599","code2":"AN","name":"Netherlands Antilles"},{"code":"+1 869","code2":"KN","name":"Nevis"},{"code":"+687","code2":"NC","name":"New Caledonia"},{"code":"+64","code2":"NZ","name":"New Zealand"},{"code":"+505","code2":"NI","name":"Nicaragua"},{"code":"+227","code2":"NE","name":"Niger"},{"code":"+234","code2":"NG","name":"Nigeria"},{"code":"+683","code2":"NU","name":"Niue"},{"code":"+672","code2":"NF","name":"Norfolk Island"},{"code":"+850","code2":"KP","name":"North Korea"},{"code":"+1 670","code2":"MP","name":"Northern Mariana Islands"},{"code":"+47","code2":"NO","name":"Norway"},{"code":"+968","code2":"OM","name":"Oman"},{"code":"+92","code2":"PK","name":"Pakistan"},{"code":"+680","code2":"PW","name":"Palau"},{"code":"+970","code2":"PS","name":"Palestinian Territory"},{"code":"+507","code2":"PA","name":"Panama"},{"code":"+675","code2":"PG","name":"Papua New Guinea"},{"code":"+595","code2":"PY","name":"Paraguay"},{"code":"+51","code2":"PE","name":"Peru"},{"code":"+63","code2":"PH","name":"Philippines"},{"code":"+64","code2":"PN","name":"Pitcairn Islands"},{"code":"+48","code2":"PL","name":"Poland"},{"code":"+351","code2":"PT","name":"Portugal"},{"code":"+1 787","code2":"PR","name":"Puerto Rico"},{"code":"+974","code2":"QA","name":"Qatar"},{"code":"+262","code2":"RE","name":"Reunion"},{"code":"+40","code2":"RO","name":"Romania"}
1495,{"code":"+7","code2":"RU","name":"Russia"},{"code":"+250","code2":"RW","name":"Rwanda"},{"code":"+685","code2":"WS","name":"Samoa"},{"code":"+378","code2":"SM","name":"San Marino"},{"code":"+966","code2":"SA","name":"Saudi Arabia"},{"code":"+221","code2":"SN","name":"Senegal"},{"code":"+381","code2":"RS","name":"Serbia"},{"code":"+248","code2":"SC","name":"Seychelles"},{"code":"+232","code2":"SL","name":"Sierra Leone"},{"code":"+65","code2":"SG","name":"Singapore"},{"code":"+421","code2":"SK","name":"Slovakia"},{"code":"+386","code2":"SI","name":"Slovenia"},{"code":"+677","code2":"SB","name":"Solomon Islands"},{"code":"+27","code2":"ZA","name":"South Africa"},{"code":"+500","code2":"GS","name":"South Georgia and the South Sandwich Islands"},{"code":"+82","code2":"KR","name":"South Korea"},{"code":"+34","code2":"ES","name":"Spain"},{"code":"+94","code2":"LK","name":"Sri Lanka"},{"code":"+249","code2":"SD","name":"Sudan"},{"code":"+597","code2":"SR","name":"Suriname"},{"code":"+268","code2":"SZ","name":"Swaziland"},{"code":"+46","code2":"SE","name":"Sweden"},{"code":"+41","code2":"CH","name":"Switzerland"},{"code":"+963","code2":"SY","name":"Syria"},{"code":"+886","code2":"TW","name":"Taiwan"},{"code":"+992","code2":"TJ","name":"Tajikistan"},{"code":"+255","code2":"TZ","name":"Tanzania"},{"code":"+66","code2":"TH","name":"Thailand"},{"code":"+670","code2":"TL","name":"Timor Leste"},{"code":"+228","code2":"TG","name":"Togo"},{"code":"+690","code2":"TK","name":"Tokelau"},{"code":"+676","code2":"TO","name":"Tonga"},{"code":"+1 868","code2":"TT","name":"Trinidad and Tobago"},{"code":"+216","code2":"TN","name":"Tunisia"},{"code":"+90","code2":"TR","name":"Turkey"},{"code":"+993","code2":"TM","name":"Turkmenistan"},{"code":"+1 649","code2":"TC","name":"Turks and Caicos Islands"},{"code":"+688","code2":"TV","name":"Tuvalu"},{"code":"+1 340","code2":"VI","name":"U.S. Virgin Islands"},{"code":"+256","code2":"UG","name":"Uganda"},{"code":"+380","code2":"UA","name":"Ukraine"},{"code":"+971","code2":"AE","name":"United Arab Emirates"},{"code":"+44","code2":"GB","name":"United Kingdom"},{"code":"+1","code2":"US","name":"United States"},{"code":"+598","code2":"UY","name":"Uruguay"},{"code":"+998","code2":"UZ","name":"Uzbekistan"},{"code":"+678","code2":"VU","name":"Vanuatu"},{"code":"+58","code2":"VE","name":"Venezuela"},{"code":"+84","code2":"VN","name":"Vietnam"},{"code":"+681","code2":"WF","name":"Wallis and Futuna"},{"code":"+967","code2":"YE","name":"Yemen"},{"code":"+260","code2":"ZM","name":"Zambia"},{"code":"+263","code2":"ZW","name":"Zimbabwe"}]; 1496 }; 1497 1498 return this.__construct(); 1499};
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.