更多操作
无编辑摘要 |
无编辑摘要 |
||
第39行: | 第39行: | ||
function get_parser_output(title){ | function get_parser_output(title){ | ||
var output | var output | ||
var output2 | |||
var url = 'http://www.wmuwiki.com/dic/api.php' | var url = 'http://www.wmuwiki.com/dic/api.php' | ||
var PARAMS={ | var PARAMS={ | ||
第56行: | 第57行: | ||
var output1 = output.split("<h3>")[0] + '<div style="height:10px;"></div></div></div>' | var output1 = output.split("<h3>")[0] + '<div style="height:10px;"></div></div></div>' | ||
output1 = output1.split("</p>") | output1 = output1.split("</p>") | ||
output2 = output1[0] + "</p>" + output1[1]+"</p>"+ output1[3] | |||
} | } | ||
}); | }); |
2021年9月18日 (六) 16:33的版本
/* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */
function oldest_page(test){
var titleList = []
$.ajax(
{
url: "http://www.wmuwiki.com/dic/api.php?action=query&format=json&list=recentchanges&utf8=1&rcnamespace=0&rctype=edit%7Cnew%7Clog%7Ccategorize&rctoponly=1",
method: "post",
async: false,
beforeSend: function (xhr) {
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
},
success: function (data) {
var data1 = data.query.recentchanges
for (var i = 0; i < data1.length; i++) {
var name = data1[i].title
var reg = RegExp(/\/all/gi)
if(name=="首页"){
var c =0
}else if(name.match(reg)){
var c =0
}else{
titleList.push(name)
console.log(name)
}
}
var number = titleList.length
if(number >= 4){
titleList.splice(4,number)
}else {
number += 0
}
}
})
console.log(titleList)
return titleList
}
function get_parser_output(title){
var output
var output2
var url = 'http://www.wmuwiki.com/dic/api.php'
var PARAMS={
"action": "parse",
"format": "json",
"page": title,
"utf8": 1
}
$.ajax({
async: false,
type : "post",
url : url,
data : PARAMS,
datatype : 'json',
success : function(datas) {
output = datas.parse.text["*"]
var output1 = output.split("<h3>")[0] + '<div style="height:10px;"></div></div></div>'
output1 = output1.split("</p>")
output2 = output1[0] + "</p>" + output1[1]+"</p>"+ output1[3]
}
});
// $.post(url, PARAMS, async =false ,function(ac){
// output = ac.parse.text["*"]
// }
// )
return output2.substring(30,output.length)
}
function insertEntries(){
var titles = oldest_page()
var div = document.getElementById("latestpages");
console.log(titles.length)
for (var i = 0; i < titles.length; i++) {
var div2 = document.createElement("div");
console.log(titles[i])
var parser = get_parser_output(titles[i])
div2.innerHTML = parser
console.log(parser)
div.appendChild(div2);
}
}
div = document.getElementById("latestpages")
div.onload = insertEntries()