diff options
author | Max Magorsch <arzano@gentoo.org> | 2020-03-01 22:33:52 +0100 |
---|---|---|
committer | Max Magorsch <arzano@gentoo.org> | 2020-03-01 22:33:52 +0100 |
commit | eaac808928c1b8a37010df20ce088d254854b1f9 (patch) | |
tree | 496e371ed1660a42b4194f7b77af46f16ca1f4d5 /js | |
download | planet-tyrian-eaac808928c1b8a37010df20ce088d254854b1f9.tar.gz planet-tyrian-eaac808928c1b8a37010df20ce088d254854b1f9.tar.bz2 planet-tyrian-eaac808928c1b8a37010df20ce088d254854b1f9.zip |
Add initial version of the tyrian pluto theme
Signed-off-by: Max Magorsch <arzano@gentoo.org>
Diffstat (limited to 'js')
-rw-r--r-- | js/planet-tyrian.js | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/js/planet-tyrian.js b/js/planet-tyrian.js new file mode 100644 index 0000000..d1850db --- /dev/null +++ b/js/planet-tyrian.js @@ -0,0 +1,68 @@ +function updateView(){
+ if(document.getElementById("article-view").checked){
+ document.querySelectorAll(".article-view").forEach(element => {
+ if( (document.getElementById("planet-scope").checked && element.getAttribute("data-location") == "planet") || document.getElementById("universe-scope").checked ){
+ element.classList.remove("d-none");
+ } else {
+ element.classList.add("d-none");
+ }
+ });
+
+ document.querySelectorAll(".short-view").forEach(element => {
+ element.classList.add("d-none");
+ });
+ } else {
+ document.querySelectorAll(".article-view").forEach(element => {
+ element.classList.add("d-none");
+ });
+
+ document.querySelectorAll(".short-view").forEach(element => {
+ if( (document.getElementById("planet-scope").checked && element.getAttribute("data-location") == "planet") || document.getElementById("universe-scope").checked ){
+ element.classList.remove("d-none");
+ } else {
+ element.classList.add("d-none");
+ }
+ });
+ }
+}
+
+
+function updateArticles() {
+ var xhttp = new XMLHttpRequest();
+ xhttp.onreadystatechange = function() {
+ if (this.readyState == 4 && this.status == 200) {
+
+ parser = new DOMParser();
+ doc = parser.parseFromString(this.responseText, "text/html")
+ var nodes = doc.querySelectorAll('[data-date]');
+
+ document.getElementById("content").innerHTML = "";
+
+ for (i = 0; i < nodes.length; ++i) {
+ if(new Date(nodes[i].getAttribute("data-date")) > new Date($("#start").val()) && new Date(nodes[i].getAttribute("data-date")) < new Date($("#end").val())){
+ document.getElementById("content").append(nodes[i]);
+ }
+ }
+
+ updateView();
+ }
+ };
+ xhttp.open("GET", "data.html", true);
+ xhttp.send();
+}
+
+
+function initialize(){
+ $('#datepicker').datepicker({
+ format: "yyyy-mm-dd",
+ orientation: "bottom auto"
+ });
+
+ document.getElementById("start").value = "2020-01-01";
+ document.getElementById("end").value = (new Date()).toISOString().slice(0,10);
+
+ updateArticles();
+}
+
+
+initialize();
|