You are here

function jstimer_build_js_cache in Javascript Timer 7

Same name and namespace in other branches
  1. 8 jstimer.module \jstimer_build_js_cache()
  2. 6 jstimer.module \jstimer_build_js_cache()

create the timer.js file and put it in the files/jstimer directory.

Return value

string The full path of the file.

3 calls to jstimer_build_js_cache()
jstimer_admin_settings_submit in ./jstimer.admin.inc
jst_clock_enable in widgets/jst_clock.module
Implementation of hook_enable().
jst_timer_enable in widgets/jst_timer.module
Implementation of hook_enable().

File

./jstimer.module, line 171

Code

function jstimer_build_js_cache() {

  // Create the files/jstimer
  $path = 'public://jstimer';
  file_prepare_directory($path, FILE_CREATE_DIRECTORY);
  $data = jstimer_get_javascript(TRUE);
  file_save_data($data, $path . '/timer.js', FILE_EXISTS_REPLACE);
  drupal_set_message(t('Countdown Timer javascript file saved to: ') . $path . '/timer.js');
  if (!file_exists($path . '/timer.js')) {
    drupal_set_message(t('File Create Error: timer.js could not be created'), 'error');
  }
  else {
    variable_set('jstimer_timerjs_path', $path . '/timer.js');
  }
  return $path . '/timer.js';
}