Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist

This is an example implementation of Mappa (github.com/Wolfy87/Mappa)

View Oliver Caldwell's JavaScript toolbox.md

This is an example implementation of Mappa (github.com/Wolfy87/Mappa)

So all you need to do is include the Mappa script which you can download from the repo. The minified version is absolutely tiny.

Then include toolbox.js. Then what do ya know! It just works. Now if you scroll to the bottom of toolbox.js you will see the mappings. It is self explaining documentation. To learn about the functions you will need to go to their respective docs which are linked to from the read me. The read me can be found in the repository.

For example, here is how you dump all of the cookies from the page.

Toolbox.cookies.dump();

Enjoy and create your own toolboxes.

View Oliver Caldwell's JavaScript toolbox.md
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709
/*
Oliver Caldwell's JavaScript toolbox
An example use of Mappa (github.com/Wolfy87/Mappa)
Copyright 2011, Oliver Caldwell (flowdev.co.uk)
*/
 
// All the mapping is done at the bottom, after the functions have initialised
 
// Cookie Toolbox Javascript
// copyright 4th September 2002, by Stephen Chapman, Felgall Pty Ltd
 
// You have permission to copy and use this javascript provided that
// the content of the script is not changed in any way.
// For instructions on how to use these functions see "A Cookie Toolbox"
// in the Javascript section of our site at http://www.felgall.com/
 
var dbug = 0; function d_a(ary) {var beg = next_entry(ary) - 1; for (var i = beg ; i > -1; i--) {ary[i] = null;}} function init_array() {if (dbug) alert('init_cookie'); var ary = new Array(null); return ary;} function set_cookie(name,value,expires) {if (dbug) alert('set_cookie'); if (!expires) expires = new Date();
document.cookie = name + '=' + escape(value) + '; expires=' + expires.toGMTString() + '; path=/';} function get_cookie(name) {if (dbug) alert('get_cookie'); var dcookie = document.cookie; var cname = name + "="; var clen = dcookie.length; var cbegin = 0; while (cbegin < clen) {var vbegin = cbegin + cname.length;
if (dcookie.substring(cbegin, vbegin) == cname) {var vend = dcookie.indexOf (";", vbegin); if (vend == -1) vend = clen; return unescape(dcookie.substring(vbegin, vend));} cbegin = dcookie.indexOf(" ", cbegin) + 1; if (cbegin == 0) break;} return null;} function del_cookie(name) {if (dbug) alert('del_cookie');
document.cookie = name + '=' + '; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/';} function get_array(name, ary) {if (dbug) alert('get_array'); d_a(ary); var ent = get_cookie(name); if (ent) {i = 1; while (ent.indexOf('^') != '-1') {ary[i] = ent.substring(0,ent.indexOf('^')); i++;
ent = ent.substring(ent.indexOf('^')+1, ent.length);}}} function set_array(name, ary, expires) {if (dbug) alert('set_array'); var value = ''; for (var i = 1; ary[i]; i++) {value += ary[i] + '^';} set_cookie(name, value, expires);} function del_entry(name, ary, pos, expires) {if (dbug) alert('del_entry');
var value = ''; get_array(name, ary); for (var i = 1; i < pos; i++) {value += ary[i] + '^';} for (var j = pos + 1; ary[j]; j++) {value += ary[j] + '^';} set_cookie(name, value, expires);} function next_entry(ary) {if (dbug) alert('next_entry'); var j = 0; for (var i = 1; ary[i]; i++) {j = i} return j + 1;}
function debug_on() {dbug = 1;} function debug_off() {dbug = 0;} function dump_cookies() {if (document.cookie == '') document.write('No Cookies Found'); else {thisCookie = document.cookie.split('; '); for (i=0; i<thisCookie.length; i++) {document.write(thisCookie[i] + '<br \/>');}}}
 
// ===================================================================
// Author: Matt Kruse <matt@ajaxtoolbox.com>
// WWW: http://www.AjaxToolbox.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download.
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================
 
/**
* The AjaxRequest class is a wrapper for the XMLHttpRequest objects which
* are available in most modern browsers. It simplifies the interfaces for
* making Ajax requests, adds commonly-used convenience methods, and makes
* the process of handling state changes more intuitive.
* An object may be instantiated and used, or the Class methods may be used
* which internally create an AjaxRequest object.
*/
function AjaxRequest() {
var req = new Object();
// -------------------
// Instance properties
// -------------------
 
/**
* Timeout period (in ms) until an async request will be aborted, and
* the onTimeout function will be called
*/
req.timeout = null;
/**
* Since some browsers cache GET requests via XMLHttpRequest, an
* additional parameter called AjaxRequestUniqueId will be added to
* the request URI with a unique numeric value appended so that the requested
* URL will not be cached.
*/
req.generateUniqueUrl = true;
/**
* The url that the request will be made to, which defaults to the current
* url of the window
*/
req.url = window.location.href;
/**
* The method of the request, either GET (default), POST, or HEAD
*/
req.method = "GET";
/**
* Whether or not the request will be asynchronous. In general, synchronous
* requests should not be used so this should rarely be changed from true
*/
req.async = true;
/**
* The username used to access the URL
*/
req.username = null;
/**
* The password used to access the URL
*/
req.password = null;
/**
* The parameters is an object holding name/value pairs which will be
* added to the url for a GET request or the request content for a POST request
*/
req.parameters = new Object();
/**
* The sequential index number of this request, updated internally
*/
req.requestIndex = AjaxRequest.numAjaxRequests++;
/**
* Indicates whether a response has been received yet from the server
*/
req.responseReceived = false;
/**
* The name of the group that this request belongs to, for activity
* monitoring purposes
*/
req.groupName = null;
/**
* The query string to be added to the end of a GET request, in proper
* URIEncoded format
*/
req.queryString = "";
/**
* After a response has been received, this will hold the text contents of
* the response - even in case of error
*/
req.responseText = null;
/**
* After a response has been received, this will hold the XML content
*/
req.responseXML = null;
/**
* After a response has been received, this will hold the status code of
* the response as returned by the server.
*/
req.status = null;
/**
* After a response has been received, this will hold the text description
* of the response code
*/
req.statusText = null;
 
/**
* An internal flag to indicate whether the request has been aborted
*/
req.aborted = false;
/**
* The XMLHttpRequest object used internally
*/
req.xmlHttpRequest = null;
 
// --------------
// Event handlers
// --------------
/**
* If a timeout period is set, and it is reached before a response is
* received, a function reference assigned to onTimeout will be called
*/
req.onTimeout = null;
/**
* A function reference assigned will be called when readyState=1
*/
req.onLoading = null;
 
/**
* A function reference assigned will be called when readyState=2
*/
req.onLoaded = null;
 
/**
* A function reference assigned will be called when readyState=3
*/
req.onInteractive = null;
 
/**
* A function reference assigned will be called when readyState=4
*/
req.onComplete = null;
 
/**
* A function reference assigned will be called after onComplete, if
* the statusCode=200
*/
req.onSuccess = null;
 
/**
* A function reference assigned will be called after onComplete, if
* the statusCode != 200
*/
req.onError = null;
/**
* If this request has a group name, this function reference will be called
* and passed the group name if this is the first request in the group to
* become active
*/
req.onGroupBegin = null;
 
/**
* If this request has a group name, and this request is the last request
* in the group to complete, this function reference will be called
*/
req.onGroupEnd = null;
 
// Get the XMLHttpRequest object itself
req.xmlHttpRequest = AjaxRequest.getXmlHttpRequest();
if (req.xmlHttpRequest==null) { return null; }
// -------------------------------------------------------
// Attach the event handlers for the XMLHttpRequest object
// -------------------------------------------------------
req.xmlHttpRequest.onreadystatechange =
function() {
if (req==null || req.xmlHttpRequest==null) { return; }
if (req.xmlHttpRequest.readyState==1) { req.onLoadingInternal(req); }
if (req.xmlHttpRequest.readyState==2) { req.onLoadedInternal(req); }
if (req.xmlHttpRequest.readyState==3) { req.onInteractiveInternal(req); }
if (req.xmlHttpRequest.readyState==4) { req.onCompleteInternal(req); }
};
// ---------------------------------------------------------------------------
// Internal event handlers that fire, and in turn fire the user event handlers
// ---------------------------------------------------------------------------
// Flags to keep track if each event has been handled, in case of
// multiple calls (some browsers may call the onreadystatechange
// multiple times for the same state)
req.onLoadingInternalHandled = false;
req.onLoadedInternalHandled = false;
req.onInteractiveInternalHandled = false;
req.onCompleteInternalHandled = false;
req.onLoadingInternal =
function() {
if (req.onLoadingInternalHandled) { return; }
AjaxRequest.numActiveAjaxRequests++;
if (AjaxRequest.numActiveAjaxRequests==1 && typeof(window['AjaxRequestBegin'])=="function") {
AjaxRequestBegin();
}
if (req.groupName!=null) {
if (typeof(AjaxRequest.numActiveAjaxGroupRequests[req.groupName])=="undefined") {
AjaxRequest.numActiveAjaxGroupRequests[req.groupName] = 0;
}
AjaxRequest.numActiveAjaxGroupRequests[req.groupName]++;
if (AjaxRequest.numActiveAjaxGroupRequests[req.groupName]==1 && typeof(req.onGroupBegin)=="function") {
req.onGroupBegin(req.groupName);
}
}
if (typeof(req.onLoading)=="function") {
req.onLoading(req);
}
req.onLoadingInternalHandled = true;
};
req.onLoadedInternal =
function() {
if (req.onLoadedInternalHandled) { return; }
if (typeof(req.onLoaded)=="function") {
req.onLoaded(req);
}
req.onLoadedInternalHandled = true;
};
req.onInteractiveInternal =
function() {
if (req.onInteractiveInternalHandled) { return; }
if (typeof(req.onInteractive)=="function") {
req.onInteractive(req);
}
req.onInteractiveInternalHandled = true;
};
req.onCompleteInternal =
function() {
if (req.onCompleteInternalHandled || req.aborted) { return; }
req.onCompleteInternalHandled = true;
AjaxRequest.numActiveAjaxRequests--;
if (AjaxRequest.numActiveAjaxRequests==0 && typeof(window['AjaxRequestEnd'])=="function") {
AjaxRequestEnd(req.groupName);
}
if (req.groupName!=null) {
AjaxRequest.numActiveAjaxGroupRequests[req.groupName]--;
if (AjaxRequest.numActiveAjaxGroupRequests[req.groupName]==0 && typeof(req.onGroupEnd)=="function") {
req.onGroupEnd(req.groupName);
}
}
req.responseReceived = true;
req.status = req.xmlHttpRequest.status;
req.statusText = req.xmlHttpRequest.statusText;
req.responseText = req.xmlHttpRequest.responseText;
req.responseXML = req.xmlHttpRequest.responseXML;
if (typeof(req.onComplete)=="function") {
req.onComplete(req);
}
if (req.xmlHttpRequest.status==200 && typeof(req.onSuccess)=="function") {
req.onSuccess(req);
}
else if (typeof(req.onError)=="function") {
req.onError(req);
}
 
// Clean up so IE doesn't leak memory
delete req.xmlHttpRequest['onreadystatechange'];
req.xmlHttpRequest = null;
};
req.onTimeoutInternal =
function() {
if (req!=null && req.xmlHttpRequest!=null && !req.onCompleteInternalHandled) {
req.aborted = true;
req.xmlHttpRequest.abort();
AjaxRequest.numActiveAjaxRequests--;
if (AjaxRequest.numActiveAjaxRequests==0 && typeof(window['AjaxRequestEnd'])=="function") {
AjaxRequestEnd(req.groupName);
}
if (req.groupName!=null) {
AjaxRequest.numActiveAjaxGroupRequests[req.groupName]--;
if (AjaxRequest.numActiveAjaxGroupRequests[req.groupName]==0 && typeof(req.onGroupEnd)=="function") {
req.onGroupEnd(req.groupName);
}
}
if (typeof(req.onTimeout)=="function") {
req.onTimeout(req);
}
// Opera won't fire onreadystatechange after abort, but other browsers do.
// So we can't rely on the onreadystate function getting called. Clean up here!
delete req.xmlHttpRequest['onreadystatechange'];
req.xmlHttpRequest = null;
}
};
 
// ----------------
// Instance methods
// ----------------
/**
* The process method is called to actually make the request. It builds the
* querystring for GET requests (the content for POST requests), sets the
* appropriate headers if necessary, and calls the
* XMLHttpRequest.send() method
*/
req.process =
function() {
if (req.xmlHttpRequest!=null) {
// Some logic to get the real request URL
if (req.generateUniqueUrl && req.method=="GET") {
req.parameters["AjaxRequestUniqueId"] = new Date().getTime() + "" + req.requestIndex;
}
var content = null; // For POST requests, to hold query string
for (var i in req.parameters) {
if (req.queryString.length>0) { req.queryString += "&"; }
req.queryString += encodeURIComponent(i) + "=" + encodeURIComponent(req.parameters[i]);
}
if (req.method=="GET") {
if (req.queryString.length>0) {
req.url += ((req.url.indexOf("?")>-1)?"&":"?") + req.queryString;
}
}
req.xmlHttpRequest.open(req.method,req.url,req.async,req.username,req.password);
if (req.method=="POST") {
if (typeof(req.xmlHttpRequest.setRequestHeader)!="undefined") {
req.xmlHttpRequest.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
}
content = req.queryString;
}
if (req.timeout>0) {
setTimeout(req.onTimeoutInternal,req.timeout);
}
req.xmlHttpRequest.send(content);
}
};
 
/**
* An internal function to handle an Object argument, which may contain
* either AjaxRequest field values or parameter name/values
*/
req.handleArguments =
function(args) {
for (var i in args) {
// If the AjaxRequest object doesn't have a property which was passed, treat it as a url parameter
if (typeof(req[i])=="undefined") {
req.parameters[i] = args[i];
}
else {
req[i] = args[i];
}
}
};
 
/**
* Returns the results of XMLHttpRequest.getAllResponseHeaders().
* Only available after a response has been returned
*/
req.getAllResponseHeaders =
function() {
if (req.xmlHttpRequest!=null) {
if (req.responseReceived) {
return req.xmlHttpRequest.getAllResponseHeaders();
}
alert("Cannot getAllResponseHeaders because a response has not yet been received");
}
};
 
/**
* Returns the the value of a response header as returned by
* XMLHttpRequest,getResponseHeader().
* Only available after a response has been returned
*/
req.getResponseHeader =
function(headerName) {
if (req.xmlHttpRequest!=null) {
if (req.responseReceived) {
return req.xmlHttpRequest.getResponseHeader(headerName);
}
alert("Cannot getResponseHeader because a response has not yet been received");
}
};
 
return req;
}
 
// ---------------------------------------
// Static methods of the AjaxRequest class
// ---------------------------------------
 
/**
* Returns an XMLHttpRequest object, either as a core object or an ActiveX
* implementation. If an object cannot be instantiated, it will return null;
*/
AjaxRequest.getXmlHttpRequest = function() {
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
}
else if (window.ActiveXObject) {
// Based on http://jibbering.com/2002/4/httprequest.html
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
try {
return new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
return null;
}
}
@end @*/
}
else {
return null;
}
};
 
/**
* See if any request is active in the background
*/
AjaxRequest.isActive = function() {
return (AjaxRequest.numActiveAjaxRequests>0);
};
 
/**
* Make a GET request. Pass an object containing parameters and arguments as
* the second argument.
* These areguments may be either AjaxRequest properties to set on the request
* object or name/values to set in the request querystring.
*/
AjaxRequest.get = function(args) {
AjaxRequest.doRequest("GET",args);
};
 
/**
* Make a POST request. Pass an object containing parameters and arguments as
* the second argument.
* These areguments may be either AjaxRequest properties to set on the request
* object or name/values to set in the request querystring.
*/
AjaxRequest.post = function(args) {
AjaxRequest.doRequest("POST",args);
};
 
/**
* The internal method used by the .get() and .post() methods
*/
AjaxRequest.doRequest = function(method,args) {
if (typeof(args)!="undefined" && args!=null) {
var myRequest = new AjaxRequest();
myRequest.method = method;
myRequest.handleArguments(args);
myRequest.process();
}
} ;
 
/**
* Submit a form. The requested URL will be the form's ACTION, and the request
* method will be the form's METHOD.
* Returns true if the submittal was handled successfully, else false so it
* can easily be used with an onSubmit event for a form, and fallback to
* submitting the form normally.
*/
AjaxRequest.submit = function(theform, args) {
var myRequest = new AjaxRequest();
if (myRequest==null) { return false; }
var serializedForm = AjaxRequest.serializeForm(theform);
myRequest.method = theform.method.toUpperCase();
myRequest.url = theform.action;
myRequest.handleArguments(args);
myRequest.queryString = serializedForm;
myRequest.process();
return true;
};
 
/**
* Serialize a form into a format which can be sent as a GET string or a POST
* content.It correctly ignores disabled fields, maintains order of the fields
* as in the elements[] array. The 'file' input type is not supported, as
* its content is not available to javascript. This method is used internally
* by the submit class method.
*/
AjaxRequest.serializeForm = function(theform) {
var els = theform.elements;
var len = els.length;
var queryString = "";
this.addField =
function(name,value) {
if (queryString.length>0) {
queryString += "&";
}
queryString += encodeURIComponent(name) + "=" + encodeURIComponent(value);
};
for (var i=0; i<len; i++) {
var el = els[i];
if (!el.disabled) {
switch(el.type) {
case 'text': case 'password': case 'hidden': case 'textarea':
this.addField(el.name,el.value);
break;
case 'select-one':
if (el.selectedIndex>=0) {
this.addField(el.name,el.options[el.selectedIndex].value);
}
break;
case 'select-multiple':
for (var j=0; j<el.options.length; j++) {
if (el.options[j].selected) {
this.addField(el.name,el.options[j].value);
}
}
break;
case 'checkbox': case 'radio':
if (el.checked) {
this.addField(el.name,el.value);
}
break;
}
}
}
return queryString;
};
 
// -----------------------
// Static Class variables
// -----------------------
 
/**
* The number of total AjaxRequest objects currently active and running
*/
AjaxRequest.numActiveAjaxRequests = 0;
 
/**
* An object holding the number of active requests for each group
*/
AjaxRequest.numActiveAjaxGroupRequests = new Object();
 
/**
* The total number of AjaxRequest objects instantiated
*/
AjaxRequest.numAjaxRequests = 0;
 
var BrowserDetect = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent)
|| this.searchVersion(navigator.appVersion)
|| "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
},
searchString: function (data) {
for (var i=0;i<data.length;i++) {
var dataString = data[i].string;
var dataProp = data[i].prop;
this.versionSearchString = data[i].versionSearch || data[i].identity;
if (dataString) {
if (dataString.indexOf(data[i].subString) != -1)
return data[i].identity;
}
else if (dataProp)
return data[i].identity;
}
},
searchVersion: function (dataString) {
var index = dataString.indexOf(this.versionSearchString);
if (index == -1) return;
return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
},
dataBrowser: [
{
string: navigator.userAgent,
subString: "Chrome",
identity: "Chrome"
},
{ string: navigator.userAgent,
subString: "OmniWeb",
versionSearch: "OmniWeb/",
identity: "OmniWeb"
},
{
string: navigator.vendor,
subString: "Apple",
identity: "Safari",
versionSearch: "Version"
},
{
prop: window.opera,
identity: "Opera"
},
{
string: navigator.vendor,
subString: "iCab",
identity: "iCab"
},
{
string: navigator.vendor,
subString: "KDE",
identity: "Konqueror"
},
{
string: navigator.userAgent,
subString: "Firefox",
identity: "Firefox"
},
{
string: navigator.vendor,
subString: "Camino",
identity: "Camino"
},
{ // for newer Netscapes (6+)
string: navigator.userAgent,
subString: "Netscape",
identity: "Netscape"
},
{
string: navigator.userAgent,
subString: "MSIE",
identity: "Explorer",
versionSearch: "MSIE"
},
{
string: navigator.userAgent,
subString: "Gecko",
identity: "Mozilla",
versionSearch: "rv"
},
{ // for older Netscapes (4-)
string: navigator.userAgent,
subString: "Mozilla",
identity: "Netscape",
versionSearch: "Mozilla"
}
],
dataOS : [
{
string: navigator.platform,
subString: "Win",
identity: "Windows"
},
{
string: navigator.platform,
subString: "Mac",
identity: "Mac"
},
{
string: navigator.userAgent,
subString: "iPhone",
identity: "iPhone/iPod"
},
{
string: navigator.platform,
subString: "Linux",
identity: "Linux"
}
]
};
BrowserDetect.init();
// Cookie Toolbox Javascript
// // copyright 4th September 2002, by Stephen Chapman, Felgall Pty Ltd
//
// // You have permission to copy and use this javascript provided that
// // the content of the script is not changed in any way.
// // For instructions on how to use these functions see "A Cookie Toolbox"
// // in the Javascript section of our site at http://www.felgall.com/
//
// var dbug = 0; function d_a(ary) {var beg = next_entry(ary) - 1; for (var i = beg ; i > -1; i--) {ary[i] = null;}} function init_array() {if (dbug) alert('init_cookie'); var ary = new Array(null); return ary;} function set_cookie(name,value,expires) {if (dbug) alert('set_cookie'); if (!expires) expires = new Date();
// document.cookie = name + '=' + escape(value) + '; expires=' + expires.toGMTString() + '; path=/';} function get_cookie(name) {if (dbug) alert('get_cookie'); var dcookie = document.cookie; var cname = name + "="; var clen = dcookie.length; var cbegin = 0; while (cbegin < clen) {var vbegin = cbegin + cname.length;
// if (dcookie.substring(cbegin, vbegin) == cname) {var vend = dcookie.indexOf (";", vbegin); if (vend == -1) vend = clen; return unescape(dcookie.substring(vbegin, vend));} cbegin = dcookie.indexOf(" ", cbegin) + 1; if (cbegin == 0) break;} return null;} function del_cookie(name) {if (dbug) alert('del_cookie');
// document.cookie = name + '=' + '; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/';} function get_array(name, ary) {if (dbug) alert('get_array'); d_a(ary); var ent = get_cookie(name); if (ent) {i = 1; while (ent.indexOf('^') != '-1') {ary[i] = ent.substring(0,ent.indexOf('^')); i++;
// ent = ent.substring(ent.indexOf('^')+1, ent.length);}}} function set_array(name, ary, expires) {if (dbug) alert('set_array'); var value = ''; for (var i = 1; ary[i]; i++) {value += ary[i] + '^';} set_cookie(name, value, expires);} function del_entry(name, ary, pos, expires) {if (dbug) alert('del_entry');
// var value = ''; get_array(name, ary); for (var i = 1; i < pos; i++) {value += ary[i] + '^';} for (var j = pos + 1; ary[j]; j++) {value += ary[j] + '^';} set_cookie(name, value, expires);} function next_entry(ary) {if (dbug) alert('next_entry'); var j = 0; for (var i = 1; ary[i]; i++) {j = i} return j + 1;}
// function debug_on() {dbug = 1;} function debug_off() {dbug = 0;} function dump_cookies() {if (document.cookie == '') document.write('No Cookies Found'); else {thisCookie = document.cookie.split('; '); for (i=0; i<thisCookie.length; i++) {document.write(thisCookie[i] + '<br \/>');}}}
/**
Written by Peter Wilkinson of http://dynamic-tools.net
Feel free to use or modify this script for any purpose. I'd appreciate you leaving
this header in though.
*/
function addEvent(elem, eventType, handler)
{
if (!elem.eventHandlers) elem.eventHandlers = [];
if (!elem.eventHandlers[eventType])
{
elem.eventHandlers[eventType] = [];
if (elem['on' + eventType]) elem.eventHandlers[eventType].push(elem['on' + eventType]);
elem['on' + eventType] = handleEvent;
}
elem.eventHandlers[eventType].push(handler);
}
 
function removeEvent(elem, eventType, handler)
{
var handlers = elem.eventHandlers[eventType];
for (var i in handlers) if (handlers[i] == handler) delete handlers[i];
}
 
function handleEvent(e)
{
var returnValue = true;
if (!e) e = fixEvent(event);
var handlers = this.eventHandlers[e.type]
for (var i in handlers)
{
this.$$handleEvent = handlers[i];
returnValue = !((returnValue && this.$$handleEvent(e)) === false);
}
return returnValue;
}
 
function fixEvent(e)
{
// add W3C standard event methods
e.preventDefault = fixEvent.preventDefault;
e.stopPropagation = fixEvent.stopPropagation;
return event;
};
 
fixEvent.preventDefault = function() {
this.returnValue = false;
};
 
fixEvent.stopPropagation = function() {
this.cancelBubble = true;
}; /*!
jsAnim: Powerful javascript animation
--------------------------------------------
Copyright 2009 Kevin Dolan
-http://www.thekevindolan.com
Code licensed under the MIT license
-See license.txt
v0.2
*/
 
//These vars are used to hold all jsAnimManagers
var jsAnimManagers = new Array();
var jsAnimManagerId = 0;
 
/*! public, accessible
jsAnimManager object constructor
Used by end-user to manage jsAnim objects
Params:
-[timestep] : time between frames, defaults to 40
*/
function jsAnimManager(timestep) {
 
jsAnimManagers[jsAnimManagerId] = this;
this.myId = jsAnimManagerId;
jsAnimManagerId++;
 
if(timestep)
this.timestep = timestep;
else
this.timestep = 40;
this.paused = false;
this.animObjects = new Array();
this.index = 0;
//Used internally to process a single frame of all active animations
this.step = function() {
if(!this.paused) {
for(x in this.animObjects) {
this.animObjects[x].step();
}
setTimeout("jsAnimManagers["+this.myId+"].step()",this.timestep);
}
};
//Used internally to kill a jsAnimObject
this.kill = function(id) {
delete this.animObjects[id];
};
/*! public
Called to create a new animation object
Params:
-objId : id of object being controlled
*/
this.createAnimObject = function(objId) {
var el = document.getElementById(objId);
var id = this.index;
this.animObjects[id] = new jsAnimObject(el, id, this);
this.index++;
return this.animObjects[id];
};
/*! public
Called to pause the animation manager
*/
this.pause = function() {
this.paused = true;
};
/*! public
Called to unpause the animation manager
*/
this.resume = function() {
this.paused = false;
this.step();
};
/*! public
Called to set the appropriate style values to allow position to be controlled by jsAnim
Params:
-objId : id of object to be registered
-[fixed] : fixed positioning, false to absolute fixed, defaults to false
*/
this.registerPosition = function(objId, fixed) {
var el = document.getElementById(objId);
var width = el.offsetWidth;
var height = el.offsetHeight;
if(fixed)
el.style.position = "fixed";
else
el.style.position = "absolute";
el.style.top = "0px";
el.style.left = "50%";
el.halfWidth = Math.floor(width/2);
el.halfHeight = Math.floor(height/2);
el.style.marginLeft = (-el.halfWidth)+"px";
el.style.marginTop = (-el.halfHeight)+"px";
el.positionRegistered = true;
/*! public
Called to manually set the position of this object
*/
el.setPosition = function(x, y) {
this.style.marginLeft = (x - this.halfWidth)+"px";
this.style.marginTop = (y - this.halfHeight)+"px";
};
};
this.step();
return true;
}
 
/*! accesible
jsAnimObject object constructor
Used internally to hold the state of a single animation manager
Params:
-obj : object being animated
*/
function jsAnimObject(obj, id, manager) {
this.id = id;
this.obj = obj;
this.paused = false;
this.animEntries = new Array();
this.animLoops = new Array();
this.current = 0;
this.manager = manager;
this.step = function() {
if(!this.paused) {
//Ugly code to get only the first element in the array
for(x in this.animEntries) {
var finished = this.animEntries[x].step();
if(finished) {
this.animLoops[x]--;
this.animEntries[x].current = 0;
this.animEntries[x].onLoop();
}
if(this.animLoops[x] == 0) {
this.animEntries[x].onComplete();
delete this.animEntries[x];
}
break;
}
}
};
/*! public
Called to add an animation to the chain
Params:
-params : a collection in the containing the following elements
- property : the Prop object to animate
- [from] : optional from value, if unspecified current value is used
- to : the value to animate to
- duration : the length of time this animation should take
- [ease] : the jsAnimEase object to use, if unspecified linear will be used
- [loop] : the number of times to loop the animation, negative values are infinite, if unspecified 1 will be used
- [onLoop] : the callback function for loop completion
- [onComplete] : the callback function for animation completion
*/
this.add = function(params) {
var property = params.property;
var from = params.from
var to = params.to;
var duration = params.duration;
if(params.ease)
var ease = params.ease;
else
var ease = jsAnimEase.linear;
if(params.loop)
var loop = params.loop;
else
var loop = 1;
if(params.onLoop)
var onLoop = params.onLoop;
else
var onLoop = function() {};
if(params.onComplete)
var onComplete = params.onComplete;
else
var onComplete = function() {};
this.animEntries[this.current] = new jsAnimEntry(this.obj, property, from, to, duration, this.manager.timestep, ease, onLoop, onComplete);
this.animLoops[this.current] = loop;
this.current++;
};
/*! public
Called to skip the current animation, can be used to exit an infinite loop
*/
this.skip = function() {
//Ugly code to get only the first element in the array
for(x in this.animEntries) {
delete this.animEntries[x];
break;
}
};
/*! public
Called to pause this animator
*/
this.pause = function() {
this.paused = true;
};
/*! public
Called to resum this animator
*/
this.resume = function() {
this.paused = false;
};
/*! public
Called to kill this animator
*/
this.kill = function() {
this.manager.kill(this.id);
};
return true;
}
 
/*! public, accesible
Pos object constructor
Called to store an x and y coordinate representing an object's center
according to the jsAnim coordinate system
Params:
-x : x coordinate, 0 is center, negative is left, positive is right
-y : y coordinate, 0 is top, positive id below
*/
function Pos(x, y) {
//public
this.x = x;
//public
this.y = y;
return true;
}
 
/*! public, accesible
Dim object constructor
Called to store a width/height dimension
Params:
-w : width
-h : height
*/
function Dim(w, h) {
//public
this.w = w;
//public
this.h = h;
return true;
}
 
/*! public, accesible
Col object constructor
Called to store an RGB color
Params:
-r : red value (0,255)
-g : green value (0,255)
-b : blue value (0,255)
*/
function Col(r, g, b) {
//public
this.r = r;
//public
this.g = g;
//public
this.b = b;
return true;
}
 
/*!
jsAnimEntry object constructor
Used internally to hold the state of single animation entry
Params:
-property : jsAnimProp object
-from : initial value
-to : end value
-duration : total time of animation (ms)
-ease : jsAnimEase object
-timestep : the timestep value of the animation manager
-onLoop : called after each loop
-onComplete : called after completion
*/
function jsAnimEntry(obj, property, from, to, duration, timestep, ease, onLoop, onComplete) {
this.obj = obj;
this.property = property;
this.from = from;
this.to = to;
this.duration = duration;
this.timestep = timestep;
this.ease = ease;
this.current = 0;
this.onLoop = onLoop;
this.onComplete = onComplete;
/*!
Used internally to move the object one step
Returns : true if this anim entry has completed, false otherwise
*/
this.step = function() {
if(!this.from)
this.from = this.property.current(this.obj);
if(this.current >= this.duration) {
var p = this.ease.transform(1);
this.property.update(this.obj, this.from, this.to, p);
return true;
}
else {
var t = this.current / this.duration;
var p = this.ease.transform(t);
this.property.update(this.obj, this.from, this.to, p);
this.current += this.timestep;
return false;
}
};
return true;
}
 
/*! public
jsAnimEase objects
Used to control easing
Methods:
transform : Transform a number 0-1 representing a time proportion
to a new number 0-1 representing a progress proportion
*/
var jsAnimEase = {
/*!public
Constant Rate
*/
linear : {
transform : function(t) {
return t;
}
},
/*!public
Starts slow, then speeds up
*/
parabolicPos : {
transform : function(t) {
return t * t;
}
},
/*!public
Starts fast, then slows down
*/
parabolicNeg : {
transform : function(t) {
return 1 - (t-1) * (t-1);
}
},
/*!public
Overshoots target then returns to target
Params:
-g : overshoot amount [0-1]
*/
backout : function(g) {
return {
transform : function(t) {
return (-1 * t * (t + g - 2)) / (1 - g);
}
};
},
/*!public
Backs up a bit then moves to target
Params:
-g : backup amount [0-1]
*/
backin : function(g) {
return {
transform : function(t) {
return 1 + ((t+1-g) * ((t+1-g) + g - 2)) / (1 - g);
}
};
},
/*!public
Goes to target and then back at constant rate
*/
bounceLinear : {
transform : function(t) {
if(t < 0.5)
return 2 * t;
else
return 1 - 2 * (t - 0.5)
}
},
/*!public
Goes to target and then back at variable rate
*/
bounceParabolic : {
transform : function(t) {
return -4 * t * (t-1);
}
},
/*!public
Goes to target and then back smoothly
*/
bounceSmooth : {
transform : function(t) {
return 0.5 - 0.5 * Math.cos(2 * Math.PI * t);
}
}
}
 
/*!
Utility objects for internal use
*/
var jsAnimUtil = {
 
interp : function (v1, v2, percent) {
if(isNaN(v1))
v1 = 0;
if(isNaN(v2))
v2 = 0;
var v = v1 + percent * (v2-v1);
return Math.floor(v);
},
getCSS : function (elem, field) {
var css = document.defaultView && document.defaultView.getComputedStyle ?
document.defaultView.getComputedStyle(elem, null)
: elem.currentStyle || elem.style;
return css[field];
},
explode : function ( delimiter, string, limit ) {
// http://kevin.vanzonneveld.net
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + improved by: kenneth
// + improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// + improved by: d3x
// + bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
// * example 1: explode(' ', 'Kevin van Zonneveld');
// * returns 1: {0: 'Kevin', 1: 'van', 2: 'Zonneveld'}
// * example 2: explode('=', 'a=bc=d', 2);
// * returns 2: ['a', 'bc=d']
var emptyArray = { 0: '' };
// third argument is not required
if ( arguments.length < 2 ||
typeof arguments[0] == 'undefined' ||
typeof arguments[1] == 'undefined' )
{
return null;
}
if ( delimiter === '' ||
delimiter === false ||
delimiter === null )
{
return false;
}
if ( typeof delimiter == 'function' ||
typeof delimiter == 'object' ||
typeof string == 'function' ||
typeof string == 'object' )
{
return emptyArray;
}
if ( delimiter === true ) {
delimiter = '1';
}
if (!limit) {
return string.toString().split(delimiter.toString());
} else {
// support for limit argument
var splitted = string.toString().split(delimiter.toString());
var partA = splitted.splice(0, limit - 1);
var partB = splitted.join(delimiter.toString());
partA.push(partB);
return partA;
}
}
}
 
/*! public
Prop objects
Used to keep track of which property is being controlled
Methods:
update : update the property to where it should be at the given time
current : return a natural representation of the current property
*/
var Prop = {
/*! public
Wait, while doing no animating
*/
wait : {
update : function(obj, from, to, percent) {},
current : function(obj) {return 0;}
},
 
/*! public
Follows a linear path
*/
position : {
update : function(obj, from, to, percent) {
var x = jsAnimUtil.interp(from.x, to.x, percent);
var y = jsAnimUtil.interp(from.y, to.y, percent);
obj.setPosition(x, y);
},
current : function(obj) {
var left = parseInt(obj.style.marginLeft);
var top = parseInt(obj.style.marginTop);
var x = left + obj.halfWidth;
var y = top + obj.halfHeight;
return new Pos(x,y);
}
},
/*! public
Follows a semicircular path
Params:
-clockwise : True for clockwise, false otherwise
*/
positionSemicircle : function(clockwise) {
return {
update : function(obj, from, to, percent) {
var centerX = (from.x + to.x) / 2;
var centerY = (from.y + to.y) / 2;
var h = centerY - from.y;
var w = from.x - centerX;
var dist = Math.sqrt(h * h + w * w);
if(w == 0) {
if(h > 0)
var initAngle = - Math.PI / 2;
else
var initAngle = Math.PI / 2;
}
else {
var atan = Math.atan(h / Math.abs(w));
if(w > 0)
var initAngle = atan;
else {
var initAngle = Math.PI - atan;
}
}
if(clockwise)
var addAngle = - percent * Math.PI;
else
var addAngle = percent * Math.PI;
var angle = initAngle + addAngle;
var x = Math.floor(centerX + dist * Math.cos(angle));
var y = Math.floor(centerY - dist * Math.sin(angle));
obj.setPosition(x, y);
},
current : function(obj) {
var left = parseInt(obj.style.marginLeft);
var top = parseInt(obj.style.marginTop);
var x = left + obj.halfWidth;
var y = top + obj.halfHeight;
return new Pos(x,y);
}
}
},
/*! public
Follows a circular path through target then back to start
Params:
-clockwise : True for clockwise, false otherwise
*/
positionCircle : function(clockwise) {
return {
update : function(obj, from, to, percent) {
var centerX = (from.x + to.x) / 2;
var centerY = (from.y + to.y) / 2;
var h = centerY - from.y;
var w = from.x - centerX;
var dist = Math.sqrt(h * h + w * w);
if(w == 0) {
if(h > 0)
var initAngle = - Math.PI / 2;
else
var initAngle = Math.PI / 2;
}
else {
var atan = Math.atan(h / Math.abs(w));
if(w > 0)
var initAngle = atan;
else {
var initAngle = Math.PI - atan;
}
}
if(clockwise)
var addAngle = 2 * percent * Math.PI;
else
var addAngle = -2 * percent * Math.PI;
var angle = initAngle + addAngle;
var x = Math.floor(centerX + dist * Math.cos(angle));
var y = Math.floor(centerY + dist * Math.sin(angle));
obj.setPosition(x, y);
},
current : function(obj) {
var left = parseInt(obj.style.marginLeft);
var top = parseInt(obj.style.marginTop);
var x = left + obj.halfWidth;
var y = top + obj.halfHeight;
return new Pos(x,y);
}
}
},
//public
top : {
update : function(obj, from, to, percent) {
obj.style.top = jsAnimUtil.interp(from, to, percent) + "px";
},
current : function(obj) {
return parseInt(jsAnimUtil.getCSS(obj, 'top'));
}
},
//public
right : {
update : function(obj, from, to, percent) {
obj.style.right = jsAnimUtil.interp(from, to, percent) + "px";
},
current : function(obj) {
return parseInt(jsAnimUtil.getCSS(obj, 'right'));
}
},
//public
bottom : {
update : function(obj, from, to, percent) {
obj.style.bottom = jsAnimUtil.interp(from, to, percent) + "px";
},
current : function(obj) {
return parseInt(jsAnimUtil.getCSS(obj, 'bottom'));
}
},
//public
left : {
update : function(obj, from, to, percent) {
obj.style.left = jsAnimUtil.interp(from, to, percent) + "px";
},
current : function(obj) {
return parseInt(jsAnimUtil.getCSS(obj, 'left'));
}
},
//public
margin : {
update : function(obj, from, to, percent) {
obj.style.margin = jsAnimUtil.interp(from, to, percent) + "px";
},
current : function(obj) {
return parseInt(jsAnimUtil.getCSS(obj, 'margin'));
}
},
//public
marginTop : {
update : function(obj, from, to, percent) {
obj.style.marginTop = jsAnimUtil.interp(from, to, percent) + "px";
},
current : function(obj) {
return parseInt(jsAnimUtil.getCSS(obj, 'marginTop'));
}
},
//public
marginRight : {
update : function(obj, from, to, percent) {
obj.style.marginRight = jsAnimUtil.interp(from, to, percent) + "px";
},
current : function(obj) {
return parseInt(jsAnimUtil.getCSS(obj, 'marginRight'));
}
},
//public
marginBottom : {
update : function(obj, from, to, percent) {
obj.style.marginBottom = jsAnimUtil.interp(from, to, percent) + "px";
},
current : function(obj) {
return parseInt(jsAnimUtil.getCSS(obj, 'marginBottom'));
}
},
//public
marginLeft : {
update : function(obj, from, to, percent) {
obj.style.marginLeft = jsAnimUtil.interp(from, to, percent) + "px";
},
current : function(obj) {
return parseInt(jsAnimUtil.getCSS(obj, 'marginLeft'));
}
},
//public
padding : {
update : function(obj, from, to, percent) {
obj.style.padding = jsAnimUtil.interp(from, to, percent) + "px";
},
current : function(obj) {
return parseInt(jsAnimUtil.getCSS(obj, 'padding'));
}
},
//public
paddingTop : {
update : function(obj, from, to, percent) {
obj.style.paddingTop = jsAnimUtil.interp(from, to, percent) + "px";
},
current : function(obj) {
return parseInt(jsAnimUtil.getCSS(obj, 'paddingTop'));
}
},
//public
paddingRight : {
update : function(obj, from, to, percent) {
obj.style.paddingRight = jsAnimUtil.interp(from, to, percent) + "px";
},
current : function(obj) {
return parseInt(jsAnimUtil.getCSS(obj, 'paddingRight'));
}
},
//public
paddingBottom : {
update : function(obj, from, to, percent) {
obj.style.paddingBottom = jsAnimUtil.interp(from, to, percent) + "px";
},
current : function(obj) {
return parseInt(jsAnimUtil.getCSS(obj, 'paddingBottom'));
}
},
//public
paddingLeft : {
update : function(obj, from, to, percent) {
obj.style.paddingLeft = jsAnimUtil.interp(from, to, percent) + "px";
},
current : function(obj) {
return parseInt(jsAnimUtil.getCSS(obj, 'paddingLeft'));
}
},
//public
borderWidth : {
update : function(obj, from, to, percent) {
obj.style.borderWidth = jsAnimUtil.interp(from, to, percent) + "px";
},
current : function(obj) {
return parseInt(jsAnimUtil.getCSS(obj, 'borderWidth'));
}
},
//public
borderTopWidth : {
update : function(obj, from, to, percent) {
obj.style.borderTopWidth = jsAnimUtil.interp(from, to, percent) + "px";
},
current : function(obj) {
return parseInt(jsAnimUtil.getCSS(obj, 'borderTopWidth'));
}
},
//public
borderRightWidth : {
update : function(obj, from, to, percent) {
obj.style.borderRightWidth = jsAnimUtil.interp(from, to, percent) + "px";
},
current : function(obj) {
return parseInt(jsAnimUtil.getCSS(obj, 'borderRightWidth'));
}
},
//public
borderBottomWidth : {
update : function(obj, from, to, percent) {
obj.style.borderBottomWidth = jsAnimUtil.interp(from, to, percent) + "px";
},
current : function(obj) {
return parseInt(jsAnimUtil.getCSS(obj, 'borderBottomWidth'));
}
},
//public
borderLeftWidth : {
update : function(obj, from, to, percent) {
obj.style.borderLeftWidth = jsAnimUtil.interp(from, to, percent) + "px";
},
current : function(obj) {
return parseInt(jsAnimUtil.getCSS(obj, 'borderLeftWidth'));
}
},
//public
fontSize : {
update : function(obj, from, to, percent) {
obj.style.fontSize = jsAnimUtil.interp(from, to, percent) + "pt";
},
current : function(obj) {
return parseInt(jsAnimUtil.getCSS(obj, 'fontSize'));
}
},
//public
height : {
update : function(obj, from, to, percent) {
var v = jsAnimUtil.interp(from, to, percent);
obj.style.height = v + "px";
//Update the position if registered
if(obj.positionRegistered) {
var y = parseInt(obj.style.marginTop) + obj.halfHeight;
obj.halfHeight = Math.floor(obj.offsetHeight/2);
obj.style.marginTop = y - obj.halfHeight + "px";
}
},
current : function(obj) {
var ht = jsAnimUtil.getCSS(obj, 'height');
if(ht == "auto")
return obj.offsetHeight;
else
return parseInt(ht);
}
},
//public
width : {
update : function(obj, from, to, percent) {
var v = jsAnimUtil.interp(from, to, percent);
obj.style.width = v + "px";
//Update the position if registered
if(obj.positionRegistered) {
var x = parseInt(obj.style.marginLeft) + obj.halfWidth;
obj.halfWidth = Math.floor(obj.offsetWidth/2);
obj.style.marginLeft = x - obj.halfWidth + "px";
}
},
current : function(obj) {
return parseInt(jsAnimUtil.getCSS(obj, 'width'));
}
},
//public
dimension : {
update : function(obj, from, to, percent) {
var h = jsAnimUtil.interp(from.h, to.h, percent);
var w = jsAnimUtil.interp(from.w, to.w, percent);
obj.style.height = h + "px";
obj.style.width = w + "px";
//Update the position if registered
if(obj.positionRegistered) {
var y = parseInt(obj.style.marginTop) + obj.halfHeight;
obj.halfHeight = Math.floor(obj.offsetHeight/2);
obj.style.marginTop = (y - obj.halfHeight) + "px";
var x = parseInt(obj.style.marginLeft) + obj.halfWidth;
obj.halfWidth = Math.floor(obj.offsetWidth/2);
obj.style.marginLeft = (x - obj.halfWidth) + "px";
}
},
current : function(obj) {
var ht = jsAnimUtil.getCSS(obj, 'height');
if(ht == "auto")
var h = obj.offsetHeight;
else
var h = parseInt(ht);
var w = parseInt(jsAnimUtil.getCSS(obj, 'width'));
return new Dim(w, h);
}
},
//public
color : {
update : function(obj, from, to, percent) {
r = jsAnimUtil.interp(from.r, to.r, percent);
g = jsAnimUtil.interp(from.g, to.g, percent);
b = jsAnimUtil.interp(from.b, to.b, percent);
obj.style.color = "rgb("+r+","+g+","+b+")";
},
current : function(obj) {
var color = jsAnimUtil.getCSS(obj, 'color');
color = color.substring(4,color.length-1);
var rgb = jsAnimUtil.explode(",",color);
return new Col(parseInt(rgb[0]), parseInt(rgb[1]), parseInt(rgb[2]));
}
},
//public
backgroundColor : {
update : function(obj, from, to, percent) {
r = jsAnimUtil.interp(from.r, to.r, percent);
g = jsAnimUtil.interp(from.g, to.g, percent);
b = jsAnimUtil.interp(from.b, to.b, percent);
 
obj.style.backgroundColor = "rgb("+r+","+g+","+b+")";
},
current : function(obj) {
var color = jsAnimUtil.getCSS(obj, 'backgroundColor');
color = color.substring(4,color.length-1);
var rgb = jsAnimUtil.explode(",",color);
return new Col(parseInt(rgb[0]), parseInt(rgb[1]), parseInt(rgb[2]));
}
},
//public
borderColor : {
update : function(obj, from, to, percent) {
r = jsAnimUtil.interp(from.r, to.r, percent);
g = jsAnimUtil.interp(from.g, to.g, percent);
b = jsAnimUtil.interp(from.b, to.b, percent);
obj.style.borderColor = "rgb("+r+","+g+","+b+")";
},
current : function(obj) {
var color = jsAnimUtil.getCSS(obj, 'borderColor');
color = color.substring(4,color.length-1);
var rgb = jsAnimUtil.explode(",",color);
return new Col(parseInt(rgb[0]), parseInt(rgb[1]), parseInt(rgb[2]));
}
},
//public
opacity : {
update : function(obj, from, to, percent) {
v = jsAnimUtil.interp(100*from, 100*to, percent);
obj.style.opacity = v / 100;
},
current : function(obj) {
return jsAnimUtil.getCSS(obj, 'opacity');
}
}
}/*
http://www.JSON.org/json2.js
2011-02-23
Public Domain.
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
See http://www.JSON.org/js.html
This code should be minified before deployment.
See http://javascript.crockford.com/jsmin.html
USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
NOT CONTROL.
This file creates a global JSON object containing two methods: stringify
and parse.
JSON.stringify(value, replacer, space)
value any JavaScript value, usually an object or array.
replacer an optional parameter that determines how object
values are stringified for objects. It can be a
function or an array of strings.
space an optional parameter that specifies the indentation
of nested structures. If it is omitted, the text will
be packed without extra whitespace. If it is a number,
it will specify the number of spaces to indent at each
level. If it is a string (such as '\t' or '&nbsp;'),
it contains the characters used to indent at each level.
This method produces a JSON text from a JavaScript value.
When an object value is found, if the object contains a toJSON
method, its toJSON method will be called and the result will be
stringified. A toJSON method does not serialize: it returns the
value represented by the name/value pair that should be serialized,
or undefined if nothing should be serialized. The toJSON method
will be passed the key associated with the value, and this will be
bound to the value
For example, this would serialize Dates as ISO strings.
Date.prototype.toJSON = function (key) {
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
return this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z';
};
You can provide an optional replacer method. It will be passed the
key and value of each member, with this bound to the containing
object. The value that is returned from your method will be
serialized. If your method returns undefined, then the member will
be excluded from the serialization.
If the replacer parameter is an array of strings, then it will be
used to select the members to be serialized. It filters the results
such that only members with keys listed in the replacer array are
stringified.
Values that do not have JSON representations, such as undefined or
functions, will not be serialized. Such values in objects will be
dropped; in arrays they will be replaced with null. You can use
a replacer function to replace those with JSON values.
JSON.stringify(undefined) returns undefined.
The optional space parameter produces a stringification of the
value that is filled with line breaks and indentation to make it
easier to read.
If the space parameter is a non-empty string, then that string will
be used for indentation. If the space parameter is a number, then
the indentation will be that many spaces.
Example:
text = JSON.stringify(['e', {pluribus: 'unum'}]);
// text is '["e",{"pluribus":"unum"}]'
text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
// text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
text = JSON.stringify([new Date()], function (key, value) {
return this[key] instanceof Date ?
'Date(' + this[key] + ')' : value;
});
// text is '["Date(---current time---)"]'
JSON.parse(text, reviver)
This method parses a JSON text to produce an object or array.
It can throw a SyntaxError exception.
The optional reviver parameter is a function that can filter and
transform the results. It receives each of the keys and values,
and its return value is used instead of the original value.
If it returns what it received, then the structure is not modified.
If it returns undefined then the member is deleted.
Example:
// Parse the text. Values that look like ISO date strings will
// be converted to Date objects.
myData = JSON.parse(text, function (key, value) {
var a;
if (typeof value === 'string') {
a =
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
if (a) {
return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+a[5], +a[6]));
}
}
return value;
});
myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
var d;
if (typeof value === 'string' &&
value.slice(0, 5) === 'Date(' &&
value.slice(-1) === ')') {
d = new Date(value.slice(5, -1));
if (d) {
return d;
}
}
return value;
});
This is a reference implementation. You are free to copy, modify, or
redistribute.
*/
 
/*jslint evil: true, strict: false, regexp: false */
 
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
lastIndex, length, parse, prototype, push, replace, slice, stringify,
test, toJSON, toString, valueOf
*/
 
 
// Create a JSON object only if one does not already exist. We create the
// methods in a closure to avoid creating global variables.
 
var JSON;
if (!JSON) {
JSON = {};
}
 
(function () {
"use strict";
 
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
 
if (typeof Date.prototype.toJSON !== 'function') {
 
Date.prototype.toJSON = function (key) {
 
return isFinite(this.valueOf()) ?
this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z' : null;
};
 
String.prototype.toJSON =
Number.prototype.toJSON =
Boolean.prototype.toJSON = function (key) {
return this.valueOf();
};
}
 
var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
gap,
indent,
meta = { // table of character substitutions
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"' : '\\"',
'\\': '\\\\'
},
rep;
 
 
function quote(string) {
 
// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.
 
escapable.lastIndex = 0;
return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
var c = meta[a];
return typeof c === 'string' ? c :
'\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
}) + '"' : '"' + string + '"';
}
 
 
function str(key, holder) {
 
// Produce a string from holder[key].
 
var i, // The loop counter.
k, // The member key.
v, // The member value.
length,
mind = gap,
partial,
value = holder[key];
 
// If the value has a toJSON method, call it to obtain a replacement value.
 
if (value && typeof value === 'object' &&
typeof value.toJSON === 'function') {
value = value.toJSON(key);
}
 
// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.
 
if (typeof rep === 'function') {
value = rep.call(holder, key, value);
}
 
// What happens next depends on the value's type.
 
switch (typeof value) {
case 'string':
return quote(value);
 
case 'number':
 
// JSON numbers must be finite. Encode non-finite numbers as null.
 
return isFinite(value) ? String(value) : 'null';
 
case 'boolean':
case 'null':
 
// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce 'null'. The case is included here in
// the remote chance that this gets fixed someday.
 
return String(value);
 
// If the type is 'object', we might be dealing with an object or an array or
// null.
 
case 'object':
 
// Due to a specification blunder in ECMAScript, typeof null is 'object',
// so watch out for that case.
 
if (!value) {
return 'null';
}
 
// Make an array to hold the partial results of stringifying this object value.
 
gap += indent;
partial = [];
 
// Is the value an array?
 
if (Object.prototype.toString.apply(value) === '[object Array]') {
 
// The value is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.
 
length = value.length;
for (i = 0; i < length; i += 1) {
partial[i] = str(i, value) || 'null';
}
 
// Join all of the elements together, separated with commas, and wrap them in
// brackets.
 
v = partial.length === 0 ? '[]' : gap ?
'[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
'[' + partial.join(',') + ']';
gap = mind;
return v;
}
 
// If the replacer is an array, use it to select the members to be stringified.
 
if (rep && typeof rep === 'object') {
length = rep.length;
for (i = 0; i < length; i += 1) {
if (typeof rep[i] === 'string') {
k = rep[i];
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
} else {
 
// Otherwise, iterate through all of the keys in the object.
 
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
}
 
// Join all of the member texts together, separated with commas,
// and wrap them in braces.
 
v = partial.length === 0 ? '{}' : gap ?
'{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
'{' + partial.join(',') + '}';
gap = mind;
return v;
}
}
 
// If the JSON object does not yet have a stringify method, give it one.
 
if (typeof JSON.stringify !== 'function') {
JSON.stringify = function (value, replacer, space) {
 
// The stringify method takes a value and an optional replacer, and an optional
// space parameter, and returns a JSON text. The replacer can be a function
// that can replace values, or an array of strings that will select the keys.
// A default replacer method can be provided. Use of the space parameter can
// produce text that is more easily readable.
 
var i;
gap = '';
indent = '';
 
// If the space parameter is a number, make an indent string containing that
// many spaces.
 
if (typeof space === 'number') {
for (i = 0; i < space; i += 1) {
indent += ' ';
}
 
// If the space parameter is a string, it will be used as the indent string.
 
} else if (typeof space === 'string') {
indent = space;
}
 
// If there is a replacer, it must be a function or an array.
// Otherwise, throw an error.
 
rep = replacer;
if (replacer && typeof replacer !== 'function' &&
(typeof replacer !== 'object' ||
typeof replacer.length !== 'number')) {
throw new Error('JSON.stringify');
}
 
// Make a fake root object containing our value under the key of ''.
// Return the result of stringifying the value.
 
return str('', {'': value});
};
}
 
 
// If the JSON object does not yet have a parse method, give it one.
 
if (typeof JSON.parse !== 'function') {
JSON.parse = function (text, reviver) {
 
// The parse method takes a text and an optional reviver function, and returns
// a JavaScript value if the text is a valid JSON text.
 
var j;
 
function walk(holder, key) {
 
// The walk method is used to recursively walk the resulting structure so
// that modifications can be made.
 
var k, v, value = holder[key];
if (value && typeof value === 'object') {
for (k in value) {
if (Object.prototype.hasOwnProperty.call(value, k)) {
v = walk(value, k);
if (v !== undefined) {
value[k] = v;
} else {
delete value[k];
}
}
}
}
return reviver.call(holder, key, value);
}
 
 
// Parsing happens in four stages. In the first stage, we replace certain
// Unicode characters with escape sequences. JavaScript handles many characters
// incorrectly, either silently deleting them, or treating them as line endings.
 
text = String(text);
cx.lastIndex = 0;
if (cx.test(text)) {
text = text.replace(cx, function (a) {
return '\\u' +
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
});
}
 
// In the second stage, we run the text against regular expressions that look
// for non-JSON patterns. We are especially concerned with '()' and 'new'
// because they can cause invocation, and '=' because it can cause mutation.
// But just to be safe, we want to reject all unexpected forms.
 
// We split the second stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
 
if (/^[\],:{}\s]*$/
.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
.replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
 
// In the third stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.
 
j = eval('(' + text + ')');
 
// In the optional fourth stage, we recursively walk the new structure, passing
// each name/value pair to a reviver function for possible transformation.
 
return typeof reviver === 'function' ?
walk({'': j}, '') : j;
}
 
// If the text is not JSON parseable, then a SyntaxError is thrown.
 
throw new SyntaxError('JSON.parse');
};
}
}());
/*!
* Sizzle CSS Selector Engine
* Copyright 2011, The Dojo Foundation
* Released under the MIT, BSD, and GPL Licenses.
* More information: http://sizzlejs.com/
*/
(function(){
 
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
done = 0,
toString = Object.prototype.toString,
hasDuplicate = false,
baseHasDuplicate = true,
rBackslash = /\\/g,
rNonWord = /\W/;
 
// Here we check if the JavaScript engine is using some sort of
// optimization where it does not always call our comparision
// function. If that is the case, discard the hasDuplicate value.
// Thus far that includes Google Chrome.
[0, 0].sort(function() {
baseHasDuplicate = false;
return 0;
});
 
var Sizzle = function( selector, context, results, seed ) {
results = results || [];
context = context || document;
 
var origContext = context;
 
if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
return [];
}
if ( !selector || typeof selector !== "string" ) {
return results;
}
 
var m, set, checkSet, extra, ret, cur, pop, i,
prune = true,
contextXML = Sizzle.isXML( context ),
parts = [],
soFar = selector;
// Reset the position of the chunker regexp (start from head)
do {
chunker.exec( "" );
m = chunker.exec( soFar );
 
if ( m ) {
soFar = m[3];
parts.push( m[1] );
if ( m[2] ) {
extra = m[3];
break;
}
}
} while ( m );
 
if ( parts.length > 1 && origPOS.exec( selector ) ) {
 
if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
set = posProcess( parts[0] + parts[1], context );
 
} else {
set = Expr.relative[ parts[0] ] ?
[ context ] :
Sizzle( parts.shift(), context );
 
while ( parts.length ) {
selector = parts.shift();
 
if ( Expr.relative[ selector ] ) {
selector += parts.shift();
}
set = posProcess( selector, set );
}
}
 
} else {
// Take a shortcut and set the context if the root selector is an ID
// (but not if it'll be faster if the inner selector is an ID)
if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
 
ret = Sizzle.find( parts.shift(), context, contextXML );
context = ret.expr ?
Sizzle.filter( ret.expr, ret.set )[0] :
ret.set[0];
}
 
if ( context ) {
ret = seed ?
{ expr: parts.pop(), set: makeArray(seed) } :
Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
 
set = ret.expr ?
Sizzle.filter( ret.expr, ret.set ) :
ret.set;
 
if ( parts.length > 0 ) {
checkSet = makeArray( set );
 
} else {
prune = false;
}
 
while ( parts.length ) {
cur = parts.pop();
pop = cur;
 
if ( !Expr.relative[ cur ] ) {
cur = "";
} else {
pop = parts.pop();
}
 
if ( pop == null ) {
pop = context;
}
 
Expr.relative[ cur ]( checkSet, pop, contextXML );
}
 
} else {
checkSet = parts = [];
}
}
 
if ( !checkSet ) {
checkSet = set;
}
 
if ( !checkSet ) {
Sizzle.error( cur || selector );
}
 
if ( toString.call(checkSet) === "[object Array]" ) {
if ( !prune ) {
results.push.apply( results, checkSet );
 
} else if ( context && context.nodeType === 1 ) {
for ( i = 0; checkSet[i] != null; i++ ) {
if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
results.push( set[i] );
}
}
 
} else {
for ( i = 0; checkSet[i] != null; i++ ) {
if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
results.push( set[i] );
}
}
}
 
} else {
makeArray( checkSet, results );
}
 
if ( extra ) {
Sizzle( extra, origContext, results, seed );
Sizzle.uniqueSort( results );
}
 
return results;
};
 
Sizzle.uniqueSort = function( results ) {
if ( sortOrder ) {
hasDuplicate = baseHasDuplicate;
results.sort( sortOrder );
 
if ( hasDuplicate ) {
for ( var i = 1; i < results.length; i++ ) {
if ( results[i] === results[ i - 1 ] ) {
results.splice( i--, 1 );
}
}
}
}
 
return results;
};
 
Sizzle.matches = function( expr, set ) {
return Sizzle( expr, null, null, set );
};
 
Sizzle.matchesSelector = function( node, expr ) {
return Sizzle( expr, null, null, [node] ).length > 0;
};
 
Sizzle.find = function( expr, context, isXML ) {
var set;
 
if ( !expr ) {
return [];
}
 
for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
var match,
type = Expr.order[i];
if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
var left = match[1];
match.splice( 1, 1 );
 
if ( left.substr( left.length - 1 ) !== "\\" ) {
match[1] = (match[1] || "").replace( rBackslash, "" );
set = Expr.find[ type ]( match, context, isXML );
 
if ( set != null ) {
expr = expr.replace( Expr.match[ type ], "" );
break;
}
}
}
}
 
if ( !set ) {
set = typeof context.getElementsByTagName !== "undefined" ?
context.getElementsByTagName( "*" ) :
[];
}
 
return { set: set, expr: expr };
};
 
Sizzle.filter = function( expr, set, inplace, not ) {
var match, anyFound,
old = expr,
result = [],
curLoop = set,
isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
 
while ( expr && set.length ) {
for ( var type in Expr.filter ) {
if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
var found, item,
filter = Expr.filter[ type ],
left = match[1];
 
anyFound = false;
 
match.splice(1,1);
 
if ( left.substr( left.length - 1 ) === "\\" ) {
continue;
}
 
if ( curLoop === result ) {
result = [];
}
 
if ( Expr.preFilter[ type ] ) {
match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
 
if ( !match ) {
anyFound = found = true;
 
} else if ( match === true ) {
continue;
}
}
 
if ( match ) {
for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
if ( item ) {
found = filter( item, match, i, curLoop );
var pass = not ^ !!found;
 
if ( inplace && found != null ) {
if ( pass ) {
anyFound = true;
 
} else {
curLoop[i] = false;
}
 
} else if ( pass ) {
result.push( item );
anyFound = true;
}
}
}
}
 
if ( found !== undefined ) {
if ( !inplace ) {
curLoop = result;
}
 
expr = expr.replace( Expr.match[ type ], "" );
 
if ( !anyFound ) {
return [];
}
 
break;
}
}
}
 
// Improper expression
if ( expr === old ) {
if ( anyFound == null ) {
Sizzle.error( expr );
 
} else {
break;
}
}
 
old = expr;
}
 
return curLoop;
};
 
Sizzle.error = function( msg ) {
throw "Syntax error, unrecognized expression: " + msg;
};
 
var Expr = Sizzle.selectors = {
order: [ "ID", "NAME", "TAG" ],
 
match: {
ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
},
 
leftMatch: {},
 
attrMap: {
"class": "className",
"for": "htmlFor"
},
 
attrHandle: {
href: function( elem ) {
return elem.getAttribute( "href" );
},
type: function( elem ) {
return elem.getAttribute( "type" );
}
},
 
relative: {
"+": function(checkSet, part){
var isPartStr = typeof part === "string",
isTag = isPartStr && !rNonWord.test( part ),
isPartStrNotTag = isPartStr && !isTag;
 
if ( isTag ) {
part = part.toLowerCase();
}
 
for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
if ( (elem = checkSet[i]) ) {
while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
 
checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
elem || false :
elem === part;
}
}
 
if ( isPartStrNotTag ) {
Sizzle.filter( part, checkSet, true );
}
},
 
">": function( checkSet, part ) {
var elem,
isPartStr = typeof part === "string",
i = 0,
l = checkSet.length;
 
if ( isPartStr && !rNonWord.test( part ) ) {
part = part.toLowerCase();
 
for ( ; i < l; i++ ) {
elem = checkSet[i];
 
if ( elem ) {
var parent = elem.parentNode;
checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
}
}
 
} else {
for ( ; i < l; i++ ) {
elem = checkSet[i];
 
if ( elem ) {
checkSet[i] = isPartStr ?
elem.parentNode :
elem.parentNode === part;
}
}
 
if ( isPartStr ) {
Sizzle.filter( part, checkSet, true );
}
}
},
 
"": function(checkSet, part, isXML){
var nodeCheck,
doneName = done++,
checkFn = dirCheck;
 
if ( typeof part === "string" && !rNonWord.test( part ) ) {
part = part.toLowerCase();
nodeCheck = part;
checkFn = dirNodeCheck;
}
 
checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
},
 
"~": function( checkSet, part, isXML ) {
var nodeCheck,
doneName = done++,
checkFn = dirCheck;
 
if ( typeof part === "string" && !rNonWord.test( part ) ) {
part = part.toLowerCase();
nodeCheck = part;
checkFn = dirNodeCheck;
}
 
checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
}
},
 
find: {
ID: function( match, context, isXML ) {
if ( typeof context.getElementById !== "undefined" && !isXML ) {
var m = context.getElementById(match[1]);
// Check parentNode to catch when Blackberry 4.6 returns
// nodes that are no longer in the document #6963
return m && m.parentNode ? [m] : [];
}
},
 
NAME: function( match, context ) {
if ( typeof context.getElementsByName !== "undefined" ) {
var ret = [],
results = context.getElementsByName( match[1] );
 
for ( var i = 0, l = results.length; i < l; i++ ) {
if ( results[i].getAttribute("name") === match[1] ) {
ret.push( results[i] );
}
}
 
return ret.length === 0 ? null : ret;
}
},
 
TAG: function( match, context ) {
if ( typeof context.getElementsByTagName !== "undefined" ) {
return context.getElementsByTagName( match[1] );
}
}
},
preFilter: {
CLASS: function( match, curLoop, inplace, result, not, isXML ) {
match = " " + match[1].replace( rBackslash, "" ) + " ";
 
if ( isXML ) {
return match;
}
 
for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
if ( elem ) {
if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {
if ( !inplace ) {
result.push( elem );
}
 
} else if ( inplace ) {
curLoop[i] = false;
}
}
}
 
return false;
},
 
ID: function( match ) {
return match[1].replace( rBackslash, "" );
},
 
TAG: function( match, curLoop ) {
return match[1].replace( rBackslash, "" ).toLowerCase();
},
 
CHILD: function( match ) {
if ( match[1] === "nth" ) {
if ( !match[2] ) {
Sizzle.error( match[0] );
}
 
match[2] = match[2].replace(/^\+|\s*/g, '');
 
// parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
!/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
 
// calculate the numbers (first)n+(last) including if they are negative
match[2] = (test[1] + (test[2] || 1)) - 0;
match[3] = test[3] - 0;
}
else if ( match[2] ) {
Sizzle.error( match[0] );
}
 
// TODO: Move to normal caching system
match[0] = done++;
 
return match;
},
 
ATTR: function( match, curLoop, inplace, result, not, isXML ) {
var name = match[1] = match[1].replace( rBackslash, "" );
if ( !isXML && Expr.attrMap[name] ) {
match[1] = Expr.attrMap[name];
}
 
// Handle if an un-quoted value was used
match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" );
 
if ( match[2] === "~=" ) {
match[4] = " " + match[4] + " ";
}
 
return match;
},
 
PSEUDO: function( match, curLoop, inplace, result, not ) {
if ( match[1] === "not" ) {
// If we're dealing with a complex expression, or a simple one
if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
match[3] = Sizzle(match[3], null, null, curLoop);
 
} else {
var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
 
if ( !inplace ) {
result.push.apply( result, ret );
}
 
return false;
}
 
} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
return true;
}
return match;
},
 
POS: function( match ) {
match.unshift( true );
 
return match;
}
},
filters: {
enabled: function( elem ) {
return elem.disabled === false && elem.type !== "hidden";
},
 
disabled: function( elem ) {
return elem.disabled === true;
},
 
checked: function( elem ) {
return elem.checked === true;
},
selected: function( elem ) {
// Accessing this property makes selected-by-default
// options in Safari work properly
if ( elem.parentNode ) {
elem.parentNode.selectedIndex;
}
return elem.selected === true;
},
 
parent: function( elem ) {
return !!elem.firstChild;
},
 
empty: function( elem ) {
return !elem.firstChild;
},
 
has: function( elem, i, match ) {
return !!Sizzle( match[3], elem ).length;
},
 
header: function( elem ) {
return (/h\d/i).test( elem.nodeName );
},
 
text: function( elem ) {
var attr = elem.getAttribute( "type" ), type = elem.type;
// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
// use getAttribute instead to test this case
return "text" === type && ( attr === type || attr === null );
},
 
radio: function( elem ) {
return "radio" === elem.type;
},
 
checkbox: function( elem ) {
return "checkbox" === elem.type;
},
 
file: function( elem ) {
return "file" === elem.type;
},
password: function( elem ) {
return "password" === elem.type;
},
 
submit: function( elem ) {
return "submit" === elem.type;
},
 
image: function( elem ) {
return "image" === elem.type;
},
 
reset: function( elem ) {
return "reset" === elem.type;
},
 
button: function( elem ) {
return "button" === elem.type || elem.nodeName.toLowerCase() === "button";
},
 
input: function( elem ) {
return (/input|select|textarea|button/i).test( elem.nodeName );
}
},
setFilters: {
first: function( elem, i ) {
return i === 0;
},
 
last: function( elem, i, match, array ) {
return i === array.length - 1;
},
 
even: function( elem, i ) {
return i % 2 === 0;
},
 
odd: function( elem, i ) {
return i % 2 === 1;
},
 
lt: function( elem, i, match ) {
return i < match[3] - 0;
},
 
gt: function( elem, i, match ) {
return i > match[3] - 0;
},
 
nth: function( elem, i, match ) {
return match[3] - 0 === i;
},
 
eq: function( elem, i, match ) {
return match[3] - 0 === i;
}
},
filter: {
PSEUDO: function( elem, match, i, array ) {
var name = match[1],
filter = Expr.filters[ name ];
 
if ( filter ) {
return filter( elem, i, match, array );
 
} else if ( name === "contains" ) {
return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0;
 
} else if ( name === "not" ) {
var not = match[3];
 
for ( var j = 0, l = not.length; j < l; j++ ) {
if ( not[j] === elem ) {
return false;
}
}
 
return true;
 
} else {
Sizzle.error( name );
}
},
 
CHILD: function( elem, match ) {
var type = match[1],
node = elem;
 
switch ( type ) {
case "only":
case "first":
while ( (node = node.previousSibling) ) {
if ( node.nodeType === 1 ) {
return false;
}
}
 
if ( type === "first" ) {
return true;
}
 
node = elem;
 
case "last":
while ( (node = node.nextSibling) ) {
if ( node.nodeType === 1 ) {
return false;
}
}
 
return true;
 
case "nth":
var first = match[2],
last = match[3];
 
if ( first === 1 && last === 0 ) {
return true;
}
var doneName = match[0],
parent = elem.parentNode;
if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
var count = 0;
for ( node = parent.firstChild; node; node = node.nextSibling ) {
if ( node.nodeType === 1 ) {
node.nodeIndex = ++count;
}
}
 
parent.sizcache = doneName;
}
var diff = elem.nodeIndex - last;
 
if ( first === 0 ) {
return diff === 0;
 
} else {
return ( diff % first === 0 && diff / first >= 0 );
}
}
},
 
ID: function( elem, match ) {
return elem.nodeType === 1 && elem.getAttribute("id") === match;
},
 
TAG: function( elem, match ) {
return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
},
CLASS: function( elem, match ) {
return (" " + (elem.className || elem.getAttribute("class")) + " ")
.indexOf( match ) > -1;
},
 
ATTR: function( elem, match ) {
var name = match[1],
result = Expr.attrHandle[ name ] ?
Expr.attrHandle[ name ]( elem ) :
elem[ name ] != null ?
elem[ name ] :
elem.getAttribute( name ),
value = result + "",
type = match[2],
check = match[4];
 
return result == null ?
type === "!=" :
type === "=" ?
value === check :
type === "*=" ?
value.indexOf(check) >= 0 :
type === "~=" ?
(" " + value + " ").indexOf(check) >= 0 :
!check ?
value && result !== false :
type === "!=" ?
value !== check :
type === "^=" ?
value.indexOf(check) === 0 :
type === "$=" ?
value.substr(value.length - check.length) === check :
type === "|=" ?
value === check || value.substr(0, check.length + 1) === check + "-" :
false;
},
 
POS: function( elem, match, i, array ) {
var name = match[2],
filter = Expr.setFilters[ name ];
 
if ( filter ) {
return filter( elem, i, match, array );
}
}
}
};
 
var origPOS = Expr.match.POS,
fescape = function(all, num){
return "\\" + (num - 0 + 1);
};
 
for ( var type in Expr.match ) {
Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
}
 
var makeArray = function( array, results ) {
array = Array.prototype.slice.call( array, 0 );
 
if ( results ) {
results.push.apply( results, array );
return results;
}
return array;
};
 
// Perform a simple check to determine if the browser is capable of
// converting a NodeList to an array using builtin methods.
// Also verifies that the returned array holds DOM nodes
// (which is not the case in the Blackberry browser)
try {
Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
 
// Provide a fallback method if it does not work
} catch( e ) {
makeArray = function( array, results ) {
var i = 0,
ret = results || [];
 
if ( toString.call(array) === "[object Array]" ) {
Array.prototype.push.apply( ret, array );
 
} else {
if ( typeof array.length === "number" ) {
for ( var l = array.length; i < l; i++ ) {
ret.push( array[i] );
}
 
} else {
for ( ; array[i]; i++ ) {
ret.push( array[i] );
}
}
}
 
return ret;
};
}
 
var sortOrder, siblingCheck;
 
if ( document.documentElement.compareDocumentPosition ) {
sortOrder = function( a, b ) {
if ( a === b ) {
hasDuplicate = true;
return 0;
}
 
if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
return a.compareDocumentPosition ? -1 : 1;
}
 
return a.compareDocumentPosition(b) & 4 ? -1 : 1;
};
 
} else {
sortOrder = function( a, b ) {
var al, bl,
ap = [],
bp = [],
aup = a.parentNode,
bup = b.parentNode,
cur = aup;
 
// The nodes are identical, we can exit early
if ( a === b ) {
hasDuplicate = true;
return 0;
 
// If the nodes are siblings (or identical) we can do a quick check
} else if ( aup === bup ) {
return siblingCheck( a, b );
 
// If no parents were found then the nodes are disconnected
} else if ( !aup ) {
return -1;
 
} else if ( !bup ) {
return 1;
}
 
// Otherwise they're somewhere else in the tree so we need
// to build up a full list of the parentNodes for comparison
while ( cur ) {
ap.unshift( cur );
cur = cur.parentNode;
}
 
cur = bup;
 
while ( cur ) {
bp.unshift( cur );
cur = cur.parentNode;
}
 
al = ap.length;
bl = bp.length;
 
// Start walking down the tree looking for a discrepancy
for ( var i = 0; i < al && i < bl; i++ ) {
if ( ap[i] !== bp[i] ) {
return siblingCheck( ap[i], bp[i] );
}
}
 
// We ended someplace up the tree so do a sibling check
return i === al ?
siblingCheck( a, bp[i], -1 ) :
siblingCheck( ap[i], b, 1 );
};
 
siblingCheck = function( a, b, ret ) {
if ( a === b ) {
return ret;
}
 
var cur = a.nextSibling;
 
while ( cur ) {
if ( cur === b ) {
return -1;
}
 
cur = cur.nextSibling;
}
 
return 1;
};
}
 
// Utility function for retreiving the text value of an array of DOM nodes
Sizzle.getText = function( elems ) {
var ret = "", elem;
 
for ( var i = 0; elems[i]; i++ ) {
elem = elems[i];
 
// Get the text from text nodes and CDATA nodes
if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
ret += elem.nodeValue;
 
// Traverse everything else, except comment nodes
} else if ( elem.nodeType !== 8 ) {
ret += Sizzle.getText( elem.childNodes );
}
}
 
return ret;
};
 
// Check to see if the browser returns elements by name when
// querying by getElementById (and provide a workaround)
(function(){
// We're going to inject a fake input element with a specified name
var form = document.createElement("div"),
id = "script" + (new Date()).getTime(),
root = document.documentElement;
 
form.innerHTML = "<a name='" + id + "'/>";
 
// Inject it into the root element, check its status, and remove it quickly
root.insertBefore( form, root.firstChild );
 
// The workaround has to do additional checks after a getElementById
// Which slows things down for other browsers (hence the branching)
if ( document.getElementById( id ) ) {
Expr.find.ID = function( match, context, isXML ) {
if ( typeof context.getElementById !== "undefined" && !isXML ) {
var m = context.getElementById(match[1]);
 
return m ?
m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
[m] :
undefined :
[];
}
};
 
Expr.filter.ID = function( elem, match ) {
var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
 
return elem.nodeType === 1 && node && node.nodeValue === match;
};
}
 
root.removeChild( form );
 
// release memory in IE
root = form = null;
})();
 
(function(){
// Check to see if the browser returns only elements
// when doing getElementsByTagName("*")
 
// Create a fake element
var div = document.createElement("div");
div.appendChild( document.createComment("") );
 
// Make sure no comments are found
if ( div.getElementsByTagName("*").length > 0 ) {
Expr.find.TAG = function( match, context ) {
var results = context.getElementsByTagName( match[1] );
 
// Filter out possible comments
if ( match[1] === "*" ) {
var tmp = [];
 
for ( var i = 0; results[i]; i++ ) {
if ( results[i].nodeType === 1 ) {
tmp.push( results[i] );
}
}
 
results = tmp;
}
 
return results;
};
}
 
// Check to see if an attribute returns normalized href attributes
div.innerHTML = "<a href='#'></a>";
 
if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
div.firstChild.getAttribute("href") !== "#" ) {
 
Expr.attrHandle.href = function( elem ) {
return elem.getAttribute( "href", 2 );
};
}
 
// release memory in IE
div = null;
})();
 
if ( document.querySelectorAll ) {
(function(){
var oldSizzle = Sizzle,
div = document.createElement("div"),
id = "__sizzle__";
 
div.innerHTML = "<p class='TEST'></p>";
 
// Safari can't handle uppercase or unicode characters when
// in quirks mode.
if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
return;
}
Sizzle = function( query, context, extra, seed ) {
context = context || document;
 
// Only use querySelectorAll on non-XML documents
// (ID selectors don't work in non-HTML documents)
if ( !seed && !Sizzle.isXML(context) ) {
// See if we find a selector to speed up
var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
// Speed-up: Sizzle("TAG")
if ( match[1] ) {
return makeArray( context.getElementsByTagName( query ), extra );
// Speed-up: Sizzle(".CLASS")
} else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
return makeArray( context.getElementsByClassName( match[2] ), extra );
}
}
if ( context.nodeType === 9 ) {
// Speed-up: Sizzle("body")
// The body element only exists once, optimize finding it
if ( query === "body" && context.body ) {
return makeArray( [ context.body ], extra );
// Speed-up: Sizzle("#ID")
} else if ( match && match[3] ) {
var elem = context.getElementById( match[3] );
 
// Check parentNode to catch when Blackberry 4.6 returns
// nodes that are no longer in the document #6963
if ( elem && elem.parentNode ) {
// Handle the case where IE and Opera return items
// by name instead of ID
if ( elem.id === match[3] ) {
return makeArray( [ elem ], extra );
}
} else {
return makeArray( [], extra );
}
}
try {
return makeArray( context.querySelectorAll(query), extra );
} catch(qsaError) {}
 
// qSA works strangely on Element-rooted queries
// We can work around this by specifying an extra ID on the root
// and working up from there (Thanks to Andrew Dupont for the technique)
// IE 8 doesn't work on object elements
} else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
var oldContext = context,
old = context.getAttribute( "id" ),
nid = old || id,
hasParent = context.parentNode,
relativeHierarchySelector = /^\s*[+~]/.test( query );
 
if ( !old ) {
context.setAttribute( "id", nid );
} else {
nid = nid.replace( /'/g, "\\$&" );
}
if ( relativeHierarchySelector && hasParent ) {
context = context.parentNode;
}
 
try {
if ( !relativeHierarchySelector || hasParent ) {
return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
}
 
} catch(pseudoError) {
} finally {
if ( !old ) {
oldContext.removeAttribute( "id" );
}
}
}
}
return oldSizzle(query, context, extra, seed);
};
 
for ( var prop in oldSizzle ) {
Sizzle[ prop ] = oldSizzle[ prop ];
}
 
// release memory in IE
div = null;
})();
}
 
(function(){
var html = document.documentElement,
matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector,
pseudoWorks = false;
 
try {
// This should fail with an exception
// Gecko does not error, returns false instead
matches.call( document.documentElement, "[test!='']:sizzle" );
} catch( pseudoError ) {
pseudoWorks = true;
}
 
if ( matches ) {
Sizzle.matchesSelector = function( node, expr ) {
// Make sure that attribute selectors are quoted
expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
 
if ( !Sizzle.isXML( node ) ) {
try {
if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
return matches.call( node, expr );
}
} catch(e) {}
}
 
return Sizzle(expr, null, null, [node]).length > 0;
};
}
})();
 
(function(){
var div = document.createElement("div");
 
div.innerHTML = "<div class='test e'></div><div class='test'></div>";
 
// Opera can't find a second classname (in 9.6)
// Also, make sure that getElementsByClassName actually exists
if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
return;
}
 
// Safari caches class attributes, doesn't catch changes (in 3.2)
div.lastChild.className = "e";
 
if ( div.getElementsByClassName("e").length === 1 ) {
return;
}
Expr.order.splice(1, 0, "CLASS");
Expr.find.CLASS = function( match, context, isXML ) {
if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
return context.getElementsByClassName(match[1]);
}
};
 
// release memory in IE
div = null;
})();
 
function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
for ( var i = 0, l = checkSet.length; i < l; i++ ) {
var elem = checkSet[i];
 
if ( elem ) {
var match = false;
 
elem = elem[dir];
 
while ( elem ) {
if ( elem.sizcache === doneName ) {
match = checkSet[elem.sizset];
break;
}
 
if ( elem.nodeType === 1 && !isXML ){
elem.sizcache = doneName;
elem.sizset = i;
}
 
if ( elem.nodeName.toLowerCase() === cur ) {
match = elem;
break;
}
 
elem = elem[dir];
}
 
checkSet[i] = match;
}
}
}
 
function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
for ( var i = 0, l = checkSet.length; i < l; i++ ) {
var elem = checkSet[i];
 
if ( elem ) {
var match = false;
elem = elem[dir];
 
while ( elem ) {
if ( elem.sizcache === doneName ) {
match = checkSet[elem.sizset];
break;
}
 
if ( elem.nodeType === 1 ) {
if ( !isXML ) {
elem.sizcache = doneName;
elem.sizset = i;
}
 
if ( typeof cur !== "string" ) {
if ( elem === cur ) {
match = true;
break;
}
 
} else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
match = elem;
break;
}
}
 
elem = elem[dir];
}
 
checkSet[i] = match;
}
}
}
 
if ( document.documentElement.contains ) {
Sizzle.contains = function( a, b ) {
return a !== b && (a.contains ? a.contains(b) : true);
};
 
} else if ( document.documentElement.compareDocumentPosition ) {
Sizzle.contains = function( a, b ) {
return !!(a.compareDocumentPosition(b) & 16);
};
 
} else {
Sizzle.contains = function() {
return false;
};
}
 
Sizzle.isXML = function( elem ) {
// documentElement is verified for cases where it doesn't yet exist
// (such as loading iframes in IE - #4833)
var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
 
return documentElement ? documentElement.nodeName !== "HTML" : false;
};
 
var posProcess = function( selector, context ) {
var match,
tmpSet = [],
later = "",
root = context.nodeType ? [context] : context;
 
// Position selectors must be done after the filter
// And so must :not(positional) so we move all PSEUDOs to the end
while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
later += match[0];
selector = selector.replace( Expr.match.PSEUDO, "" );
}
 
selector = Expr.relative[selector] ? selector + "*" : selector;
 
for ( var i = 0, l = root.length; i < l; i++ ) {
Sizzle( selector, root[i], tmpSet );
}
 
return Sizzle.filter( later, tmpSet );
};
 
// EXPOSE
 
window.Sizzle = Sizzle;
 
})();
// This fixes the syntax highlighting in TextMate "
 
// First set up the alias
Mappa.addAlias('Toolbox');
 
// Then map all of the functions
 
// Sizzle
Toolbox.addMap('find', Sizzle);
 
// JSON
Toolbox.addMap('json', {
encode: JSON.stringify,
decode: JSON.parse
});
 
// Browser detect
Toolbox.addMap('client', {
browser: BrowserDetect.browser,
version: BrowserDetect.version,
os: BrowserDetect.OS
});
 
// Cookie
Toolbox.addMap('cookie', {
set: set_cookie,
get: get_cookie,
del: del_cookie,
array: {
init: init_array,
set: set_array,
get: get_array,
entry: {
del: del_entry,
next: next_entry
}
},
debug: {
on: debug_on,
off: debug_off
},
dump: dump_cookies
});
 
// Events
Toolbox.addMap('event', {
add: addEvent,
remove: removeEvent,
handle: handleEvent,
fix: fixEvent
});
 
// AJAX
Toolbox.addMap('ajax', AjaxRequest);
 
// Animate
Toolbox.addMap('animator', jsAnimManager);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.