更多操作
无编辑摘要 |
无编辑摘要 |
||
第76行: | 第76行: | ||
console.log(titles[i]) | console.log(titles[i]) | ||
// var parser = get_parser_output(titles[i]) | // var parser = get_parser_output(titles[i]) | ||
div2.innerHTML = '<a href="/dic/'+ | div2.innerHTML = '<a href="/dic/'+titles[i]+'"><h3>'+titles[i]+'</h3></a>' | ||
console.log( '<a href="/dic/"+title[i]+"><h3>"+title[i]+"</h3></a>"') | console.log( '<a href="/dic/"+title[i]+"><h3>"+title[i]+"</h3></a>"') | ||
div.appendChild(div2); | div.appendChild(div2); |
2021年10月19日 (二) 09:57的版本
/* 这里的任何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 >= 10){
titleList.splice(10,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>")
console.log(output1)
output2 = output1[0] + "</p>" + output1[1]+"</p>"+ output1[3]
output2 += "<a href=" + title +">查看详情>>></a>"
}
});
// $.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 = '<a href="/dic/'+titles[i]+'"><h3>'+titles[i]+'</h3></a>'
console.log( '<a href="/dic/"+title[i]+"><h3>"+title[i]+"</h3></a>"')
div.appendChild(div2);
}
}
div = document.getElementById("latestpages")
div.onload = insertEntries()