]>
Commit | Line | Data |
---|---|---|
b65f0496 VP |
1 | <?php |
2 | ||
c06c1713 BM |
3 | require_once "../inc/common.php"; |
4 | require_once "../inc/header.php"; | |
b65f0496 VP |
5 | |
6 | ||
7 | ?> | |
8 | ||
e47cb29f | 9 | <h2>Active Plugins <a class="btn btn-sm btn-primary" href="add-plugin.php">Add New</a></h2> |
b65f0496 | 10 | <br> |
c99eabea | 11 | Your installed plugins: |
b65f0496 VP |
12 | <br> |
13 | <table class="container-xxl table table-sm table-responsive caption-top table-striped"> | |
14 | <thead class="table-primary"> | |
15 | <form method="post"> | |
be5ea960 | 16 | <th scope="col"><input type="checkbox" label='selectall' onClick="toggle_tkl(this)" /></th> |
b65f0496 | 17 | <th scope="col">Plugin Name</th> |
b65f0496 VP |
18 | <th scope="col">Version</th> |
19 | <th scope="col">Description</th> | |
20 | <th scope="col">Author</th> | |
21 | <th scope="col">Contact</th> | |
be5ea960 | 22 | <th scope="col">Uninstall</th> |
b65f0496 VP |
23 | |
24 | </thead> | |
25 | <tbody> | |
26 | <?php | |
27 | foreach(Plugins::$list as $plugin) | |
28 | { | |
29 | echo "<tr>"; | |
be5ea960 VP |
30 | echo "<th scope=\"col\"><input type=\"checkbox\" label='selectall' onClick=\"toggle_tkl(this)\" /></th>"; |
31 | echo "<td scope=\"col\" onClick=\"create_plugin_info_modal('".$plugin->handle."')\">".$plugin->name."</td>"; | |
b65f0496 VP |
32 | echo "<td scope=\"col\"><code>".$plugin->version."</code></td>"; |
33 | echo "<td scope=\"col\">".$plugin->description."</td>"; | |
34 | echo "<td scope=\"col\">".$plugin->author."</td>"; | |
35 | echo "<td scope=\"col\"><a href='mailto:$plugin->email'>".$plugin->email."</a></td>"; | |
be5ea960 | 36 | echo "<td width=\"110\" scope=\"col\"><div id=\"".$plugin->handle."install\" class='text-center btn-sm btn-danger btn-install-plugin'>Uninstall</div></td>"; |
b65f0496 VP |
37 | echo "</tr>"; |
38 | } | |
39 | ?> | |
40 | </tbody> | |
685677bd | 41 | </table> |
be5ea960 VP |
42 | |
43 | <script> | |
44 | const ibtns = document.querySelectorAll(".btn-install-plugin"); | |
45 | ibtns.forEach((ib) => { | |
46 | ib.addEventListener('click', (e) => { | |
47 | console.log(ib.id); | |
48 | if (ib.innerHTML !== "Install" && ib.innerHTML !== "Uninstall") // some point between, don't do anything | |
49 | {} | |
50 | else if (ib.innerHTML == "Install") // install button pressed! | |
51 | { | |
52 | let req = requestInstall(ib.id.slice(0,-7)) | |
53 | if (req == true) | |
54 | { | |
55 | ib.classList.replace("btn-primary", "btn-secondary"); | |
56 | ib.innerHTML = "Installing..."; | |
57 | } | |
58 | else | |
59 | { | |
60 | let uhoh = new bsModal("Error", "Could not install: "+req, "", null, false, true); | |
61 | } | |
62 | } | |
63 | else if (ib.innerHTML == "Uninstall") | |
64 | { | |
65 | let req = requestInstall(ib.id.slice(0,-7), true); // true = uninstall | |
66 | if (req == true) | |
67 | { | |
68 | ib.classList.replace("btn-outline-danger", "btn-secondary"); | |
69 | ib.innerHTML = "Uninstalling..."; | |
70 | } | |
71 | else | |
72 | { | |
73 | let uhoh = new bsModal("Error", "Could not uninstall: "+req, "", null, false, true); | |
74 | } | |
75 | } | |
76 | }); | |
77 | }) | |
78 | const installed = document.querySelectorAll(".installed"); | |
79 | installed.forEach((el) => { | |
80 | let btn = document.getElementById(el.id + 'install'); | |
81 | btn.classList.replace("btn-primary", "btn-outline-danger"); | |
82 | btn.innerHTML = "Uninstall"; | |
83 | }); | |
84 | </script> | |
85 | ||
685677bd | 86 | <?php |
c06c1713 | 87 | require_once "../inc/footer.php"; |