更多操作
无编辑摘要 |
小无编辑摘要 |
||
第11行: | 第11行: | ||
$.ajax( | $.ajax( | ||
{ | { | ||
url: "http://www.wmuwiki.com/ | url: "http://www.wmuwiki.com/medf/api.php?action=query&format=json&list=recentchanges&utf8=1&rcnamespace=0&rctype=edit%7Cnew%7Clog%7Ccategorize&rctoponly=1", | ||
method: "post", | method: "post", | ||
async: false, | async: false, | ||
第50行: | 第50行: | ||
var output | var output | ||
var output2 | var output2 | ||
var url = 'http://www.wmuwiki.com/ | var url = 'http://www.wmuwiki.com/medf/api.php' | ||
var PARAMS={ | var PARAMS={ | ||
"action": "parse", | "action": "parse", | ||
第87行: | 第87行: | ||
console.log(titles[i]) | console.log(titles[i]) | ||
// var parser = get_parser_output(titles[i][0]) | // var parser = get_parser_output(titles[i][0]) | ||
var div2html = '<a href="/ | var div2html = '<a href="/medf/'+titles[i][0]+'"><h3 style="margin-bottom:-1px;style=margin-top:7px;margin-left:7px">'+titles[i][0]+'</h3></a>' | ||
div2html += '<p style="margin-top:1px;;margin-left:10px"><font size="2px" color="gray">'+ titles[i][1] + '</font></a>' | div2html += '<p style="margin-top:1px;;margin-left:10px"><font size="2px" color="gray">'+ titles[i][1] + '</font></a>' | ||
div2.innerHTML = div2html | div2.innerHTML = div2html | ||
console.log( '<a href="/ | console.log( '<a href="/medf/"+title[i][0]+"><h3>"+title[i][0]+"</h3></a>"') | ||
div.appendChild(div2); | div.appendChild(div2); | ||
} | } | ||
第107行: | 第107行: | ||
$.ajax( | $.ajax( | ||
{ | { | ||
url: "http://www.wmuwiki.com/ | url: "http://www.wmuwiki.com/medf/api.php?action=query&format=json&list=recentchanges&rcdir=older&rcnamespace=3006&rclimit=20", | ||
method: "post", | method: "post", | ||
async: false, | async: false, | ||
第146行: | 第146行: | ||
var output | var output | ||
var output2 | var output2 | ||
var url = 'http://www.wmuwiki.com/ | var url = 'http://www.wmuwiki.com/medf/api.php' | ||
var PARAMS={ | var PARAMS={ | ||
"action": "parse", | "action": "parse", | ||
第183行: | 第183行: | ||
console.log(titles[i]) | console.log(titles[i]) | ||
// var parser = get_parser_output(titles[i][0]) | // var parser = get_parser_output(titles[i][0]) | ||
var div2html = '<a href="/ | var div2html = '<a href="/medf/'+titles[i][0]+'"><h3 style="margin-bottom:-1px;style=margin-top:7px;margin-left:7px">'+titles[i][0].split(":")[1]+'</h3></a>' | ||
div2html += '<p style="margin-top:1px;;margin-left:10px"><font size="2px" color="gray">'+ titles[i][1] + '</font></a>' | div2html += '<p style="margin-top:1px;;margin-left:10px"><font size="2px" color="gray">'+ titles[i][1] + '</font></a>' | ||
div2.innerHTML = div2html | div2.innerHTML = div2html | ||
console.log( '<a href="/ | console.log( '<a href="/medf/"+title[i][0]+"><h3>"+title[i][0]+"</h3></a>"') | ||
div.appendChild(div2); | div.appendChild(div2); | ||
} | } |
2021年11月16日 (二) 03:00的版本
mw.loader.load( '/w/index.php?title=MediaWiki:Prowordviewer.js&action=raw&ctype=text/javascript' );
/* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */
//latestpages
function oldest_page(test){
div = document.getElementById("latestpages")
if(div==null){
console.log("asdsasdasdsaddsadasdsadas")
return false
}
var titleList = []
$.ajax(
{
url: "http://www.wmuwiki.com/medf/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 time = data1[i].timestamp
var list1 = []
var reg = RegExp(/\/all/gi)
if(name=="首页"){
var c =0
}else if(name.match(reg)){
var c =0
}else{
list1.push(name)
console.log(name)
}
list1.push(time)
titleList.push(list1)
}
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/medf/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;margin-left:7px"></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");
div2.className = "latestwords_con"
console.log(titles[i])
// var parser = get_parser_output(titles[i][0])
var div2html = '<a href="/medf/'+titles[i][0]+'"><h3 style="margin-bottom:-1px;style=margin-top:7px;margin-left:7px">'+titles[i][0]+'</h3></a>'
div2html += '<p style="margin-top:1px;;margin-left:10px"><font size="2px" color="gray">'+ titles[i][1] + '</font></a>'
div2.innerHTML = div2html
console.log( '<a href="/medf/"+title[i][0]+"><h3>"+title[i][0]+"</h3></a>"')
div.appendChild(div2);
}
}
div = document.getElementById("latestpages")
div.onload = insertEntries()
//latestproenglishpages
function oldest_page2(test){
div = document.getElementById("latestproenglishpages")
if(div==null){
console.log("asdsasdasdsaddsadasdsadas")
return false
}
var titleList = []
$.ajax(
{
url: "http://www.wmuwiki.com/medf/api.php?action=query&format=json&list=recentchanges&rcdir=older&rcnamespace=3006&rclimit=20",
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 time = data1[i].timestamp
var list1 = []
var reg = RegExp(/\/all/gi)
if(name=="首页"){
var c =0
}else if(name.match(reg)){
var c =0
}else{
list1.push(name)
console.log(name)
}
list1.push(time)
titleList.push(list1)
}
var number = titleList.length
if(number >= 12){
titleList.splice(12,number)
}else {
number += 0
}
}
})
console.log(titleList)
return titleList
}
function get_parser_output(title){
var output
var output2
var url = 'http://www.wmuwiki.com/medf/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;margin-left:7px"></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 insertEntries2(){
var titles = oldest_page2()
// var div = document.getElementById("latestproenglishpages");
console.log(titles.length)
for (var i = 0; i < titles.length; i++) {
var div2 = document.createElement("div");
div2.className = "latestwords_con"
console.log(titles[i])
// var parser = get_parser_output(titles[i][0])
var div2html = '<a href="/medf/'+titles[i][0]+'"><h3 style="margin-bottom:-1px;style=margin-top:7px;margin-left:7px">'+titles[i][0].split(":")[1]+'</h3></a>'
div2html += '<p style="margin-top:1px;;margin-left:10px"><font size="2px" color="gray">'+ titles[i][1] + '</font></a>'
div2.innerHTML = div2html
console.log( '<a href="/medf/"+title[i][0]+"><h3>"+title[i][0]+"</h3></a>"')
div.appendChild(div2);
}
}
div = document.getElementById("latestproenglishpages")
div.onload = insertEntries2()