mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/CategoryTree
synced 2024-11-30 19:16:15 +00:00
* (bug 11015) Handle HTTP errors for CategoryTree ajax request more gracefully. Instead of dumping the entire error page's HTML inline, display a nice clean bit of text with a functional retry link.
* Added $wgCategoryTreeVersion variable to bump JS and CSS URLs on update
This commit is contained in:
parent
b6181e71b5
commit
d0b1db56b4
|
@ -33,6 +33,8 @@ $messages['categorytree-nothing-found']= 'nothing found';
|
|||
$messages['categorytree-no-subcategories']= 'no subcategories';
|
||||
$messages['categorytree-no-pages']= 'no pages or subcategories';
|
||||
$messages['categorytree-not-found']= "Category <i>$1</i> not found";
|
||||
$messages['categorytree-error'] = 'Problem loading data.';
|
||||
$messages['categorytree-retry'] = 'Please wait a moment and try again.';
|
||||
|
||||
$messages['categorytree-show-list'] = "Show as list";
|
||||
$messages['categorytree-show-tree'] = "Show as tree";
|
||||
|
|
|
@ -8,7 +8,11 @@
|
|||
* @copyright © 2006 Daniel Kinzler
|
||||
* @licence GNU General Public Licence 2.0 or later
|
||||
*/
|
||||
|
||||
|
||||
// Default messages if new code loaded with old cached page
|
||||
var categoryTreeErrorMsg = "Problem loading data.";
|
||||
var categoryTreeRetryMsg = "Please wait a moment and try again.";
|
||||
|
||||
function categoryTreeNextDiv(e) {
|
||||
var n= e.nextSibling;
|
||||
while ( n && ( n.nodeType != 1 || n.nodeName != 'DIV') ) {
|
||||
|
@ -55,10 +59,19 @@
|
|||
div.innerHTML= '<i class="CategoryTreeNotice">' + categoryTreeLoadingMsg + '</i>';
|
||||
|
||||
function f( request ) {
|
||||
if (request.status != 200) {
|
||||
div.innerHTML = '<i class="CategoryTreeNotice">' + categoryTreeErrorMsg + ' </i>';
|
||||
var retryLink = document.createElement('a');
|
||||
retryLink.innerHTML = categoryTreeRetryMsg;
|
||||
retryLink.onclick = function() {
|
||||
categoryTreeLoadChildren(cat, mode, div);
|
||||
}
|
||||
div.appendChild(retryLink);
|
||||
return;
|
||||
}
|
||||
|
||||
result= request.responseText;
|
||||
result= result.replace(/^\s+|\s+$/, '');
|
||||
|
||||
if (request.status != 200) result= "<div class='error'> " + request.status + " " + request.statusText + ": " + result + "</div>";
|
||||
|
||||
if ( result == '' ) {
|
||||
result= '<i class="CategoryTreeNotice">';
|
||||
|
|
|
@ -51,6 +51,7 @@ $wgCategoryTreeMaxDepth = array(CT_MODE_PAGES => 1, CT_MODE_ALL => 1, CT_MODE_CA
|
|||
$wgCategoryTreeExtPath = '/extensions/CategoryTree';
|
||||
$wgCategoryTreeDefaultMode = CT_MODE_CATEGORIES;
|
||||
$wgCategoryTreeCategoryPageMode = CT_MODE_CATEGORIES;
|
||||
$wgCategoryTreeVersion = '1';
|
||||
|
||||
/**
|
||||
* Register extension setup hook and credits
|
||||
|
|
|
@ -23,7 +23,7 @@ class CategoryTree {
|
|||
* @param OutputPage $outputPage
|
||||
*/
|
||||
static function setHeaders( &$outputPage ) {
|
||||
global $wgJsMimeType, $wgScriptPath, $wgContLang, $wgCategoryTreeExtPath;
|
||||
global $wgJsMimeType, $wgScriptPath, $wgContLang, $wgCategoryTreeExtPath, $wgCategoryTreeVersion;
|
||||
efInjectCategoryTreeMessages();
|
||||
|
||||
# Register css file for CategoryTree
|
||||
|
@ -31,7 +31,7 @@ class CategoryTree {
|
|||
array(
|
||||
'rel' => 'stylesheet',
|
||||
'type' => 'text/css',
|
||||
'href' => $wgScriptPath . $wgCategoryTreeExtPath . '/CategoryTree.css'
|
||||
'href' => "$wgScriptPath$wgCategoryTreeExtPath/CategoryTree.css?$wgCategoryTreeVersion",
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -41,14 +41,14 @@ class CategoryTree {
|
|||
array(
|
||||
'rel' => 'stylesheet',
|
||||
'type' => 'text/css',
|
||||
'href' => $wgScriptPath . $wgCategoryTreeExtPath . '/CategoryTree.rtl.css'
|
||||
'href' => "$wgScriptPath$wgCategoryTreeExtPath/CategoryTree.rtl.css?$wgCategoryTreeVersion"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
# Register main js file for CategoryTree
|
||||
$outputPage->addScript(
|
||||
"<script type=\"{$wgJsMimeType}\" src=\"{$wgScriptPath}{$wgCategoryTreeExtPath}/CategoryTree.js\">" .
|
||||
"<script type=\"{$wgJsMimeType}\" src=\"{$wgScriptPath}{$wgCategoryTreeExtPath}/CategoryTree.js?{$wgCategoryTreeVersion}\">" .
|
||||
"</script>\n"
|
||||
);
|
||||
|
||||
|
@ -62,6 +62,8 @@ class CategoryTree {
|
|||
var categoryTreeNothingFoundMsg = \"".Xml::escapeJsString(self::msg('nothing-found'))."\";
|
||||
var categoryTreeNoSubcategoriesMsg = \"".Xml::escapeJsString(self::msg('no-subcategories'))."\";
|
||||
var categoryTreeNoPagesMsg = \"".Xml::escapeJsString(self::msg('no-pages'))."\";
|
||||
var categoryTreeErrorMsg = \"".Xml::escapeJsString(self::msg('error'))."\";
|
||||
var categoryTreeRetryMsg = \"".Xml::escapeJsString(self::msg('retry'))."\";
|
||||
</script>\n"
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue