Skip to content

Commit

Permalink
Cleaned up time dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
otrok7 committed Nov 19, 2024
1 parent a97eefd commit 9ef916c
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 193 deletions.
186 changes: 31 additions & 155 deletions admin/js/bmlt_meeting_list.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,4 @@
var s = document.getElementById('extra_meetings').options,
l = [],
d = '';
for(i = 0;i < s.length;i++) {
column = s[i].text.split(';');
for(j = 0;j < column.length;j++) {
if(!l[j]) {
l[j] = 0;
}
if(column[j].length > l[j]) {
l[j] = column[j].length;
}
}
}
for(i = 0;i < s.length;i++) {
column = s[i].text.split(';');
temp_line = '';
for(j = 0;j < column.length;j++) {
t = (l[j] - column[j].length);
d = '\u00a0';
for(k = 0;k < t;k++) {
d += '\u00a0';
}
temp_line += column[j] + d;
}
s[i].text = temp_line;
}
var $ml = jQuery.noConflict
var $ml = jQuery.noConflict
jQuery(document).ready(
function($ml) {
$ml(".connecting").hide();
Expand Down Expand Up @@ -164,22 +137,6 @@ jQuery(document).ready(
}
}
);
$ml('#root-server-button').bind(
'click', function(e) {
e.preventDefault();
$ml('#root-server-video').bPopup(
{
transition: 'slideIn',
closeClass: 'b-close',
onClose: function() {
for(var player in mejs.players) {
mejs.players[player].media.stop();
}
}
}
);
}
);
$ml('.my-tooltip').each(function(i,e) {
$ml(e).tooltipster(
{
Expand Down Expand Up @@ -281,7 +238,6 @@ jQuery(document).ready(
);
$ml("#subgrouping").click(
function() {
var user_defined_sub = false;
$ml('.user_defined_headings').hide();
if($ml("#meeting_sort").val() === 'user_defined') {
$ml('.user_defined_headings').show();
Expand All @@ -293,105 +249,41 @@ jQuery(document).ready(
}
}
);
var time_clock_val = $ml('input[name=time_clock]:checked').val();
if(time_clock_val == '24') {
$ml('#option3').hide();
$ml('label[for=option3]').hide();
} else if(time_clock_val == '24fr') {
$ml('#option3').hide();
$ml('label[for=option3]').hide();
} else {
$ml('#option3').show();
$ml('label[for=option3]').show();
}
$ml("#two").click(
function() {
var time_clock_val = $ml('input[name=time_clock]:checked').val();
if(time_clock_val == '24') {
$ml('label[for=option1]').html('20:00');
$ml('label[for=option2]').html('20:00 - 21:00');
$ml('#option3').hide();
$ml('label[for=option3]').html('');
} else if(time_clock_val == '24fr') {
$ml('label[for=option1]').html('20h00');
$ml('label[for=option2]').html('20h00 - 21h00');
$ml('#option3').hide();
$ml('label[for=option3]').html('');
} else {
$ml('#option3').show();
$ml('label[for=option1]').html('8:00 PM');
$ml('label[for=option2]').html('8:00 PM - 9:00 PM');
$ml('label[for=option3]').html('8 - 9 PM');
}
function calcTimeDisplay(hasEndTime) {
let clock = $ml('input[name=time_clock]:checked').val();
let removeSpaces = $ml('input[name=remove_space]:checked').val()
let startTime = '8:00 PM';
let endTime = '9:00 PM';
if (clock == '24') {
startTime = '20:00';
endTime = '21:00';
} else if (clock == '24fr') {
startTime = '20h00';
endTime = '21h00';
}
);
$ml("#four").click(
function() {
var time_clock_val = $ml('input[name=time_clock]:checked').val();
if(time_clock_val == '24') {
$ml('label[for=option1]').html('20:00');
$ml('label[for=option2]').html('20:00-21:00');
$ml('#option3').hide();
$ml('label[for=option3]').html('');
} else if(time_clock_val == '24fr') {
$ml('#option3').hide();
$ml('label[for=option1]').html('20h00');
$ml('label[for=option2]').html('20h00-21h00');
$ml('#option3').hide();
$ml('label[for=option3]').html('');
} else {
$ml('#option3').show();
$ml('label[for=option1]').html('8:00PM');
$ml('label[for=option2]').html('8:00PM-9:00PM');
$ml('label[for=option3]').html('8-9PM');
}
if (hasEndTime==2) {
startTime += ' - '+endTime;
}
);
$ml("#time_clock12").click(
function() {
var remove_space_val = $ml('input[name=remove_space]:checked').val();
$ml('#option3').show();
$ml('label[for=option3]').show();
if(remove_space_val == '1') {
$ml('label[for=option1]').html('8:00PM');
$ml('label[for=option2]').html('8:00PM-9:00PM');
$ml('label[for=option3]').html('8-9PM');
} else {
$ml('label[for=option1]').html('8:00 PM');
$ml('label[for=option2]').html('8:00 PM - 9:00 PM');
$ml('label[for=option3]').html('8 - 9 PM');
}
if (hasEndTime==3) {
startTime = clock=='12' ? '8 - 9' : '';
}
);
$ml("#time_clock24").click(
function() {
var remove_space_val = $ml('input[name=remove_space]:checked').val();
$ml('#option3').hide();
$ml('label[for=option3]').html('');
if(remove_space_val == '1') {
$ml('label[for=option1]').html('20:00');
$ml('label[for=option2]').html('20:00-21:00');
} else {
$ml('label[for=option1]').html('20:00');
$ml('label[for=option2]').html('20:00 - 21:00');
}
if (removeSpaces!="0") {
startTime = startTime.replaceAll(' ','');
}
);
$ml("#time_clock24fr").click(
function() {
var remove_space_val = $ml('input[name=remove_space]:checked').val();
return startTime;
}
function setTimeOptionText() {
$ml('label[for=option1]').html(calcTimeDisplay(1));
$ml('label[for=option2]').html(calcTimeDisplay(2));
$ml('label[for=option3]').html(calcTimeDisplay(3));
if ($ml('input[name=time_clock]:checked').val()!='12') {
if ($ml('input[name=time_clock]:checked').val()==3)
$ml('#option2').prop('checked', true);
$ml('#option3').hide();
$ml('label[for=option3]').html('');
if(remove_space_val == '1') {
$ml('label[for=option1]').html('20h00');
$ml('label[for=option2]').html('20h00-21h00');
} else {
$ml('label[for=option1]').html('20h00');
$ml('label[for=option2]').html('20h00 - 21h00');
}
}
);
var page_fold_val = $ml('input[name=page_fold]:checked').val();
} else $ml('#option3').show();
};
setTimeOptionText();
$ml('.recalcTimeLabel').on('click', setTimeOptionText);
function bookletControlsShowHide() {
$ml('#landscape').prop("checked", true);
$ml('.booklet').show();
Expand Down Expand Up @@ -447,22 +339,6 @@ jQuery(document).ready(
$ml(".ctrl_key").hide();
}
);
/*
$ml("#extra_meetings").select2({
//tags: "true",
placeholder: "Select Meetings",
containerCssClass: 'tpx-select2-container select2-container-lg',
dropdownCssClass: 'tpx-select2-drop',
dropdownAutoWidth: true,
allowClear: true,
width: "100%",
/* dropdownParent: $ml('.exactCenter'), */
/* minimumResultsForSearch: 1, */
/* closeOnSelect: false, */
/* escapeMarkup: function (markup) { return markup; }
}).maximizeSelect2Height({cushion: 100});
$ml('.select2-choices').css('background-image','none').css('background-color','#111111 !important');
*/
$ml("#meeting-list-tabs").tabs(
{
active: 0
Expand Down
9 changes: 3 additions & 6 deletions admin/partials/_bmlt_server_setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,9 @@
<?php
if ($this->connected && Bread::getOption('extra_meetings_enabled') == 1) {
$extra_meetings_array = Bread_Bmlt::get_all_meetings();
foreach ($extra_meetings_array as $extra_meeting) {
$extra_meeting_x = explode('|||', $extra_meeting);
$extra_meeting_id = trim(Bread::arraySafeGet($extra_meeting_x, 3));
$extra_meeting_display = substr(Bread::arraySafeGet($extra_meeting_x), 0, 30) . ';' . Bread::arraySafeGet($extra_meeting_x, 1) . ';' . Bread::arraySafeGet($extra_meeting_x, 2); ?>
<option <?php echo (Bread::getOption('extra_meetings') != '' && in_array($extra_meeting_id, Bread::getOption('extra_meetings')) ? 'selected="selected"' : '') ?> value="<?php echo $extra_meeting_id ?>"><?php echo esc_html($extra_meeting_display) ?></option>
<?php
foreach ($extra_meetings_array as $id => $descr) {
$selected = Bread::getOption('extra_meetings') != '' && in_array($id, Bread::getOption('extra_meetings')) ? 'selected="selected"' : '';
echo "<option $selected value='$id'>$descr</option>";
}
} ?>
</select>
Expand Down
2 changes: 1 addition & 1 deletion admin/partials/_layout_setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
<div class="inside">
<div id="includeprotection" style="border-top: 1px solid #EEE;">
<input name="include_protection" value="0" type="hidden">
<input type="checkbox" name="include_protection" value="1" <?php echo (Bread::getOption('include_protection') == '1' ? 'checked' : '') ?>>
<input type="checkbox" name="include_protection" value="1" <?php echo (Bread::getOption('include_protection') == '1' ? 'checked' : '') ?>>Enable Protection
<div style="overflow: none; height: 0px;background: transparent;" data-description="dummyPanel for Chrome auto-fill issue">
<input type="text" style="height:0;width:0; background: transparent; color: transparent;border: none;" data-description="dummyUsername">
<input type="password" style="height:0;width:0;background: transparent; color: transparent;border: none;" data-description="dummyPassword">
Expand Down
34 changes: 6 additions & 28 deletions admin/partials/_meetings_setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,56 +236,34 @@
<div id="starttimeformatdiv" class="postbox">
<h3 class="hndle">Start Time Format<span title="Format the <strong>Start Time</strong> (start_time) field in the <strong>Meeting Template</strong>." class="my-tooltip"><span class="tooltipster-icon">(?)</span></span></h3>
<div class="inside">
<?php
$space = Bread::getOption('remove_space') == '1' ? '' : ' ';
$end_time_2 = "9" . $space . "PM";
$start_time_2 = "8" . $space;
if (Bread::getOption('time_clock') == '12') {
$start_time = "8:00" . $space . "PM";
$end_time = "9:00" . $space . "PM";
} elseif (Bread::getOption('time_clock') == '24fr') {
$start_time = "20h00";
$end_time = "21h00";
} else {
$start_time = "20:00";
$end_time = "21:00";
}
?>
<table>
<tr>
<td style="padding-right: 30px;">
<div><input class="mlg" id="time_clock12" type="radio" name="time_clock" value="12" <?php echo (Bread::getOption('time_clock') == '12' || Bread::getOption('time_clock') == '' ? 'checked' : '') ?>><label for="time_clock">12 Hour</label></div>
<div><input class="mlg recalcTimeLabel" id="time_clock12" type="radio" name="time_clock" value="12" <?php echo (Bread::getOption('time_clock') == '12' || Bread::getOption('time_clock') == '' ? 'checked' : '') ?>><label for="time_clock">12 Hour</label></div>
</td>
<td style="padding-right: 30px;">
<div><input class="mlg" id="option1" type="radio" name="time_option" value="1" <?php echo (Bread::getOption('time_option') == '1' || Bread::getOption('time_option') == '' ? 'checked' : '') ?>><label for="option1"><?php echo $start_time ?></label></div>
</td>
<td style="padding-right: 30px;">
<?php if (Bread::getOption('remove_space') == '0' || Bread::getOption('remove_space') == '') { ?>
<div><input class="mlg" id="two" type="radio" name="remove_space" value="0" checked><label for="two">Add White Space</label></div>
<?php } else { ?>
<div><input class="mlg" id="two" type="radio" name="remove_space" value="0"><label for="two">Add White Space</label></div>
<?php } ?>
<?php $checked = Bread::getOption('remove_space') == '0' || Bread::getOption('remove_space') == '' ? 'checked' : ''; ?>
<div><input class="mlg recalcTimeLabel" id="two" type="radio" name="remove_space" value="0" <?php echo $checked; ?>><label for="two">Add White Space</label></div>
</td>
</tr>
<tr>
<td style="padding-right: 30px;">
<div><input class="mlg" id="time_clock24" type="radio" name="time_clock" value="24" <?php echo (Bread::getOption('time_clock') == '24' ? 'checked' : '') ?>><label for="time_clock">24 Hour</label></div>
<div><input class="mlg recalcTimeLabel" id="time_clock24" type="radio" name="time_clock" value="24" <?php echo (Bread::getOption('time_clock') == '24' ? 'checked' : '') ?>><label for="time_clock">24 Hour</label></div>
</td>
<td style="padding-right: 30px;">
<div><input class="mlg" id="option2" type="radio" name="time_option" value="2" <?php echo (Bread::getOption('time_option') == '2' ? 'checked' : '') ?>><label for="option2"><?php echo $start_time ?><?php echo $space ?>-<?php echo $space ?><?php echo $end_time ?></label></div>
</td>
<td style="padding-right: 30px;">
<?php if (Bread::getOption('remove_space') == '1') { ?>
<div><input class="mlg" id="four" type="radio" name="remove_space" value="1" checked><label for="four">Remove White Space</label></div>
<?php } else { ?>
<div><input class="mlg" id="four" type="radio" name="remove_space" value="1"><label for="four">Remove White Space</label></div>
<?php } ?>
<div><input class="mlg recalcTimeLabel" id="four" type="radio" name="remove_space" value="1" <?php echo (Bread::getOption('remove_space') == '1') ? 'checked' : '';?>><label for="four">Remove White Space</label></div>
</td>
</tr>
</tr>
<tr>
<td style="padding-right: 30px;">
<div><input class="mlg" id="time_clock24fr" type="radio" name="time_clock" value="24fr" <?php echo (Bread::getOption('time_clock') == '24fr' ? 'checked' : '') ?>><label for="time_clock">24 Hour French</label></div>
<div><input class="mlg recalcTimeLabel" id="time_clock24fr" type="radio" name="time_clock" value="24fr" <?php echo (Bread::getOption('time_clock') == '24fr' ? 'checked' : '') ?>><label for="time_clock">24 Hour French</label></div>
</td>
<td style="padding-right: 30px;">
<div><input class="mlg" id="option3" type="radio" name="time_option" value="3" <?php echo (Bread::getOption('time_option') == '3' ? 'checked' : '') ?>><label for="option3"><?php echo $start_time_2 ?><?php echo $space ?>-<?php echo $space ?><?php echo $end_time_2 ?></label></div>
Expand Down
9 changes: 7 additions & 2 deletions includes/class-bread-bmlt.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ private static function get(string $url) : WP_Error | array
}
return wp_remote_get($url, $args);
}
public static function get_all_meetings()
/**
* Gets all the meetins in the root server as an array with id=>string. Used to select extra meetings.
*
* @return array
*/
public static function get_all_meetings(): array
{
$lang = Bread_Bmlt::get_bmlt_server_lang();
$result = Bread_Bmlt::get_configured_root_server_request("client_interface/json/?switcher=GetSearchResults&data_field_key=weekday_tinyint,start_time,service_body_bigint,id_bigint,meeting_name,location_text,email_contact&sort_keys=meeting_name,service_body_bigint,weekday_tinyint,start_time");
Expand All @@ -55,7 +60,7 @@ public static function get_all_meetings()
}

$value['start_time'] = date("g:iA", strtotime($value['start_time']));
$all_meetings[] = $value['meeting_name'].'||| ['.Bread::getday($value['weekday_tinyint'], true, $lang).'] ['.$value['start_time'].']||| ['.$area_name.']||| ['.$value['id_bigint'].']';
$all_meetings[$value['id_bigint']] = $value['meeting_name'].' - '.Bread::getday($value['weekday_tinyint'], true, $lang).' '.$value['start_time'].' in '.$area_name.' at '.$value['location_text'];
}

return $all_meetings;
Expand Down
2 changes: 1 addition & 1 deletion includes/class-bread.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ public static function getday($day, $abbreviate = false, $language = 'en')
if ($abbreviate) {
$key = "WKDYS";
}
return mb_convert_encoding(Bread::$instance->translate[$language][$key][$day], 'UTF-8', mb_list_encodings());
return Bread::$instance->translate[$language][$key][$day];
}
function fillUnsetOption($option, $default)
{
Expand Down

0 comments on commit 9ef916c

Please sign in to comment.