|
@@ -3,7 +3,8 @@ layout: default
|
|
|
---
|
|
|
|
|
|
<script>
|
|
|
-
|
|
|
+
|
|
|
+ // Main Library-printing function
|
|
|
function printLibrary(sheet) {
|
|
|
const store = new SteinStore(
|
|
|
"https://api.steinhq.com/v1/storages/5e8b937ab88d3d04ae0816a5"
|
|
@@ -12,22 +13,43 @@ layout: default
|
|
|
store.read(sheet, { limit: 0, offset: 0 }).then(data => {
|
|
|
rules = data.reverse();
|
|
|
libHTML = "";
|
|
|
+ // iterating over all the rules
|
|
|
for (var i = 0; i < rules.length; i++) {
|
|
|
+ libHTML += "<div class='library-item'>\n";
|
|
|
+ // first the titles
|
|
|
var title = rules[i]["communityname"];
|
|
|
if (title == null) { title = "Untitled"; }
|
|
|
libHTML += "<div class='library-rule-name'>" +
|
|
|
"<a href='/create/?r=" + rules[i]["ruleID"] + "'>" +
|
|
|
title + "</a></div>\n";
|
|
|
+ // then the authors
|
|
|
var author = rules[i]["author-text"];
|
|
|
if (author != null) {
|
|
|
libHTML += "<div class='library-rule-author'>" + author + "</div>";
|
|
|
- }
|
|
|
+ }
|
|
|
+ // then the structures
|
|
|
var structure = rules[i]["structure"];
|
|
|
if (structure != null) {
|
|
|
libHTML += "<p class='library-rule-structure'>" + structure;
|
|
|
libHTML += "</p>\n\n";
|
|
|
}
|
|
|
+ // then the modules
|
|
|
+ var modulesRaw = rules[i]["modules"];
|
|
|
+ if (modulesRaw != null) {
|
|
|
+ libHTML += "<div class='library-module-list'>";
|
|
|
+ var modulesDOM = document.createElement("DIV");
|
|
|
+ modulesDOM.innerHTML = "<div>" + modulesRaw + "</div>";
|
|
|
+ var modules = modulesDOM.getElementsByClassName("module");
|
|
|
+ for (var x = 0; x < modules.length; x++) {
|
|
|
+ var moduleName = modules[x].children.item("module-name").innerHTML;
|
|
|
+ libHTML += "<div class='module library-module'>" +
|
|
|
+ moduleName + "</div>\n";
|
|
|
+ }
|
|
|
+ moduleName + "</div>\n";
|
|
|
+ }
|
|
|
+ libHTML += "</div>\n</div>\n";
|
|
|
}
|
|
|
+ libHTML += "</div>\n";
|
|
|
document.getElementById("librarylist").innerHTML = libHTML;
|
|
|
});
|
|
|
}
|