Factor out code for generating JS inclusion.

This commit is contained in:
Michal Čihař
2011-02-08 09:25:27 +01:00
parent b694a590dd
commit 1208ed935f
2 changed files with 16 additions and 5 deletions

View File

@@ -673,4 +673,19 @@ function PMA_linkURL($url) {
return './url.php?url=' . $url; return './url.php?url=' . $url;
} }
} }
/**
* Returns HTML code to include javascript file.
*
* @param string $url Location of javascript, relative to js/ folder.
*
* @return string HTML code for javascript inclusion.
*/
function PMA_includeJS($url) {
if (strpos($js_script_file, '?') === FALSE) {
return '<script src="./js/' . $js_script_file . '?ts=' . filemtime('./js/' . $js_script_file) . '" type="text/javascript"></script>' . "\n";
} else {
return '<script src="./js/' . $js_script_file . '" type="text/javascript"></script>' . "\n";
}
}
?> ?>

View File

@@ -47,11 +47,7 @@ $GLOBALS['js_include'][] = 'messages.php' . PMA_generate_common_url($params);
// avoid loading twice a js file // avoid loading twice a js file
$GLOBALS['js_include'] = array_unique($GLOBALS['js_include']); $GLOBALS['js_include'] = array_unique($GLOBALS['js_include']);
foreach ($GLOBALS['js_include'] as $js_script_file) { foreach ($GLOBALS['js_include'] as $js_script_file) {
if (strpos($js_script_file, '?') === FALSE) { echo PMA_includeJS($js_script_file);
echo '<script src="./js/' . $js_script_file . '?ts=' . filemtime('./js/' . $js_script_file) . '" type="text/javascript"></script>' . "\n";
} else {
echo '<script src="./js/' . $js_script_file . '" type="text/javascript"></script>' . "\n";
}
} }
?> ?>
<script type="text/javascript"> <script type="text/javascript">