Difference between revisions of "Template:Main2021"

Line 2,613: Line 2,613:
  
 
 
 
+
////////////////////////////////////////////////////////////
+
+
//if there is a time zone converter
+
if(  $(".date_timezone").length > 0 ){
+
+
 
+
         
+
//global variables
+
var hold_all_dates = [];
+
var date_counter = 0;
+
 
+
 
+
//grab original dates
+
var grab_date;
+
var date_array;
+
+
//change dates to Boston timezone and collect all dates into a global variable
+
$('.date_timezone').each(function(i, obj) {
+
 
+
//get the date
+
grab_date = $(this).html();
+
+
//change date to a number array
+
date_array = grab_date.split(',').map(Number);
+
+
//create an id for that specific date, we will use this later to append
+
$(this).attr('id', 'dt_'+date_counter);
+
+
//add to global variables
+
hold_all_dates[date_counter]=date_array;
+
date_counter++;
+
+
//clean the div and have it ready for the change
+
$(this).empty();
+
+
//now append that date in Boston time:
+
$(this).append(change_time_zone(date_array[0],date_array[1],date_array[2],date_array[3],0));
+
 
+
});
+
+
 
+
//setup timezone select
+
var select_is_ready = false;
+
+
// DAYLIGHT SAVINGS TIME
+
select_is_ready = time_zone_dropdown('winter');
+
+
//once timezone is ready, allow user to change time zones
+
if(select_is_ready){
+
//if the user wants to change the timezone
+
$("#timezone_converter").on("change", function(e) {
+
+
//get the timezone requested
+
var timezone_selected = $(this).val();
+
var time_difference = parseInt(timezone_selected);
+
 
+
+
//empty all timezones getting ready for appending
+
$('.date_timezone').empty();
+
+
//get each date_timezone by number id
+
for(x=0; x< date_counter; x++){
+
+
$('#dt_'+x).append(change_time_zone(hold_all_dates[x][0],
+
hold_all_dates[x][1],
+
hold_all_dates[x][2],
+
hold_all_dates[x][3],
+
time_difference));
+
+
}
+
 
+
});
+
+
}
+
else{
+
console.log('error with appending timezone select');
+
}
+
 
+
}
+
+
+
////////////////////////////////////////////////////////////
+
 
//TIME ZONE CONVERTER
 
//TIME ZONE CONVERTER
 
 
Line 3,000: Line 2,918:
 
 
 
//time zones
 
//time zones
if($("#timezone_select").length){
+
//if there is a time zone converter
 +
if(   $(".date_timezone").length ){
 +
 +
 
 +
         
 
//global variables
 
//global variables
 
var hold_all_dates = [];
 
var hold_all_dates = [];
Line 3,044: Line 2,966:
 
if(select_is_ready){
 
if(select_is_ready){
 
//if the user wants to change the timezone
 
//if the user wants to change the timezone
$("#timezone_select").on("change", function(e) {
+
$("#timezone_converter").on("change", function(e) {
 
 
 
//get the timezone requested  
 
//get the timezone requested  
Line 3,074: Line 2,996:
 
}
 
}
 
 
 +
 
 
 
//navigation support
 
//navigation support

Revision as of 17:12, 22 April 2021