dpt-admin.js
7 years ago
dpt.js
7 years ago
load-monthly-table.js
8 years ago
wp-color-picker.js
9 years ago
dpt.js
109 lines
| 1 | DPT = { |
| 2 | init: function() { |
| 3 | this.monthlyCalendarChange(); |
| 4 | this.digitalScreenCheckChange(); |
| 5 | this.changeInputBackground(); |
| 6 | this.printDiv(); |
| 7 | this.startTimer(); |
| 8 | this.bs3screenOptions(); |
| 9 | }, |
| 10 | |
| 11 | monthlyCalendarChange: function () { |
| 12 | jQuery('#monthAjax').on('change', '#month', function() { |
| 13 | jQuery.blockUI({ |
| 14 | timeout: 1000, |
| 15 | }); |
| 16 | var display = jQuery('#display').val(); |
| 17 | var month = this.value; |
| 18 | jQuery.ajax({ |
| 19 | url: timetable_params.ajaxurl, |
| 20 | data: { |
| 21 | 'action':'get_monthly_timetable', |
| 22 | 'month' : month, |
| 23 | 'display': display |
| 24 | }, |
| 25 | success: function(response){ |
| 26 | jQuery('#monthlyTimetable').html(response); |
| 27 | }, |
| 28 | error: function(errorThrown){ |
| 29 | alert(JSON.stringify(errorThrown)); |
| 30 | } |
| 31 | }); |
| 32 | }); |
| 33 | |
| 34 | jQuery('#month').trigger('change'); |
| 35 | }, |
| 36 | |
| 37 | digitalScreenCheckChange: function () { |
| 38 | var sliderChbox = jQuery("input#slider-chbox"); |
| 39 | |
| 40 | sliderChbox.on('click', function() { |
| 41 | jQuery(".ds-slides").toggle(); |
| 42 | }); |
| 43 | |
| 44 | if (! sliderChbox.is(':checked')) { |
| 45 | jQuery(".ds-slides").hide(); |
| 46 | } |
| 47 | }, |
| 48 | |
| 49 | changeInputBackground: function () { |
| 50 | jQuery("input").on('change', function() { |
| 51 | jQuery(this).css("background-color","#F6F8CE"); |
| 52 | }); |
| 53 | }, |
| 54 | |
| 55 | printDiv: function (divName) { |
| 56 | if (divName) { |
| 57 | var printContents = document.getElementById(divName).innerHTML; |
| 58 | var originalContents = document.body.innerHTML; |
| 59 | |
| 60 | document.body.innerHTML = printContents; |
| 61 | |
| 62 | window.print(); |
| 63 | |
| 64 | document.body.innerHTML = originalContents; |
| 65 | } |
| 66 | }, |
| 67 | |
| 68 | startTimer: function () { |
| 69 | var presentTime = ''; |
| 70 | if (document.getElementsByClassName('timeLeftCountDown')[0]) { |
| 71 | presentTime = document.getElementsByClassName('timeLeftCountDown')[0].innerHTML.trim(); |
| 72 | presentTime = presentTime.split(' ')[0]; |
| 73 | var timeArray = presentTime.split(/[:]+/); |
| 74 | if (timeArray && timeArray.length === 2) { |
| 75 | var m = timeArray[0]; |
| 76 | var s = DPT.checkSecond((timeArray[1] - 1)); |
| 77 | if(s==59){m=m-1} |
| 78 | if ( m >= 0) { |
| 79 | document.getElementsByClassName('timeLeftCountDown')[0].innerHTML = |
| 80 | m + ":" + s; |
| 81 | setTimeout(DPT.startTimer, 1000); |
| 82 | if(m == 0 && s == 0) { |
| 83 | document.getElementsByClassName('timeLeftCountDown')[0].innerHTML = ""; |
| 84 | document.getElementsByClassName('timeLeft')[1].innerHTML = ""; |
| 85 | location.reload(); |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | } |
| 90 | }, |
| 91 | |
| 92 | checkSecond: function (sec) { |
| 93 | if (sec < 10 && sec >= 0) {sec = "0" + sec}; // add zero in front of numbers < 10 |
| 94 | if (sec < 0) {sec = "59"}; |
| 95 | return sec; |
| 96 | }, |
| 97 | |
| 98 | bs3screenOptions: function( ) { |
| 99 | jQuery("#contextual-help-link").click(function () { |
| 100 | jQuery("#contextual-help-wrap").css("cssText", "display: block !important;"); |
| 101 | }); |
| 102 | jQuery("#show-settings-link").click(function () { |
| 103 | jQuery("#screen-options-wrap").css("cssText", "display: block !important;"); |
| 104 | }); |
| 105 | } |
| 106 | }; |
| 107 | jQuery(document).ready(function() { DPT.init(); }); |
| 108 | |
| 109 |