1/**************************************************************************************************************************************************/ 2/* 3 * jQuery CountdownGampang 4 * written by Shidiq Fadhilah - Indonesia <[email protected]> 5 * Licensed under the MIT license https://github.com/fadhilah1992/jquery-countdowngampang/blob/main/LICENSE 6 * Version 1.0.1 7 * 8 * jQuery ClassyCountdown 9 * www.class.pm 10 * 11 * Written by Marius Stanciu - Sergiu <[email protected]> 12 * Licensed under the MIT license www.class.pm/LICENSE-MIT 13 * Version 1.0.1 14 /**************************************************************************************************************************************************/ 15 16(function ($) { 17 18 $.fn.CountdownGampang = function (options, callback) { 19 // check for jQuery knob and throttle 20 if (!jQuery().knob) { 21 throw 'CountdownGampang require jQuery knob.'; 22 } 23 24 if (!jQuery.throttle) { 25 throw 'CountdownGampang require jQuery throttle / debounce.'; 26 } 27 28 var element = $(this); 29 var settings = { 30 rampung: undefined, 31 labels: true, 32 labelsOptions: { 33 lang: { 34 days: 'Days', 35 hours: 'Hours', 36 minutes: 'Minutes', 37 seconds: 'Seconds' 38 }, 39 }, 40 style: { 41 element: '', 42 labels: false, 43 textResponsive: 0.5, 44 days: { 45 gauge: { 46 thickness: 0.02, 47 bgColor: '#ff8503', 48 fgColor: '#ff8503', 49 lineCap: 'butt' 50 }, 51 textCSS: '' 52 }, 53 hours: { 54 gauge: { 55 thickness: 0.02, 56 bgColor: 'rgba(0, 0, 0, 0)', 57 fgColor: 'rgba(0, 0, 0, 1)', 58 lineCap: 'butt' 59 }, 60 textCSS: '' 61 }, 62 minutes: { 63 gauge: { 64 thickness: 0.02, 65 bgColor: 'rgba(0, 0, 0, 0)', 66 fgColor: 'rgba(0, 0, 0, 1)', 67 lineCap: 'butt' 68 }, 69 textCSS: '' 70 }, 71 seconds: { 72 gauge: { 73 thickness: 0.02, 74 bgColor: 'rgba(0, 0, 0, 0)', 75 fgColor: 'rgba(0, 0, 0, 1)', 76 lineCap: 'butt' 77 }, 78 textCSS: '' 79 } 80 }, 81 onEndCallback: function () { 82 if (window.console && window.console.log) { 83 window.console.log("[CountdownGampang::isRampung] Wayae, wayae ......"); 84 } 85 } 86 }; 87 88 // if not rampung passed in options 89 if (!options.rampung) { 90 throw 'Parameter options.rampung must passed bro.'; 91 } 92 93 // append options 94 settings = $.extend(true, settings, options); 95 96 // callback 97 if (typeof callback !== undefined) { 98 settings.onEndCallback = callback; 99 } 100 101 function prepareTemplate() { 102 element.append('<div class="ClassyCountdown-wrapper">' + 103 '<div class="ClassyCountdown-days">' + 104 '<input type="text" />' + 105 '<div class="ClassyCountdown-value"><div></div><span></span></div>' + 106 '</div>' + 107 '<div class="ClassyCountdown-hours">' + 108 '<input type="text" />' + 109 '<div class="ClassyCountdown-value"><div></div><span></span></div>' + 110 '</div>' + 111 '<div class="ClassyCountdown-minutes">' + 112 '<input type="text" />' + 113 '<div class="ClassyCountdown-value"><div></div><span></span></div>' + 114 '</div>' + 115 '<div class="ClassyCountdown-seconds">' + 116 '<input type="text" />' + 117 '<div class="ClassyCountdown-value"><div></div><span></span></div>' + 118 '</div>' + 119 '</div>'); 120 121 element.find('.ClassyCountdown-days input').knob($.extend({ 122 width: '100%', 123 displayInput: false, 124 readOnly: true, 125 max: 365 126 }, settings.style.days.gauge)); 127 128 element.find('.ClassyCountdown-hours input').knob($.extend({ 129 width: '100%', 130 displayInput: false, 131 readOnly: true, 132 max: 24 133 }, settings.style.hours.gauge)); 134 135 element.find('.ClassyCountdown-minutes input').knob($.extend({ 136 width: '100%', 137 displayInput: false, 138 readOnly: true, 139 max: 60 140 }, settings.style.minutes.gauge)); 141 142 element.find('.ClassyCountdown-seconds input').knob($.extend({ 143 width: '100%', 144 displayInput: false, 145 readOnly: true, 146 max: 60 147 }, settings.style.seconds.gauge)); 148 149 element.find('.ClassyCountdown-wrapper > div').attr("style", settings.style.element); 150 element.find('.ClassyCountdown-days .ClassyCountdown-value').attr('style', settings.style.days.textCSS); 151 element.find('.ClassyCountdown-hours .ClassyCountdown-value').attr('style', settings.style.hours.textCSS); 152 element.find('.ClassyCountdown-minutes .ClassyCountdown-value').attr('style', settings.style.minutes.textCSS); 153 element.find('.ClassyCountdown-seconds .ClassyCountdown-value').attr('style', settings.style.seconds.textCSS); 154 155 if (settings.labels) { 156 element.find(".ClassyCountdown-days .ClassyCountdown-value >
156 span").html(settings.labelsOptions.lang.days); 157 element.find(".ClassyCountdown-hours .ClassyCountdown-value > span").html(settings.labelsOptions.lang.hours); 158 element.find(".ClassyCountdown-minutes .ClassyCountdown-value > span").html(settings.labelsOptions.lang.minutes); 159 element.find(".ClassyCountdown-seconds .ClassyCountdown-value > span").html(settings.labelsOptions.lang.seconds); 160 element.find(".ClassyCountdown-value > span").attr("style", settings.labelsOptions.style); 161 } 162 } 163 164 function onResize() { 165 element.find('.ClassyCountdown-wrapper > div').each(function () { 166 $(this).css('height', $(this).width() + 'px'); 167 }); 168 169 if (settings.style.textResponsive) { 170 element.find('.ClassyCountdown-value').css('font-size', Math.floor(element.find('> div').eq(0).width() * settings.style.textResponsive / 10) + 'px'); 171 } 172 173 element.find('.ClassyCountdown-days input').trigger('change'); 174 element.find('.ClassyCountdown-hours input').trigger('change'); 175 element.find('.ClassyCountdown-minutes input').trigger('change'); 176 element.find('.ClassyCountdown-seconds input').trigger('change'); 177 } 178 179 function doResponsive() { 180 element.find('.ClassyCountdown-wrapper > div').each(function () { 181 $(this).css('height', $(this).width() + 'px'); 182 }); 183 184 if (settings.style.textResponsive) { 185 element.find('.ClassyCountdown-value').css('font-size', Math.floor(element.find('> div').eq(0).width() * settings.style.textResponsive / 10) + 'px'); 186 } 187 188 $(window).trigger('resize'); 189 190 $(window).resize($.throttle(50, onResize)); 191 } 192 193 function getTheme(name) { 194 switch (name) { 195 case 'flat-colors': 196 return { 197 labels: true, 198 style: { 199 element: '', 200 textResponsive: 0.5, 201 days: { 202 gauge: { 203 thickness: 0.01, 204 bgColor: "#c3c3c3", 205 fgColor: "#ff8503" 206 }, 207 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 208 }, 209 hours: { 210 gauge: { 211 thickness: 0.01, 212 bgColor: "#c3c3c3", 213 fgColor: "#ff8503" 214 }, 215 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 216 }, 217 minutes: { 218 gauge: { 219 thickness: 0.01, 220 bgColor: "#c3c3c3", 221 fgColor: "#ff8503" 222 }, 223 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 224 }, 225 seconds: { 226 gauge: { 227 thickness: 0.01, 228 bgColor: "#c3c3c3", 229 fgColor: "#ff8503" 230 }, 231 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 232 } 233 } 234 }; 235 case 'flat-colors-wide': 236 return { 237 labels: true, 238 style: { 239 element: '', 240 textResponsive: 0.5, 241 days: { 242 gauge: { 243 thickness: 0.03, 244 bgColor: "#c3c3c3", 245 fgColor: "#ff8503" 246 }, 247 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 248 }, 249 hours: { 250 gauge: { 251 thickness: 0.03, 252 bgColor: "#c3c3c3", 253 fgColor: "#ff8503" 254 }, 255 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 256 }, 257 minutes: { 258 gauge: { 259 thickness: 0.03, 260 bgColor: "#c3c3c3", 261 fgColor: "#ff8503" 262 }, 263 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 264 }, 265 seconds: { 266 gauge: { 267 thickness: 0.03, 268 bgColor: "#c3c3c3", 269 fgColor: "#ff8503" 270 }, 271 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 272 } 273 } 274 }; 275 case 'flat-colors-very-wide': 276 return { 277 labels: true, 278 style: { 279 element: '', 280 textResponsive: 0.5, 281 days: { 282 gauge: { 283 thickness: 0.1, 284 bgColor: "#c3c3c3", 285 fgColor: "#ff8503" 286 }, 287 textCSS: 'font-weight:600;color:#fff;' 288 }, 289 hours: { 290 gauge: { 291 thickness: 0.1, 292 bgColor: "#c3c3c3", 293 fgColor: "#ff8503" 294 }, 295 textCSS: 'font-weight:600;color:#fff;' 296 }, 297 minutes: { 298 gauge: { 299 thickness: 0.1, 300 bgColor: "#c3c3c3", 301 fgColor: "#ff8503" 302 }, 303 textCSS: 'font-weight:600;color:#fff;' 304 }, 305 seconds: { 306 gauge: { 307 thickness: 0.1, 308 bgColor: "#c3c3c3", 309 fgColor: "#ff8503" 310 }, 311 textCSS: 'font-weight:600;color:#fff;' 312 } 313 } 314 }; 315 case 'flat-colors-black': 316 return { 317 labels: true, 318 style: { 319 element: '', 320 textResponsive: 0.5, 321 days: { 322 gauge: { 323 thickness: 0.25, 324 bgColor: "##c3c3c3", 325 fgColor: "#ff8503", 326 lineCap: 'round' 327 }, 328 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 329 }, 330 hours: { 331 gauge: { 332 thickness: 0.25, 333 bgColor: "#c3c3c3", 334 fgColor: "#ff8503", 335 lineCap: 'round' 336 }, 337 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 338 }, 339 minutes: { 340 gauge: { 341 thickness: 0.25, 342 bgColor: "#c3c3c3", 343 fgColor: "#ff8503", lineCap: 'round' 344 }, 345 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 346 }, 347 seconds: { 348 gauge: { 349 thickness: 0.25, 350 bgColor: "#c3c3c3", 351 fgColor: "#ff8503", 352 lineCap: 'round' 353 }, 354 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 355 } 356 } 357 }; 358 case 'black': 359 return { 360 labels: true, 361 style: { 362 element: '', 363 textResponsive: 0.5, 364 days: { 365 gauge: { 366 thickness: 0.01, 367 bgColor: "rgba(0,0,0,0.05)", 368 fgColor: "#222" 369 }, 370 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 371 }, 372 hours: { 373 gauge: { 374 thickness: 0.01, 375 bgColor: "rgba(0,0,0,0.05)", 376 fgColor: "#222" 377 }, 378 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 379 }, 380 minutes: { 381 gauge: { 382 thickness: 0.01, 383 bgColor: "rgba(0,0,0,0.05)", 384 fgColor: "#222" 385 }, 386 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 387 }, 388 seconds: { 389 gauge: { 390 thickness: 0.01, 391 bgColor: "rgba(0,0,0,0.05)", 392 fgColor: "#222" 393 }, 394 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 395 } 396 } 397 }; 398 case 'black-wide': 399 return { 400 labels: true, 401 style: { 402 element: '', 403 textResponsive: 0.5, 404 days: { 405 gauge: { 406 thickness: 0.03, 407 bgColor: "rgba(0,0,0,0.05)", 408 fgColor: "#222" 409 }, 410 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 411 }, 412 hours: { 413 gauge: { 414 thickness: 0.03, 415 bgColor: "rgba(0,0,0,0.05)", 416 fgColor: "#222" 417 }, 418 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 419 }, 420 minutes: { 421 gauge: { 422 thickness: 0.03, 423 bgColor: "rgba(0,0,0,0.05)", 424 fgColor: "#222" 425 }, 426 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 427 }, 428 seconds: { 429 gauge: { 430 thickness: 0.03, 431 bgColor: "rgba(0,0,0,0.05)", 432 fgColor: "#222" 433 }, 434 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 435 } 436 } 437 }; 438 case 'black-very-wide': 439 return { 440 labels: true, 441 style: { 442 element: '', 443 textResponsive: 0.5, 444 days: { 445 gauge: { 446 thickness: 0.17, 447 bgColor: "rgba(0,0,0,0.05)", 448 fgColor: "#222" 449 }, 450 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 451 }, 452 hours: { 453 gauge: { 454 thickness: 0.17, 455 bgColor: "rgba(0,0,0,0.05)", 456 fgColor: "#222" 457 }, 458 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 459 }, 460 minutes: { 461 gauge: { 462 thickness: 0.17, 463 bgColor: "rgba(0,0,0,0.05)", 464 fgColor: "#222" 465 }, 466 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 467 }, 468 seconds: { 469 gauge: { 470 thickness: 0.17, 471 bgColor: "rgba(0,0,0,0.05)", 472 fgColor: "#222" 473 }, 474 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 475 } 476 } 477 }; 478 case 'black-black': 479 return { 480 labels: true, 481 style: { 482 element: '', 483 textResponsive: 0.5, 484 days: { 485 gauge: { 486 thickness: 0.25, 487 bgColor: "rgba(0,0,0,0.05)", 488 fgColor: "#222", 489 lineCap: 'round' 490 }, 491 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 492 }, 493 hours: { 494 gauge: { 495 thickness: 0.25, 496 bgColor: "rgba(0,0,0,0.05)", 497 fgColor: "#222", 498
498 lineCap: 'round' 499 }, 500 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 501 }, 502 minutes: { 503 gauge: { 504 thickness: 0.25, 505 bgColor: "rgba(0,0,0,0.05)", 506 fgColor: "#222", 507 lineCap: 'round' 508 }, 509 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 510 }, 511 seconds: { 512 gauge: { 513 thickness: 0.25, 514 bgColor: "rgba(0,0,0,0.05)", 515 fgColor: "#222", 516 lineCap: 'round' 517 }, 518 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#34495e;' 519 } 520 } 521 }; 522 case 'white': 523 return { 524 labels: true, 525 style: { 526 element: '', 527 textResponsive: 0.5, 528 days: { 529 gauge: { 530 thickness: 0.03, 531 bgColor: "rgba(255,255,255,0.05)", 532 fgColor: "#fff" 533 }, 534 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#fff;' 535 }, 536 hours: { 537 gauge: { 538 thickness: 0.03, 539 bgColor: "rgba(255,255,255,0.05)", 540 fgColor: "#fff" 541 }, 542 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#fff;' 543 }, 544 minutes: { 545 gauge: { 546 thickness: 0.03, 547 bgColor: "rgba(255,255,255,0.05)", 548 fgColor: "#fff" 549 }, 550 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#fff;' 551 }, 552 seconds: { 553 gauge: { 554 thickness: 0.03, 555 bgColor: "rgba(255,255,255,0.05)", 556 fgColor: "#fff" 557 }, 558 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#fff;' 559 } 560 } 561 }; 562 case 'white-wide': 563 return { 564 labels: true, 565 style: { 566 element: '', 567 textResponsive: 0.5, 568 days: { 569 gauge: { 570 thickness: 0.06, 571 bgColor: "rgba(255,255,255,0.05)", 572 fgColor: "#fff" 573 }, 574 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#fff;' 575 }, 576 hours: { 577 gauge: { 578 thickness: 0.06, 579 bgColor: "rgba(255,255,255,0.05)", 580 fgColor: "#fff" 581 }, 582 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#fff;' 583 }, 584 minutes: { 585 gauge: { 586 thickness: 0.06, 587 bgColor: "rgba(255,255,255,0.05)", 588 fgColor: "#fff" 589 }, 590 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#fff;' 591 }, 592 seconds: { 593 gauge: { 594 thickness: 0.06, 595 bgColor: "rgba(255,255,255,0.05)", 596 fgColor: "#fff" 597 }, 598 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#fff;' 599 } 600 } 601 }; 602 case 'white-very-wide': 603 return { 604 labels: true, 605 style: { 606 element: '', 607 textResponsive: 0.5, 608 days: { 609 gauge: { 610 thickness: 0.16, 611 bgColor: "rgba(255,255,255,0.05)", 612 fgColor: "#fff" 613 }, 614 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#fff;' 615 }, 616 hours: { 617 gauge: { 618 thickness: 0.16, 619 bgColor: "rgba(255,255,255,0.05)", 620 fgColor: "#fff" 621 }, 622 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#fff;' 623 }, 624 minutes: { 625 gauge: { 626 thickness: 0.16, 627 bgColor: "rgba(255,255,255,0.05)", 628 fgColor: "#fff" 629 }, 630 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#fff;' 631 }, 632 seconds: { 633 gauge: { 634 thickness: 0.16, 635 bgColor: "rgba(255,255,255,0.05)", 636 fgColor: "#fff" 637 }, 638 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#fff;' 639 } 640 } 641 }; 642 case 'white-black': 643 return { 644 labels: true, 645 style: { 646 element: '', 647 textResponsive: 0.5, 648 days: { 649 gauge: { 650 thickness: 0.25, 651 bgColor: "rgba(255,255,255,0.05)", 652 fgColor: "#fff", 653 lineCap: 'round' 654 }, 655 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#fff;' 656 }, 657 hours: { 658 gauge: { 659 thickness: 0.25, 660 bgColor: "rgba(255,255,255,0.05)", 661 fgColor: "#fff", 662 lineCap: 'round' 663 }, 664 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#fff;' 665 }, 666 minutes: { 667 gauge: { 668 thickness: 0.25, 669 bgColor: "rgba(255,255,255,0.05)", 670 fgColor: "#fff", 671 lineCap: 'round' 672 }, 673 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#fff;' 674 }, 675 seconds: { 676 gauge: { 677 thickness: 0.25, 678 bgColor: "rgba(255,255,255,0.05)", 679 fgColor: "#fff", 680 lineCap: 'round' 681 }, 682 textCSS: 'font-family:\'Open Sans\';font-weight:300;color:#fff;' 683 } 684 } 685 }; 686 } 687 } 688 689 // append theme from options if passed 690 if (options.theme) { 691 if (options.theme === "default") { 692 options.theme = "flat-colors-very-wide"; 693 } 694 settings = $.extend(true, settings, getTheme(options.theme)); 695 } else { 696 settings = $.extend(true, settings, getTheme("flat-colors-very-wide")); 697 } 698 699 prepareTemplate(); 700 701 var countdown = setInterval(function () { 702 var siki = new Date().getTime(); 703 var sels = settings.rampung - siki; 704 705 var days = Math.floor(sels / (1000 * 60 * 60 * 24)); 706 var hours = Math.floor((sels % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); 707 var minutes = Math.floor((sels % (1000 * 60 * 60)) / (1000 * 60)); 708 var seconds = Math.floor((sels % (1000 * 60)) / 1000); 709 710 if (sels < 0) { 711 days = 0; 712 hours = 0; 713 minutes = 0; 714 seconds = 0; 715 } 716 717 element.find('.ClassyCountdown-days input').val(365 - days).trigger('change'); 718 element.find('.ClassyCountdown-hours input').val(24 - hours).trigger('change'); 719 element.find('.ClassyCountdown-minutes input').val(60 - minutes).trigger('change'); 720 element.find('.ClassyCountdown-seconds input').val(60 - seconds).trigger('change'); 721 element.find('.ClassyCountdown-days .ClassyCountdown-value > div').html(days); 722 element.find('.ClassyCountdown-hours .ClassyCountdown-value > div').html(hours); 723 element.find('.ClassyCountdown-minutes .ClassyCountdown-value > div').html(minutes); 724 element.find('.ClassyCountdown-seconds .ClassyCountdown-value > div').html(seconds); 725 726 if (sels < 0) { 727 clearInterval(countdown); 728 settings.onEndCallback(); 729 } 730 }, 1000); 731 doResponsive(); 732 }; 733 734}(jQuery));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.