-
Notifications
You must be signed in to change notification settings - Fork 0
/
detail.html
92 lines (90 loc) · 2.8 KB
/
detail.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
<title></title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<script src="js/mui.js"></script>
<link href="css/mui.min.css" rel="stylesheet" />
<link href="css/github-markdown.css" rel="stylesheet">
<style type="text/css">
body{
width:100%;
word-wrap: break-word;
}
h1,h2,h3,h4,small{
padding-left: 10px;
padding-right: 10px;
}
p{
padding: 10px;
}
small{
color:#666666
}
</style>
</head>
<body>
<header class="mui-bar mui-bar-nav">
<a class="mui-icon mui-icon-left-nav mui-pull-left mui-action-back"></a>
<h1 id="title" class="mui-title"></h1>
</header>
<div class="mui-content markdown-body">
<h4 id='title1' style="padding-top: 10px;"></h4>
<small id="introduce"></small>
<hr style="margin:5px">
<p id="text"></p>
<ul id="replies" style="padding: 0;" class="mui-table-view">
<li class="mui-table-view-divider">评论</li>
</ul>
</div>
<script type="text/javascript" charset="utf-8">
mui.init({
swipeBack:true //启用右滑关闭功能
});
window.onload = function(){
mui.plusReady(function() {
var self = plus.webview.currentWebview();
var detail_id = self.detailID;
var show= get('https://cnodejs.org/api/v1/topic/'+detail_id , function(detail) {
var data = JSON.parse(detail).data;
var num=data.replies.length;
data.content=data.content.replace(/\n/g,'<br>');
document.getElementById('title').innerText = data.title;
document.getElementById('title1').innerText = data.title;
document.getElementById('introduce').innerHTML = data.author.loginname +' '+ data.visit_count +' '+ data.create_at.substr(0,data.create_at.indexOf('T'));
document.getElementById('text').innerHTML = data.content;
for(var i=0;i<num;i++){
document.getElementById("replies").innerHTML+='<li class="mui-table-view-cell">'+data.replies[i].content+'<small>'+data.replies[i].author.loginname+' '+data.replies[i].create_at.substr(0,data.replies[i].create_at.indexOf('T'))+'</small></li>';
}
plus.nativeUI.closeWaiting();
mui.currentWebview.show();
});
//新建浏览器
mui('body').on('tap','a',function(e){
var href = this.getAttribute('href');
if (href) {
plus.runtime.openURL(href);
}
});
});
};
function get(url, callback) {
var xmlhttp = null;
xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", url, true);
xmlhttp.send(null);
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
callback(xmlhttp.responseText);
}
}
}
mui.back=function(){
plus.webview.currentWebview().close();
}
</script>
</body>
</html>