-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.php
71 lines (66 loc) · 2.34 KB
/
index.php
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
<?php
/**
* Created by PhpStorm.
* User: fengchang
* Date: 2017/6/9
* Time: 下午10:08
*/
require 'config.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Readhub RSS</title>
</head>
<body>
<div style="width: 600px; margin: 100px auto 0px">
<p>这是一个通过 RSS 订阅 Readhub 的站点,您可以自己选择想要订阅的频道。</p>
<p>
全部频道: <a href="<?=RSS_URL?>?channel=all"><?=RSS_URL?>?channel=all</a>
<img src="https://cdnjs.cloudflare.com/ajax/libs/webicons/2.0.0/webicons/webicon-rss-s.png" alt="">
</p>
<fieldset>
<legend>自定义频道</legend>
<?php
foreach (CHANNEL_CONFIG as $channel=>$attributes) {
echo "<div>";
echo "<input type='checkbox' id='$channel' name='channel' value='$channel' onchange='generateRss()'>";
echo "<label for='$channel'>{$attributes['name']}</label>";
echo "</div>";
}
?>
<p>
<a id="customRssLink" href="">请选中需要订阅的频道</a>
<img id="customRssIcon" src="https://cdnjs.cloudflare.com/ajax/libs/webicons/2.0.0/webicons/webicon-rss-s.png" alt="">
</p>
</fieldset>
<p style="text-align: right;">
See on <a href="https://github.com/fengchang/readhub-rss">Github</a>.
</p>
</div>
<script>
function generateRss() {
var checkboxes = document.getElementsByName('channel');
var checkedValue = [];
for (var i=0; i<checkboxes.length; i++) {
if (checkboxes[i].checked) {
checkedValue.push(checkboxes[i].value);
}
}
if (checkedValue.length > 0) {
var rssBaseUrl = "<?=RSS_URL?>";
var rssUrl = rssBaseUrl + '?channel=' + checkedValue.join(",");
document.getElementById('customRssLink').innerHTML = rssUrl;
document.getElementById('customRssLink').href = rssUrl;
document.getElementById('customRssIcon').style.display = "inline";
} else {
document.getElementById('customRssLink').innerHTML = "请选中需要订阅的频道";
document.getElementById('customRssLink').removeAttribute('href');
document.getElementById('customRssIcon').style.display = "none";
}
}
generateRss();
</script>
</body>
</html>