You are here

function jstimer_clean_for_javascript in Javascript Timer 6

Same name and namespace in other branches
  1. 8 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.

1 call to jstimer_clean_for_javascript()
jst_timer_jstwidget in widgets/jst_timer.module
Implementation of hook_jstwidget().

File

./jstimer.module, line 166
A module which creates javascript timed dhtml things.

Code

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