# HG changeset patch
# User Dan
# Date 1229895663 18000
# Node ID 609e35845ec30737e72eb9882687e10cc4cecf75
# Parent 57ce13805b6f1c6048847c1682c1775c23ba491a
load_component() now accepts an array, and most JS components are loaded all in one request now. Totally modular baby. And failsafe too.
diff -r 57ce13805b6f -r 609e35845ec3 includes/clientside/jsres.php
--- a/includes/clientside/jsres.php Sun Dec 21 16:28:00 2008 -0500
+++ b/includes/clientside/jsres.php Sun Dec 21 16:41:03 2008 -0500
@@ -185,16 +185,38 @@
{
// requested a single file
$js_file =& $_GET['f'];
- if ( !preg_match('/^[a-z0-9_-]+\.js$/i', $js_file) )
+ if ( strstr($js_file, ',') )
{
- header('HTTP/1.1 404 Not Found');
- exit('Not found');
+ $filelist = explode(',', $js_file);
+ unset($js_file);
+ $everything = '';
+ foreach ( $filelist as $js_file )
+ {
+ if ( !preg_match('/^[a-z0-9_-]+\.js$/i', $js_file) )
+ {
+ header('HTTP/1.1 404 Not Found');
+ exit('Not found');
+ }
+
+ $apex = filemtime("includes/clientside/static/$js_file");
+
+ $file_contents = file_get_contents("includes/clientside/static/$js_file");
+ $everything .= jsres_cache_check($js_file, $file_contents) . ' loaded_components[\'' . $js_file . '\'] = true;';
+ }
}
-
- $apex = filemtime("includes/clientside/static/$js_file");
-
- $file_contents = file_get_contents("includes/clientside/static/$js_file");
- $everything = jsres_cache_check($js_file, $file_contents);
+ else
+ {
+ if ( !preg_match('/^[a-z0-9_-]+\.js$/i', $js_file) )
+ {
+ header('HTTP/1.1 404 Not Found');
+ exit('Not found');
+ }
+
+ $apex = filemtime("includes/clientside/static/$js_file");
+
+ $file_contents = file_get_contents("includes/clientside/static/$js_file");
+ $everything = jsres_cache_check($js_file, $file_contents) . ' loaded_components[\'' . $js_file . '\'] = true;';
+ }
}
else
{
@@ -294,7 +316,7 @@
{
if ( $cache_file['md5'] === $file_md5 )
{
- header("X-Cache-Status: cache HIT, hash $file_md5");
+ @header("X-Cache-Status: cache HIT, hash $file_md5");
$loaded_cache = true;
$file_contents = $cache_file['src'];
}
@@ -316,16 +338,16 @@
));
fwrite($handle, $payload);
fclose($handle);
- header("X-Cache-Status: cache MISS, new generated");
+ @header("X-Cache-Status: cache MISS, new generated");
}
else
{
- header("X-Cache-Status: cache MISS, not generated");
+ @header("X-Cache-Status: cache MISS, not generated");
}
}
else if ( !$loaded_cache )
{
- header("X-Cache-Status: cache MISS, not generated");
+ @header("X-Cache-Status: cache MISS, not generated");
}
return $file_contents;
diff -r 57ce13805b6f -r 609e35845ec3 includes/clientside/static/acl.js
--- a/includes/clientside/static/acl.js Sun Dec 21 16:28:00 2008 -0500
+++ b/includes/clientside/static/acl.js Sun Dec 21 16:41:03 2008 -0500
@@ -9,11 +9,7 @@
if(IE)
return true;
- load_component('l10n');
- load_component('messagebox');
- load_component('fadefilter');
- load_component('template-compiler');
- load_component('autofill');
+ load_component(['l10n', 'messagebox', 'fadefilter', 'template-compiler', 'autofill', 'jquery', 'jquery-ui']);
if(!page_id || !namespace)
{
@@ -58,11 +54,7 @@
function ajaxOpenDirectACLRule(rule_id)
{
- load_component('l10n');
- load_component('messagebox');
- load_component('fadefilter');
- load_component('template-compiler');
- load_component('autofill');
+ load_component(['l10n', 'messagebox', 'fadefilter', 'template-compiler', 'autofill']);
var params = {
target_id: rule_id,
diff -r 57ce13805b6f -r 609e35845ec3 includes/clientside/static/ajax.js
--- a/includes/clientside/static/ajax.js Sun Dec 21 16:28:00 2008 -0500
+++ b/includes/clientside/static/ajax.js Sun Dec 21 16:41:03 2008 -0500
@@ -78,8 +78,7 @@
return true;
// updated - 1.1.4 to use miniPrompt
- load_component('l10n');
- load_component('messagebox');
+ load_component(['l10n', 'messagebox', 'flyin', 'fadefilter']);
miniPrompt(ajaxRenameConstructDialog);
}
@@ -221,10 +220,7 @@
// IE <6 pseudo-compatibility
if ( KILL_SWITCH )
return true;
- load_component('l10n');
- load_component('messagebox');
- load_component('jquery');
- load_component('jquery-ui');
+ load_component(['l10n', 'messagebox', 'jquery', 'jquery-ui', 'fadefilter', 'flyin']);
// stage 1: prompt for reason and confirmation
miniPrompt(function(parent)
@@ -409,8 +405,7 @@
window.ajaxDelVote = function()
{
- load_component('l10n');
- load_component('messagebox');
+ load_component(['l10n', 'messagebox', 'flyin', 'fadefilter']);
// IE <6 pseudo-compatibility
if ( KILL_SWITCH )
@@ -450,8 +445,7 @@
window.ajaxResetDelVotes = function()
{
- load_component('l10n');
- load_component('messagebox');
+ load_component(['l10n', 'messagebox', 'flyin', 'fadefilter']);
// IE <6 pseudo-compatibility
if ( KILL_SWITCH )
@@ -619,8 +613,7 @@
if ( KILL_SWITCH )
return true;
- load_component('l10n');
- load_component('messagebox');
+ load_component(['l10n', 'messagebox', 'flyin', 'fadefilter']);
miniPromptMessage({
title: $lang.get('ajax_clearlogs_confirm_title'),
@@ -745,8 +738,7 @@
// IE <6 pseudo-compatibility
if ( KILL_SWITCH )
return true;
- load_component('l10n');
- load_component('messagebox');
+ load_component(['l10n', 'messagebox', 'flyin', 'fadefilter']);
var inner_html = '';
inner_html += '