« MediaWiki:Common-IntersectionCategorie.js » : différence entre les versions
Contenu supprimé Contenu ajouté
m sélectionner pour montrer le requête en cours |
mAucun résumé des modifications |
||
Ligne 1 :
/*
* Utilise http://www.mediawiki.org/wiki/Extension:DynamicPageList_(Wikimedia)
* pour présenter
* sur http://fr.wikisource.org/wiki/Spécial:Intersection_de_catégorie
*/
var intersection_categorie = {
// TODO : la liste des catégories ne devrait pas être codée en dur
// dans le script,
// racine dont le premier (et deuxième ?) niveau de sous-catégories
// sont de bons candidats à
//"Page à problème",
//"Page corrigée",
Ligne 26 :
"Bibliothécaires",
"Diplomates",
"Historiens",
"Personnalités politiques",
"Philologues",
Ligne 55 ⟶ 56 :
"Économistes"
],
possible_article_category : [
"Anthropologie",
"Archéologie",
"Démographie",
"Économie",
"Éducation",
"Ethnologie",
"Géographie",
"Histoire",
"Histoire de l'art",
"Linguistique",
"Philologie",
"Psychologie",
"Science politique",
"Sciences de l'information et des bibliothèques",
"Sociologie",
"Agriculture",
"Mécanique",
"Médecine",
"Logique",
"Mathématiques",
"Philosophie des sciences",
"Bouddhisme",
"Christianisme",
"Ésotérisme",
"Hindouisme",
"Islam",
"Jaïnisme",
"Judaïsme",
"Libre pensée",
"Mythologie",
"Nihilisme",
"Religieux",
"Religion celtique",
"Religion grecque antique",
"Spiritualité",
"Taoïsme",
"Théologie",
"Contes philosophiques",
"Cours de philosophie",
"Esthétique",
"Histoire de la philosophie",
"Logique",
"Morale",
"Métaphysique",
"Philosophes",
"Philosophie analytique",
"Philosophie chinoise",
"Philosophie de la religion",
"Philosophie des sciences",
"Philosophie du droit",
"Philosophie politique",
"Revue de métaphysique et de morale",
"Scepticisme",
"Stoïcisme",
"Œuvres de Platon",
"Canulars littéraires",
"Courants littéraires",
"Dictionnaires",
"Genres littéraires",
"Littératures non francophones",
"Prix littéraire",
"Droit",
"Politique",
"Architecture",
"Critiques d'art",
"Esthétique",
"Histoire de l'art",
"Illustrateurs",
"Musique",
"00%",
"25%",
"50%",
"75%",
"100%"
],
// FIXME possible_intersection and get_cat() : there is surely a more
// elegant way to do that.
// définition des possibilités d’intersections par groupe.
possible_intersection : [
"Intersection d’auteurs",
"Intersection d’articles",
],
get_cat : function () {
var text = $("#dropdown option:selected").text();
if (text == "Intersection d’auteurs")
return this.possible_author_category;
else if (text == "Intersection d’articles")
return this.possible_article_category;
return null;
},
add_dpl_result_to_page : function (datas) {
$("#
var cat = [];
var nocat = [];
this.cat_from_string(location.search, cat, nocat);
if (cat.length)
this.set_selected(cat, this.get_cat());
},
build_url : function (cat,
var url = mw.config.get("wgServer") + mw.config.get("wgScriptPath");
url += "/index.php?title=" + "Spécial:Intersection_de_catégorie";
for (var i = 0; i < cat.length; ++i)
url += "&cat=" + cat[i]
for (var i = 0; i <
url += "¬cat=" +
return url;
},
Ligne 89 ⟶ 185 :
for (var i = 0; i < cat.length; ++i)
text += "<option value='" + i + "'>" + cat[i] + "</option>";
return text + "</select>" + "<br /><button type='button' onclick='intersection_categorie.exec_user_query()'>Exécuter la requête</button>";
},
build_dpl_query : function (cat,
var text = "<DynamicPageList>count = 50\norder = sortkey\nshownamespace = false";
return text + "\n</DynamicPageList>";
},
dpl_query : function (cat,
var query = this.build_dpl_query(cat,
var url = mw.config.get("wgServer") + mw.config.get("wgScriptPath")
+ "/api.php?action=parse&callback=intersection_categorie.add_dpl_result_to_page"
Ligne 116 ⟶ 210 :
},
set_selected : function (cat, possible_cat) {
for (var i = 0 ; i < cat.length; ++i) {
for (var j = 0 ; j <
if (cat[i].replace(
$("#select_cat option[value=" + j + "]").attr("selected", "selected");
}
Ligne 133 ⟶ 227 :
if (key_value.length == 2) {
if (key_value[0] == "cat")
cat.push(decodeURIComponent(key_value[1]).replace("_", " "));
else if (key_value[0] == "nocat")
nocat.push(decodeURIComponent(key_value[1]).replace("_", " "));
}
}
Ligne 146 ⟶ 240 :
if (cat.length)
this.dpl_query(cat, nocat);
},
guess_cat_group_from_url : function() {
var cat = [];
var nocat = [];
this.cat_from_string(location.search, cat, nocat);
if (cat.length) {
for (var i = 0; i < this.possible_author_category.length; ++i) {
if (cat[0].replace("_", "") == this.possible_author_category[i])
return "Intersection d’auteurs";
}
for (var i = 0; i < this.possible_article_category.length; ++i) {
if (cat[0].replace("_", "") == this.possible_article_category[i])
return "Intersection d’articles";
}
}
return this.possible_intersection[0];
},
dropdown_change : function() {
$("#input_listbox").html(this.build_listbox(this.get_cat()));
},
add_dropdown_list : function () {
var html = "<select id='dropdown' onchange='intersection_categorie.dropdown_change()''>";
for (var i = 0; i < this.possible_intersection.length; ++i)
html += "\n<option value='" + this.possible_intersection[i] + "'>" + this.possible_intersection[i] + "</option>";
html += "\n</select><br />";
$("#input_cat").html(html);
$("#dropdown").val(this.guess_cat_group_from_url());
$("#dropdown").change();
},
setup : function () {
$("#firstHeading").text("Intersection de catégorie");
$("#bodyContent
$("title").text("Spécial:Intersection de catégorie");
this.query_from_url();
}
|