|
|
(未显示同一用户的75个中间版本) |
第1行: |
第1行: |
| mw.loader.load( '/w/index.php?title=MediaWiki:Prowordviewer.js&action=raw&ctype=text/javascript' );
| |
| /* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */ | | /* 这里的任何JavaScript将为所有用户在每次页面载入时加载。 */ |
| //基本函数 | | //基本函数 |
第5行: |
第4行: |
| $("#"+id).fadeIn(time) | | $("#"+id).fadeIn(time) |
| } | | } |
| | | MathJax = { |
| //插入外部图片
| | tex: { |
| function thumbImage(){
| | inlineMath: [['$', '$'], ['\\(', '\\)']] |
| console.log('container_width')
| | }, |
| var container_width = $("#external-image").width()
| | loader: {load: ['[tex]/mhchem']}, |
| var img = $("#external-image>p>img")
| | }; |
| img.width(container_width)
| | mw.loader.getScript( 'https://cdn.bootcss.com/mathjax/3.0.5/es5/tex-mml-chtml.js' ) |
| }
| |
| try{
| |
| div = document.getElementById("external-image")
| |
| console.log('container_width1')
| |
| div.onload = thumbImage()
| |
| console.log('container_width')
| |
| }catch(err){
| |
| console.log(err)
| |
| }
| |
| | |
| | |
| | |
| | |
| //获取最新页面
| |
| var weburl = "https://www.medforest.cn/medf"
| |
| //latestpages
| |
| function oldest_page(test){
| |
| div = document.getElementById("latestpages")
| |
| if(div==null){
| |
| console.log("asdsasdasdsaddsadasdsadas")
| |
| return false
| |
| }
| |
| var titleList = []
| |
| $.ajax(
| |
| {
| |
| url: weburl+"/api.php?action=query&format=json&list=recentchanges&utf8=1&rcnamespace=0&rctype=edit%7Cnew%7Clog%7Ccategorize&rctoponly=1",
| |
| method: "post",
| |
| async: true,
| |
| 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)
| |
| }
| |
| for(let key=0;key<11;key++) {
| |
| console.log(key)
| |
| console.log(titleList[key])
| |
| setTimeout(function (){insertEntries(titleList[key], 1, key)},50*key)
| |
|
| |
| }
| |
| }
| |
| })
| |
| console.log(titleList)
| |
| } | |
| function insertEntries(titles,number,i){
| |
| if(titles.length ==1){
| |
| return false
| |
| }
| |
| var word = titles[0]
| |
| var time = titles[1]
| |
| var origin_div = document.getElementById("latestpages")
| |
| console.log(titles.length)
| |
| var div2 = document.createElement("div");
| |
| div2.className = "latestwords_con"
| |
| div2.id = "glossary-"+i
| |
| div2.style = "display:none"
| |
| console.log(titles)
| |
| // var parser = get_parser_output(titles[i][0])
| |
| var div2html = '<a href="/dic/'+word+'"><h3 style="margin-bottom:-1px;style=margin-top:7px;margin-left:7px">'+word+'</h3></a>'
| |
| div2html += '<p style="margin-top:1px;;margin-left:10px"><font size="2px" color="gray">'+ time + '</font></a>'
| |
| div2.innerHTML = div2html
| |
| console.log( '<a href="/dic/"+word+"><h3>"+word+"</h3></a>"')
| |
| origin_div.appendChild(div2)
| |
| fadeIn("glossary-"+i,"normal")
| |
| }
| |
| div = document.getElementById("latestpages")
| |
| div.onload = oldest_page()
| |
| | |
| //latestproenglishpages
| |
| function oldest_page2(test){
| |
| div = document.getElementById("latestproenglishpages")
| |
| if(div==null){
| |
| console.log("asdsasdasdsaddsadasdsadas")
| |
| return false
| |
| }
| |
| var titleList = []
| |
| $.ajax(
| |
| {
| |
| url: weburl+"/api.php?action=query&format=json&list=recentchanges&rcdir=older&rcnamespace=3006&rclimit=20",
| |
| method: "post",
| |
| async: true,
| |
| 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
| |
| }
| |
| insertEntries2(titleList)
| |
| }
| |
| })
| |
| console.log(titleList)
| |
| }
| |
| | |
| function get_parser_output(title){
| |
| var output
| |
| var output2
| |
| var url = weburl+'/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(titles){
| |
| // 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="/dic/'+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="/dic/"+title[i][0]+"><h3>"+title[i][0]+"</h3></a>"')
| |
| div.appendChild(div2);
| |
| }
| |
| }
| |
| div = document.getElementById("latestproenglishpages")
| |
| div.onload = oldest_page2()
| |