« MediaWiki:Common-IntersectionCategorie.js » : différence entre les versions

Contenu supprimé Contenu ajouté
Phe (discussion | contributions)
mAucun résumé des modifications
Phe (discussion | contributions)
m sélectionner pour montrer le requête en cours
Ligne 58 :
add_dpl_result_to_page : function (datas) {
$("#bodyContent").html($("#bodyContent").html() + datas.parse.text["*"]);
var cat = [];
var nocat = [];
this.cat_from_string(location.search, cat, nocat);
if (cat.length)
this.set_selected(cat);
},
 
Ligne 72 ⟶ 77 :
exec_user_query : function () {
var cat = []
$("select#select_cat option:selected").each(function () {
cat.push($(this).text());
});
Ligne 80 ⟶ 85 :
},
 
build_listbox : function (categoriescat) {
var text = "<select name='select_cat' id='select_cat' size='8' multiple='multiple'>\n";
for (var i = 0; i < categoriescat.length; ++i)
text += "<option value='" + i + "'>" + categoriescat[i] + "</option>";
return text + "</select>" + "<button type='button' onclick='intersection_categorie.exec_user_query()'>Exécuter la requête</button>";
},
 
build_dpl_query : function (categoriescat, not_categoriesnot_cat) {
var text = "<DynamicPageList>count = 50\norder = sortkey\nshownamespace = false";
for (var i = 0; i < categoriescat.length; ++i)
text += "\ncategory = " + categoriescat[i].replace(' ', '_');
for (var i = 0; i < not_categoriesnot_cat.length; ++i)
text += "\nnotcategory = " + not_categoriesnot_cat[i].replace(' ', '_');
return text + "\n</DynamicPageList>";
},
 
dpl_query : function (categoriescat, not_categoriesnot_cat) {
var query = this.build_dpl_query(categoriescat, not_categoriesnot_cat);
var url = mw.config.get("wgServer") + mw.config.get("wgScriptPath")
+ "/api.php?action=parse&callback=intersection_categorie.add_dpl_result_to_page"
Ligne 111 ⟶ 116 :
},
 
query_from_stringset_selected : function (strcat) {
// str can be from location.search or a simple string ala
for (var i = 0 ; i < cat.length; ++i) {
// &cat=cat1&cat=cat2&nocat=cat3
for (var j = 0 ; j < this.possible_category.length; ++j) {
query_from_string : function (str) {
if (cat[i].replace('_', ' ') == this.possible_category[j])
$("#select_cat option[value=" + j + "]").attr("selected", "selected");
}
}
},
 
cat_from_string : function (str, cat, nocat) {
if (str.charAt[0] = "?")
str = str.slice(1);
var params = str.split("&");
var cat = [];
var nocat = [];
for (var i = 0; i < params.length; ++i) {
var key_value = params[i].split("=");
Ligne 128 ⟶ 138 :
}
}
},
 
query_from_url : function () {
var cat = [];
var nocat = [];
this.cat_from_string(location.search, cat, nocat);
if (cat.length)
this.dpl_query(cat, nocat);
Ligne 137 ⟶ 153 :
$("title").text("Spécial:Intersection de catégorie")
$("#bodyContent").html(this.build_listbox(this.possible_category));
this.query_from_stringquery_from_url(location.search);
}
}