forked from Hiyoteam/HCPlus-Plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plugins.html
117 lines (114 loc) · 4.76 KB
/
plugins.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
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, shrink-to-fit=no"/>
<meta name="renderer" content="webkit"/>
<meta name="force-rendering" content="webkit"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<meta name="description" content="For Better Chatting Experience."/>
<!-- MDUI CSS -->
<link rel="stylesheet" href="https://unpkg.com/mdui@1.0.2/dist/css/mdui.min.css"/>
<title>HC++ Plugins</title>
</head>
<body class="mdui-theme-layout-auto mdui-theme-accent-blue">
<div class="mdui-appbar">
<div class="mdui-toolbar mdui-color-theme">
<a href="javascript:;" class="mdui-btn mdui-btn-icon" onclick="aHref('/index.html')">
<i class="mdui-icon material-icons">arrow_back</i>
</a>
<a href="javascript:;" class="mdui-typo-headline">HC++ Plugins</a>
<div class="mdui-toolbar-spacer"></div>
<a href="javascript:;" onclick="document.location.reload();" class="mdui-btn mdui-btn-icon">
<i class="mdui-icon material-icons">refresh</i>
</a>
</div>
</div>
<div class="mdui-typo mdui-p-l-2">
<h1>Plugin List</h1>
<p>Here are the plugins you can install.</p>
<br>
<hr>
<div id="plugins-progress">
<h4>Fetching Plugins...</h4>
<div class="mdui-progress">
<div class="mdui-progress-indeterminate"></div>
</div>
</div>
</div>
<ul class="mdui-list mdui-p-a-2" id="plugins-list">
</ul>
<!-- MDUI JavaScript -->
<script src="https://unpkg.com/mdui@1.0.2/dist/js/mdui.min.js"></script>
<script>
function isMobile(){
return window.innerWidth<768
}
function aHref(url){
window.location.href=url;
}
function getText(e){
return e.text()
}
function processPluginDetails(e){
getText(e).then(function(json){
let details=JSON.parse(json)
let a=document.getElementsByClassName(`plugin-${details.id}`)[0]
a.querySelector(".mdui-list-item-title").innerText=details.name
let description=a.querySelector(".mdui-list-item-text")
let maxLength=300
if(isMobile()){
maxLength=100
}
description.innerText = details.description.length > maxLength ? details.description.substring(0, maxLength) + "..." : details.description;
description.innerHTML+="<br>"
description.innerText+="By "+details.author
})
}
function fetchPluginDetails(name){
let a=document.createElement("a");
a.setAttribute("href",`/plugin-detail.html#${name}`)
let li=document.createElement("li")
li.classList.add("mdui-list-item")
li.classList.add("mdui-ripple")
let content_div=document.createElement("div")
content_div.classList.add("mdui-list-item-content")
let content_title=document.createElement("div")
content_title.classList.add("mdui-list-item-title")
content_title.innerText=name
let content_text=document.createElement("div")
content_text.classList.add("mdui-list-item-text")
content_text.innerHTML="Loading...<br>"
content_div.appendChild(content_title)
content_div.appendChild(content_text)
li.appendChild(content_div)
a.appendChild(li)
a.classList.add(`plugin-${name}`)
document.getElementById("plugins-list").appendChild(a)
fetch(`/plugins/${name}/plugin.json`, {cache: "no-store"}).then(processPluginDetails)
.catch(console.warn)
}
function processPlugins(e){
getText(e).then(function(json){
let plugins=JSON.parse(json)
plugins.plugins.forEach(element => {
// fetch plugin details
fetchPluginDetails(element)
});
document.getElementById("plugins-progress").style.display="none"
})
}
function fetchPlugins(){
fetch("/plugins/plugins.json", {cache: "no-store"})
.then(processPlugins)
.catch(console.warn)
}
async function fetchLastPush(){
let request=await fetch("https://camo.hach.chat/?proxyUrl=https://api.github.com/repos/Hiyoteam/HCPlus-Plugins/commits/main",{cache: "no-store"})
let json=await request.json()
return json.commit
}
fetchPlugins()
</script>
</body>
</html>