You are here

function jstimer_clean_for_javascript in Javascript Timer 8

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

scrub the format strings for things that make bad javascript.

Parameters

$format_string: String which needs to be cleaned.

Return value

string cleaned string which does not contain newlines, carrage returns, or single quotes.

2 calls to jstimer_clean_for_javascript()
jst_timer_get_js_formats in widgets/jst_timer.module
Get a javascript array encoded list of timer formats.
jst_timer_jstwidget in widgets/jst_timer.module
Implementation of hook_jstwidget().

File

./jstimer.module, line 104

Code

function jstimer_clean_for_javascript($format_string = '') {
  $patterns = array(
    '/\\n/',
    '/\\r/',
    '/\'/',
  );
  $replacements = array(
    '<br/>',
    '',
    '"',
  );
  return preg_replace($patterns, $replacements, $format_string);
}