-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathutil.js
90 lines (78 loc) · 2.12 KB
/
util.js
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
renderMarkdown = function(content,text)
{
var post = {
"text": text,
"mode": "gfm",
};
var url = "https://api.github.com/markdown";
ajax(post, url, function(data) {
content.innerHTML = data;
});
}
getIssuesPreUrl = function()
{
return "https://api.github.com/repos/"+config.github_username+"/"+config.github_repo+"/issues";
}
getPageUrl = function(page)
{
var preUrl = getIssuesPreUrl();
var url = preUrl+"?per_page="+config.per_page+"&page="+page;
return url;
}
getIssuesUrl = function(id)
{
var preUrl = getIssuesPreUrl();
var url = preUrl+"/"+id;
return url
}
getCommentUrl = function(id)
{
return "https://github.com/"+config.github_username+"/"+config.github_repo+"/issues/"+id+"#new_comment_field";
}
setTitle = function(title)
{
var titles = document.getElementsByTagName("title");
titles[0].innerHTML = title;
}
setBlogName = function()
{
var btitle = document.getElementById("blog_title");
var txt = document.createTextNode(config.blog_name);
btitle.appendChild(txt);
}
cleanChild = function(node)
{
while (node.firstChild) {
node.removeChild(node.firstChild);
}
}
removeChildById = function(node, id)
{
var child = document.getElementById(id);
if (child) {
try {
node.removeChild(child);
} catch {}
}
}
setFooter = function()
{
var footer = document.getElementById("footer");
footer.innerHTML += '<span>\
Copyright © 2015-'+ new Date().getFullYear() +' <a href="http://github.com/'+config.github_username+'" target="_blank">'+config.github_username+'</a>.\
Powered by <a href="http://github.com/hanxi/issues-blog" target="_blank">issues-blog</a>.\
</span>';
}
hideElement = function(id)
{
var node = document.getElementById(id);
node.style.display="none";
}
showElement = function(id)
{
var node = document.getElementById(id);
node.style.display="";
}
loadPageVar = function (sVar) {
return unescape(window.location.search.replace(new RegExp("^(?:.*[&\\?]" + escape(sVar).replace(/[\.\+\*]/g, "\\$&") + "(?:\\=([^&]*))?)?.*$", "i"), "$1"));
}