You are here

function mcd_js_countdown in Maintenance Countdown 7

Same name and namespace in other branches
  1. 6 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. You can override this or core or add custom variables via your theme just using the same TEMPLATE_preprocess_maintenance_page

File

./mcd.countdown.inc, line 30
This file provides theme part of MCD module

Code

function mcd_js_countdown() {

  //  get stoptime like 1315776380
  $stoptime = variable_get('mcd_stoptime');
  $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") . ", 'month': " . format_date($stoptime, 'custom', "n") . ", 'year': " . format_date($stoptime, 'custom', "Y") . ", 'hour': " . format_date($stoptime, 'custom', "G") . ", 'min': " . format_date($stoptime, 'custom', "i") . ", 'sec': " . format_date($stoptime, 'custom', "s") . ", 'utc': '" . format_date($stoptime, 'custom', "O") . "'}";
  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()});";
  }

  // close function
  $output .= "\$('#countdown_dashboard2').startCountDown();";
  $output .= "});";
  return $output;
}