-
Notifications
You must be signed in to change notification settings - Fork 7
/
regex.html
70 lines (68 loc) · 3.93 KB
/
regex.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(runoob.com)</title>
<script>
let rawdata = String.raw `{yearDom:"2003-20042004-20052005-20062006-20072007-20082008-20092009-20102010-20112011-20122012-20132013-20142014-20152015-20162016-20172017-20182018-20192019-20202020-20212021-20222022-20232023-20242024-20252025-20262026-20272027-20282028-2029",termDom:"学期1学期2",semesters:{y0:[{id:24,schoolYear:"2003-2004",name:"1"},{id:15,schoolYear:"2003-2004",name:"2"}],y1:[{id:32,schoolYear:"2004-2005",name:"1"},{id:16,schoolYear:"2004-2005",name:"2"}],y2:[{id:33,schoolYear:"2005-2006",name:"1"},{id:17,schoolYear:"2005-2006",name:"2"}],y3:[{id:34,schoolYear:"2006-2007",name:"1"},{id:18,schoolYear:"2006-2007",name:"2"}],y4:[{id:35,schoolYear:"2007-2008",name:"1"},{id:19,schoolYear:"2007-2008",name:"2"}],y5:[{id:36,schoolYear:"2008-2009",name:"1"},{id:20,schoolYear:"2008-2009",name:"2"}],y6:[{id:37,schoolYear:"2009-2010",name:"1"},{id:21,schoolYear:"2009-2010",name:"2"}],y7:[{id:3,schoolYear:"2010-2011",name:"1"},{id:22,schoolYear:"2010-2011",name:"2"}],y8:[{id:4,schoolYear:"2011-2012",name:"1"},{id:23,schoolYear:"2011-2012",name:"2"}],y9:[{id:5,schoolYear:"2012-2013",name:"1"},{id:25,schoolYear:"2012-2013",name:"2"}],y10:[{id:6,schoolYear:"2013-2014",name:"1"},{id:26,schoolYear:"2013-2014",name:"2"}],y11:[{id:7,schoolYear:"2014-2015",name:"1"},{id:2,schoolYear:"2014-2015",name:"2"}],y12:[{id:8,schoolYear:"2015-2016",name:"1"},{id:27,schoolYear:"2015-2016",name:"2"}],y13:[{id:9,schoolYear:"2016-2017",name:"1"},{id:28,schoolYear:"2016-2017",name:"2"}],y14:[{id:10,schoolYear:"2017-2018",name:"1"},{id:29,schoolYear:"2017-2018",name:"2"}],y15:[{id:11,schoolYear:"2018-2019",name:"1"},{id:30,schoolYear:"2018-2019",name:"2"}],y16:[{id:12,schoolYear:"2019-2020",name:"1"},{id:31,schoolYear:"2019-2020",name:"2"}],y17:[{id:47,schoolYear:"2020-2021",name:"1"},{id:48,schoolYear:"2020-2021",name:"2"}],y18:[{id:74,schoolYear:"2021-2022",name:"1"},{id:75,schoolYear:"2021-2022",name:"2"}],y19:[{id:76,schoolYear:"2022-2023",name:"1"},{id:77,schoolYear:"2022-2023",name:"2"}],y20:[{id:94,schoolYear:"2023-2024",name:"1"},{id:95,schoolYear:"2023-2024",name:"2"}],y21:[{id:114,schoolYear:"2024-2025",name:"1"},{id:115,schoolYear:"2024-2025",name:"2"}],y22:`
function displayDate(year,month){
let d = new Date()
let yr=year//d.getFullYear()
let mr=month//d.getMonth()+1
let reg
let sessionid
if (mr < 8 && mr > 1)//2到7月看作下学期
{
let yearTemp = (yr-1)+"-"+yr
console.log(yearTemp+"下学期")
document.getElementById("demo").innerHTML=yearTemp+"下学期"
reg = new RegExp("(?<=\\{id:)\\d+(?=,schoolYear:\"" + yearTemp + "\",name:\"2\")", 'g')
}
else if (1 == mr)
{
let yearTemp = (yr-1)+"-"+yr
console.log(yearTemp+"上学期")
document.getElementById("demo").innerHTML=yearTemp+"上学期"
reg = new RegExp("(?<=\\{id:)\\d+(?=,schoolYear:\"" + yearTemp + "\",name:\"1\")", 'g')
}
else
{
let yearTemp = yr+"-"+(yr+1)
console.log(yearTemp+"上学期")
document.getElementById("demo").innerHTML=yearTemp+"上学期"
reg = new RegExp("(?<=\\{id:)\\d+(?=,schoolYear:\"" + yearTemp + "\",name:\"1\")", 'g')
}
sessionid = rawdata.match(reg)
console.log("id: " + sessionid)
//console.log(reg)
console.log(year)
document.getElementById("sessid").innerHTML=sessionid
document.getElementById("reg").innerHTML=reg
}
let myVar = setInterval(function(){loopMyFun()},250)
let i=1
let j=2022
console.log(rawdata)
function loopMyFun(){
document.getElementById("etc").innerHTML=i
displayDate(j,i++)
if (i == 13)
{i = 1;j++;}
if (j == 2025)
{j = 2003}
}
function manualadd(){
loopMyFun()
}
</script>
</head>
<body>
<h1>我的第一个 JavaScript 程序</h1>
<p id="demo">这是一个段落</p>
<p id="etc">这是一个段落</p>
<p id="sessid">这是一个段落</p>
<p id="reg">这是一个段落</p>
<button type="button" onclick="clearInterval(myVar)">停止</button>
<button type="button" onclick="manualadd()">+1</button>
</body>
</html>