function mcd_js_countdown in Maintenance Countdown 6
Same name and namespace in other branches
- 7 mcd.countdown.inc \mcd_js_countdown()
Generate the jQuery output
1 call to mcd_js_countdown()
- mcd_preprocess_maintenance_page in ./
mcd.countdown.inc - Add some variables for maintenance-coundown-page.tpl.php file.
File
- ./
mcd.countdown.inc, line 24 - This file will be processed if time is set
Code
function mcd_js_countdown() {
// get stoptime like 1315776380
$stoptime = variable_get('mcd_stoptime', NULL);
$mcd_message = variable_get('mcd_time_up_message', FALSE);
$mcd_reload = variable_get('mcd_reload_button', 0);
// jQuery script for countdown initialization
$output = "jQuery(document).ready(function(\$) {\$('#countdown_dashboard').countDown({targetDate: {";
$output .= "'day': " . format_date($stoptime, 'custom', 'j') . ", ";
$output .= "'month': " . format_date($stoptime, 'custom', 'n') . ", ";
$output .= "'year': " . format_date($stoptime, 'custom', 'Y') . ", ";
$output .= "'hour': " . format_date($stoptime, 'custom', 'G') . ", ";
$output .= "'min': " . format_date($stoptime, 'custom', 'i') . ", ";
$output .= "'sec': " . format_date($stoptime, 'custom', 's') . ", ";
$output .= "'utc': '" . format_date($stoptime, 'custom', 'O') . "'";
$output .= "}";
if ($mcd_message || $mcd_reload != 1) {
$output .= ", onComplete: function() {";
// slide down 'time is up' message or 'Reload' button
if ($mcd_message || $mcd_reload == 0) {
$output .= " \$('#complete_message').slideDown();";
}
if ($mcd_reload == 2) {
$output .= " setTimeout(function() {location.reload();}, 15000)";
}
$output .= "}";
}
// close countDown
$output .= "});";
// reload current page by clicking 'Reload' button
if (variable_get('mcd_reload_button', 0) == 0) {
$output .= " \$('#page_reload').click(function() {location.reload()});";
}
$output .= "";
// close function
$output .= "});";
return $output;
}