-
Notifications
You must be signed in to change notification settings - Fork 364
/
index.html
270 lines (235 loc) · 8.44 KB
/
index.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
---
layout: index-vue
title: Home
---
<style>
.inner-app-hide{
display: none;
}
.live-hide{
display: none;
}
.blue-visit:visited{
color: #2a7ae2;
}
.blue-visit{
font-size: 16px;
}
.top-4-hide{
display: none;
}
.bottom-10px{
margin-bottom: 45px;
}
.index-live a:visited{
color: #3e1004;
}
</style>
{% raw %}
<p style="font-size: 1.25em; font-weight: bold;" class="live-hide">Live
<div class="index-live latest-app-top-4 top-4-hide bottom-10px">
<div v-for="link in top_4" class="" >
<ul v-bind:class="is_ds(link.I)">
<li>
<p class="added-hostname" v-if="link.N !== undefined">
<a class="externalLink" target="_blank" rel="nofollow noopener" v-bind:href="link.U">{{ is_pkg(link.U) }}{{ link.T }} <span class="spantext">{{ get_host(link.U) }}</span></a> - {{ link.N }} <span style="color:#999;" class="tooltiptext">( {{ get_host(link.U) }} ) </span>
</p>
<p class="added-hostname" v-else>
<a class="externalLink" target="_blank" rel="nofollow noopener" v-bind:href="link.U">{{ is_pkg(link.U) }}{{ link.T }} <span class="spantext">{{ get_host(link.U) }}</span></a><span style="color:#999;" class="tooltiptext">( {{ get_host(link.U) }} ) </span>
</p>
</li>
</ul>
<p v-bind:class="is_ds(link.I)" v-if="link.P !== undefined">
<img v-bind:src="link.P" v-bind:alt="link.T"/>
</p>
</div>
<a class="live-more blue-visit" style="color:#2a7ae2;" href="#">More</a></p>
</div>
<div class="index-live latest-app inner-app-hide bottom-10px">
<div class="like-table" v-for="item in post_date.obj">
<p style="font-size: 1.2em; font-weight: bold;" v-bind:id="item.date">{{ item.date }}</p>
<div v-for="link in item.links" class="" >
<ul v-bind:class="is_ds(link.I)">
<li>
<p class="added-hostname" v-if="link.N !== undefined">
<a class="externalLink" target="_blank" rel="nofollow noopener" v-bind:href="link.U">{{ is_pkg(link.U) }}{{ link.T }} <span class="spantext">{{ get_host(link.U) }}</span></a> - {{ link.N }} <span style="color:#999;" class="tooltiptext"><br/>( {{ get_host(link.U) }} ) </span>
</p>
<p class="added-hostname" v-else>
<a class="externalLink" target="_blank" rel="nofollow noopener" v-bind:href="link.U">{{ is_pkg(link.U) }}{{ link.T }} <span class="spantext">{{ get_host(link.U) }}</span></a><span style="color:#999;" class="tooltiptext"><br/>( {{ get_host(link.U) }} ) </span>
</p>
</li>
</ul>
<p v-bind:class="is_ds(link.I)" v-if="link.P !== undefined">
<img v-bind:src="link.P" v-bind:alt="link.T"/>
</p>
</div>
</div>
</div>
{% endraw %}
<div id="posts-content" class="posts">
{% for post in paginator.posts %}
<article class="post post-detail-{{ post.id | replace: '/', '' }}">
<h1 class="post-title">
<a href="{{ site.baseurl }}{{ post.url }}">
{{ post.title }}
</a>
</h1>
<p class="added-hostname"><time style="display: inline;margin-right: 15px;" datetime="{{ post.date | date_to_xmlschema }}" class="post-date">{{ post.date | date_to_string }}</time>
{% include social-button.html %}
</p>
<form class="filter-box">
<input name="query" placeholder="type to filter" class="input-box title-filter">
</form>
{{ post.content }}
<!--<p><small id="page_view"> </small></p>-->
<div id="dialog-{{ post.id | replace: '/', '' }}" style="display:none;"></div>
<script class="inf-detail">
console.log("loading page {{ post.id | replace: '/', '' | replace: '-', '_' }}");
function onHostClick{{ post.id | replace: '/', '' | replace: '-', '_' }}(evt) {
console.log(evt.dataset.desc);
$("#dialog-{{ post.id | replace: '/', '' }}").text(evt.dataset.desc);
$("#dialog-{{ post.id | replace: '/', '' }}").dialog({
width: "80%",
maxWidth: 600,
maxHeight: 600,
});
}
setTimeout(function () {
$.ajax({
dataType: "json",
url: "https://live.rweekly.org/post-{{post.id | replace: '/', ''}}.json",
success: function (data) {
console.log(data);
if (typeof data === 'object') {
$(".post-detail-{{post.id | replace: '/', ''}} .added-hostname").each(function (index, elt) {
const href = $('a', elt).attr('href');
if (data[href]) {
$('.tooltiptext', elt).attr('data-desc', data[href]);
$('a', elt).attr('data-desc', data[href]);
$('.tooltiptext', elt).attr('onclick', "onHostClick{{ post.id | replace: '/', '' | replace: '-', '_' }}(this)");
$('a', elt).tooltip(
{
items: '[data-desc]',
content: function () {
var element = $(this);
return '<div class="link-desc">' + element.attr("data-desc") + '</div>';
},
position: {
collision: "none",
}
}
);
}
});
}
}
});
}, 1000);
</script>
</article>
{% endfor %}
<div class="pagination">
{% if paginator.next_page %}
<a id="next-page" class="pagination-item older" href="{{ paginator.next_page_path | prepend: site.baseurl }}/index.html">Older</a>
{% else %}
<span class="pagination-item older">Older</span>
{% endif %}
{% if paginator.previous_page %}
<a class="pagination-item newer" href="{{ paginator.previous_page_path | prepend: site.baseurl }}/index.html">Newer</a>
{% else %}
<span class="pagination-item newer">Newer</span>
{% endif %}
</div>
</div>
<script>
function is_ds(value){
if(value === 1){
return "is-ds";
}
return "not-ds";
}
function get_host(text){
var aurl = document.createElement('a');
aurl.href = text;
return aurl.host;
}
var weekday = new Array(7);
weekday[0] = "Sunday";
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";
function get_date(){
var date_var = new Date();
return date_var.getFullYear() + '-' + (date_var.getMonth()+1) + '-' + date_var.getDate() + " " + weekday[date_var.getDay()];
}
var latest_data = {};
var top_4 = [];
// Vue.config.devtools = true;
function is_pkg(url){
if (get_host(url) === "cran.r-project.org"){
return "📦 ";
}else{
return "";
}
}
var latest_app = new Vue({
el: '.latest-app',
data: {
post_date: latest_data
}
});
var top4_app = new Vue({
el: '.latest-app-top-4',
data: {
top_4: top_4
}
});
function load_latest(){
var xhr = new XMLHttpRequest();
xhr.open("GET","https://live.rweekly.org/latest.json");
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
try{
localStorage.setItem("live-latest", xhr.responseText);
}catch(err2){
console.log(err2);
}
var myArr = JSON.parse(xhr.responseText);
var max_length = myArr.obj[0].links.length;
if(max_length>3){
max_length = 3;
}
for(var ii =0; ii!=max_length; ii++){
top_4.push(myArr.obj[0].links[ii]);
}
top4_app.top_4 = top_4;
// document.querySelector('.latest-app').classList.remove('inner-app-hide');
document.querySelector('.latest-app-top-4').classList.remove('top-4-hide');
document.querySelector('.live-hide').classList.remove('live-hide');
latest_app.post_date = myArr;
// add_external_links();
setTimeout(function(){
twemoji.parse(document.body,
{
folder: 'svg',
ext: '.svg'
});
}, 500);
}
};
xhr.send();
}
document.addEventListener('DOMContentLoaded', function(){
load_latest();
var live_more_button = document.querySelector(".live-more");
live_more_button.addEventListener("click",function(){
_paq.push(['trackEvent', 'Read-Live', '1']);
document.querySelector('.latest-app').classList.remove('inner-app-hide');
document.querySelector('.latest-app-top-4').classList.add('top-4-hide');
document.querySelector(".live-more").classList.add('top-4-hide');
})
});
</script>