-
Notifications
You must be signed in to change notification settings - Fork 0
/
worship-song.html
executable file
·73 lines (63 loc) · 1.91 KB
/
worship-song.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
70
71
72
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Worship Song To WIKI</title>
<style>
body {
font-size: 12px;
font-family: Arial;
}
</style>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/themes/smoothness/jquery-ui.min.css" />
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
</head>
<div id="container"> </div>
<script>
$(function() {
function lastline(lines){
var tmps=lines.split("\n");
for(var i=tmps.length-1;i>=0;i--){
var tmp=tmps[i];
if(tmp.trim().length>0)
return tmp.trim();
}
return lines;
}
$("#parse_button").click(function(event){
$("#content").text("");
var email=$("#emailtext").val();
reg = new RegExp(
"http.*",
"gi");
var result;
var lastindex=0;
var sameSongIndex=0;
while ((result = reg.exec(email)) !== null) {
var url=result[0].trim();
var index=result.index;
var lines=email.substring(lastindex,index)
var song=lastline(lines).replace(/[0-9]\.\s*/,"");
console.log(song+ " "+url);
if(song.trim().length==0){
sameSongIndex++;
$("#content").append("[[@"+url+"|link"+(sameSongIndex+1)+"]] ");
}else{
$("#content").append("[[@"+url+"|"+song+"]] ");
sameSongIndex=0;
}
lastindex=reg.lastIndex;
}
event.preventDefault();
});
});
</script>
<textarea rows="20" cols="100" id="emailtext">
</textarea>
<br>
<button id="parse_button">Parse the Email</button>
<br>
敬拜诗歌 : <span id="content"> </span>
</body>
</html>