diff options
Diffstat (limited to 'pages')
-rw-r--r-- | pages/bitset.inc | 440 | ||||
-rw-r--r-- | pages/page.inc | 4 | ||||
-rw-r--r-- | pages/relations.inc | 10 | ||||
-rw-r--r-- | pages/rules-old.inc | 253 | ||||
-rw-r--r-- | pages/rules.inc | 251 | ||||
-rw-r--r-- | pages/stats.inc | 226 |
6 files changed, 627 insertions, 557 deletions
diff --git a/pages/bitset.inc b/pages/bitset.inc index d4239a7..c74fe64 100644 --- a/pages/bitset.inc +++ b/pages/bitset.inc @@ -31,7 +31,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; <br> <div class="container"> <div id="page-content"> - <h2>Bitset calculator</h2> + <h2 oncontextmenu="document.getElementById('deprecated-options').style.display='block';">Bitset calculator</h2> </div> <div style="display:grid; grid-template-columns: repeat(48, 1fr);"> <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-1" class="font-monospace tooltip-nohelp text-muted" style="text-align: center;cursor: pointer;">0</div> @@ -46,27 +46,27 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-10" class="font-monospace tooltip-nohelp text-muted" style="text-align: center;cursor: pointer;">0</div> <div data-bs-toggle="tooltip" title="Persecutor" id="binary-bit-11" class="font-monospace tooltip-nohelp" style="color:#197387;text-align: center;cursor: pointer;">0</div> <div data-bs-toggle="tooltip" title="Leader" id="binary-bit-12" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#877e19;">0</div> - <div data-bs-toggle="tooltip" title="Age regressor (deprecated)" id="binary-bit-13" class="font-monospace tooltip-nohelp" style="color: #383838;text-align: center;cursor: pointer;">0</div> - <div data-bs-toggle="tooltip" title="Sexually active" id="binary-bit-14" class="font-monospace tooltip-nohelp" style="color: rgb(59,196,46);text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-13" class="text-muted font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Preemptive sexual consent" id="binary-bit-14" class="font-monospace tooltip-nohelp" style="color: rgb(59,196,46);text-align: center;cursor: pointer;">0</div> <div data-bs-toggle="tooltip" title="Fronts less frequently" id="binary-bit-15" class="font-monospace tooltip-nohelp" style="color: #198754;text-align: center;cursor: pointer;">0</div> <div data-bs-toggle="tooltip" title="Non verbal in real life" id="binary-bit-16" class="font-monospace tooltip-nohelp" style="color: #20c997;text-align: center;cursor: pointer;">0</div> <div data-bs-toggle="tooltip" title="Eatable food" id="binary-bit-17" class="font-monospace tooltip-nohelp" style="color: #d63384;text-align: center;cursor: pointer;">0</div> <div data-bs-toggle="tooltip" title="Eatable food" id="binary-bit-18" class="font-monospace tooltip-nohelp" style="color: #d63384;text-align: center;cursor: pointer;">0</div> - <div data-bs-toggle="tooltip" title="Ability to use magic" id="binary-bit-19" class="font-monospace tooltip-nohelp" style="color: #fd7e14;text-align: center;cursor: pointer;">0</div> - <div data-bs-toggle="tooltip" title="Ability to use magic" id="binary-bit-20" class="font-monospace tooltip-nohelp" style="color: #fd7e14;text-align: center;cursor: pointer;">0</div> - <div data-bs-toggle="tooltip" title="Ability to use magic" id="binary-bit-21" class="font-monospace tooltip-nohelp" style="color: #fd7e14;text-align: center;cursor: pointer;">0</div> - <div data-bs-toggle="tooltip" title="Affectionative or sexual sensitivity" id="binary-bit-22" class="font-monospace tooltip-nohelp" style="color:#3340d0; text-align: center;cursor: pointer;">0</div> - <div data-bs-toggle="tooltip" title="Affectionative or sexual sensitivity" id="binary-bit-23" class="font-monospace tooltip-nohelp" style="color:#3340d0; text-align: center;cursor: pointer;">0</div> - <div data-bs-toggle="tooltip" title="Affectionative or sexual sensitivity" id="binary-bit-24" class="font-monospace tooltip-nohelp" style="color:#3340d0; text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Polyamory (romantic)" id="binary-bit-19" class="font-monospace tooltip-nohelp" style="color: #eeb8b8; text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Polyamory (sexual)" id="binary-bit-20" class="font-monospace tooltip-nohelp" style="color: #e2b8ee; text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Sexual alignment" id="binary-bit-21" class="font-monospace tooltip-nohelp" style="color: #5fff4d; text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Sexual alignment" id="binary-bit-22" class="font-monospace tooltip-nohelp" style="color: #5fff4d; text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Sexual alignment" id="binary-bit-23" class="font-monospace tooltip-nohelp" style="color: #5fff4d; text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Sexual alignment" id="binary-bit-24" class="font-monospace tooltip-nohelp" style="color: #5fff4d; text-align: center;cursor: pointer;">0</div> <div data-bs-toggle="tooltip" title="Shared memory access" id="binary-bit-25" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#fa77ef;">0</div> <div data-bs-toggle="tooltip" title="Shared memory access" id="binary-bit-26" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#fa77ef;">0</div> - <div data-bs-toggle="tooltip" title="Median system" id="binary-bit-27" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color: #a14700;">0</div> + <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-27" class="text-muted font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;">0</div> <div data-bs-toggle="tooltip" title="Little/younger" id="binary-bit-28" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#b277fa;">0</div> <div data-bs-toggle="tooltip" title="Little/younger" id="binary-bit-29" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#b277fa;">0</div> <div data-bs-toggle="tooltip" title="Protector" id="binary-bit-30" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#77faab;">0</div> <div data-bs-toggle="tooltip" title="Fictive" id="binary-bit-31" class="font-monospace tooltip-nohelp text-info" style="text-align: center;cursor: pointer;">0</div> - <div data-bs-toggle="tooltip" title="Not talking" id="binary-bit-32" class="font-monospace tooltip-nohelp text-danger" style="text-align: center;cursor: pointer;">0</div> - <div data-bs-toggle="tooltip" title="Most common fronter (deprecated)" id="binary-bit-33" class="font-monospace tooltip-nohelp" style="color:#383838;text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-32" class="text-muted font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-33" class="text-muted font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;">0</div> <div data-bs-toggle="tooltip" title="1st species" id="binary-bit-34" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#fab277;">0</div> <div data-bs-toggle="tooltip" title="1st species" id="binary-bit-35" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#fab277;">0</div> <div data-bs-toggle="tooltip" title="1st species" id="binary-bit-36" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#fab277;">0</div> @@ -75,18 +75,18 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; <div data-bs-toggle="tooltip" title="2nd species" id="binary-bit-39" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#faf377;">0</div> <div data-bs-toggle="tooltip" title="2nd species" id="binary-bit-40" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#faf377;">0</div> <div data-bs-toggle="tooltip" title="2nd species" id="binary-bit-41" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#faf377;">0</div> - <div data-bs-toggle="tooltip" title="3rd species" id="binary-bit-42" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#abfa77;">0</div> - <div data-bs-toggle="tooltip" title="3rd species" id="binary-bit-43" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#abfa77;">0</div> - <div data-bs-toggle="tooltip" title="3rd species" id="binary-bit-44" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#abfa77;">0</div> - <div data-bs-toggle="tooltip" title="3rd species" id="binary-bit-45" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#abfa77;">0</div> + <div data-bs-toggle="tooltip" title="Romantic alignment" id="binary-bit-42" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color: #4d5cff;">0</div> + <div data-bs-toggle="tooltip" title="Romantic alignment" id="binary-bit-43" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color: #4d5cff;">0</div> + <div data-bs-toggle="tooltip" title="Romantic alignment" id="binary-bit-44" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color: #4d5cff;">0</div> + <div data-bs-toggle="tooltip" title="Romantic alignment" id="binary-bit-45" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color: #4d5cff;">0</div> <div data-bs-toggle="tooltip" title="Robot" id="binary-bit-46" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;">0</div> <div data-bs-toggle="tooltip" title="Plush" id="binary-bit-47" class="font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;color:#6610f2;">0</div> - <div data-bs-toggle="tooltip" title="Affected by age spells (deprecated)" id="binary-bit-48" class="font-monospace tooltip-nohelp" style="color:#383838;text-align: center;cursor: pointer;">0</div> + <div data-bs-toggle="tooltip" title="Value reserved for future use" id="binary-bit-48" class="text-muted font-monospace tooltip-nohelp" style="text-align: center;cursor: pointer;">0</div> </div> <br> <p> - <b>Input:</b> <input onchange="calculateInput();" onkeydown="calculateInput()" onkeyup="calculateInput()" value="2048" id="input" type="number" class="form-control" style="width:256px;display: inline-block;color:white;background:#111;border-color:#222;" maxlength="15" max="281474976710655" min="2048"><br> - <b>Output:</b> <code id="output-bin">0b000000000000000000000000000000000000100000000000</code>, <code id="output-hex">0x000008000000</code>, <code id="output-dec">2048</code> + <input onchange="calculateInput();" onkeydown="calculateInput()" onkeyup="calculateInput()" value="2048" id="input" type="number" class="form-control" style="width:256px;display: inline-block;color:white;background:#111;border-color:#222;" maxlength="15" max="281474976710655" min="2048"><br> + <code id="output-bin">0b000000000000000000000000000000000000100000000000</code>, <code id="output-hex">0x000008000000</code>, <code id="output-dec">2048</code> </p> <script> for (let i = 1; i <= 48; i++) { @@ -113,130 +113,112 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; } } - let sharedMemory = parseInt(binString.substring(8 + 16, 10 + 16), 2); - let median = binString.substring(10 + 16, 11 + 16) !== "0"; - let little = parseInt(binString.substring(11 + 16, 13 + 16), 2); - let protector = binString.substring(13 + 16, 14 + 16) !== "0"; - let fictive = binString.substring(14 + 16, 15 + 16) !== "0"; - let notTalking = binString.substring(15 + 16, 16 + 16) !== "0"; - let host = binString.substring(16 + 16, 17 + 16) !== "0"; - let robot = binString.substring(29 + 16, 30 + 16) !== "0"; - let plush = binString.substring(30 + 16, 31 + 16) !== "0"; - let species1 = binString.substring(17 + 16, 21 + 16); - let species2 = binString.substring(21 + 16, 25 + 16); - let species3 = binString.substring(25 + 16, 29 + 16); - let food = parseInt(binString.substring(16, 2 + 16), 2); - let magic = parseInt(binString.substring(2 + 16, 5 + 16), 2); - let sensitivity = parseInt(binString.substring(5 + 16, 8 + 16), 2); - let ageSpells = binString.substring(31 + 16, 32 + 16) !== "0"; - let nonverbal = binString.substring(15, 16) !== "0"; - let lessFrequent = binString.substring(14, 15) !== "0"; - let sexuallyActive = binString.substring(13, 14) !== "0"; - let ageRegressor = binString.substring(12, 13) !== "0"; - let leader = binString.substring(11, 12) !== "0"; - let persecutor = binString.substring(10, 11) !== "0"; - - document.getElementById("value-0").value = sharedMemory; - document.getElementById("value-1").value = little; - document.getElementById("value-2").value = species1; - document.getElementById("value-3").value = species2; - document.getElementById("value-4").checked = median; - document.getElementById("value-5").checked = protector; - document.getElementById("value-6").checked = fictive; - document.getElementById("value-7").checked = notTalking; - document.getElementById("value-8").checked = host; - document.getElementById("value-9").checked = robot; - document.getElementById("value-10").checked = plush; - document.getElementById("value-11").value = food; - document.getElementById("value-12").value = magic; - document.getElementById("value-13").value = sensitivity; - document.getElementById("value-14").value = species3; - document.getElementById("value-15").checked = ageSpells; - document.getElementById("value-16").checked = nonverbal; - document.getElementById("value-17").checked = lessFrequent; - document.getElementById("value-18").checked = sexuallyActive; - document.getElementById("value-19").checked = ageRegressor; - document.getElementById("value-20").checked = leader; - document.getElementById("value-21").checked = persecutor; + display(binString); + setColors(); } - } - - function calculateOutput() { - let bin = [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null].map((_, i) => { - let e = i + 1; - return document.getElementById("binary-bit-" + e).innerText; - }).join(""); - document.getElementById("output-bin").innerText = "0b" + bin; - - let hex = parseInt(bin, 2).toString(16); - - document.getElementById("output-hex").innerText = "0x" + "0".repeat(12 - hex.length) + hex; - document.getElementById("output-dec").innerText = parseInt(bin, 2).toString(); - document.getElementById("input").value = parseInt(bin, 2).toString(); + setColors() } - function calculateInput() { - if (parseInt(document.getElementById("input").value).toString().length > 15) return; - - let binString = ("0".repeat(48 - parseInt(document.getElementById("input").value).toString(2).length)) + parseInt(document.getElementById("input").value).toString(2); - let bin = binString.split("").map((i) => parseInt(i)); - + function setColors() { for (let i = 1; i <= 48; i++) { - if (bin[i - 1]) { - document.getElementById("binary-bit-" + i).innerText = bin[i - 1].toString(); + let e = document.getElementById("binary-bit-" + i); + if (e.title !== "Value reserved for future use") { + e.style.color = ""; + + e.classList.remove("text-info"); + e.classList.remove("text-warning"); + e.classList.remove("text-light"); + e.classList.remove("text-dark"); + + if (e.innerText === "0") { + e.classList.remove("text-success"); + e.classList.add("text-danger"); + } else { + e.classList.add("text-success"); + e.classList.remove("text-danger"); + } } else { - document.getElementById("binary-bit-" + i).innerText = "0"; + e.style.cursor = "not-allowed"; + e.onclick = null; } } + } + function display(binString) { let sharedMemory = parseInt(binString.substring(8 + 16, 10 + 16), 2); - let median = binString.substring(10 + 16, 11 + 16) !== "0"; let little = parseInt(binString.substring(11 + 16, 13 + 16), 2); let protector = binString.substring(13 + 16, 14 + 16) !== "0"; let fictive = binString.substring(14 + 16, 15 + 16) !== "0"; - let notTalking = binString.substring(15 + 16, 16 + 16) !== "0"; - let host = binString.substring(16 + 16, 17 + 16) !== "0"; let robot = binString.substring(29 + 16, 30 + 16) !== "0"; let plush = binString.substring(30 + 16, 31 + 16) !== "0"; - let ageSpells = binString.substring(31 + 16, 32 + 16) !== "0"; let species1 = binString.substring(17 + 16, 21 + 16); let species2 = binString.substring(21 + 16, 25 + 16); - let species3 = binString.substring(25 + 16, 29 + 16); let food = parseInt(binString.substring(16, 2 + 16), 2); let nonverbal = binString.substring(15, 16) !== "0"; let lessFrequent = binString.substring(14, 15) !== "0"; - let magic = parseInt(binString.substring(2 + 16, 5 + 16), 2); - let sensitivity = parseInt(binString.substring(5 + 16, 8 + 16), 2); let sexuallyActive = binString.substring(13, 14) !== "0"; - let ageRegressor = binString.substring(12, 13) !== "0"; let leader = binString.substring(11, 12) !== "0"; let persecutor = binString.substring(10, 11) !== "0"; + let polyamorous1 = binString.substring(18, 19) !== "0"; + let polyamorous2 = binString.substring(19, 20) !== "0"; + let alignment1 = binString.substring(20, 24); + let alignment2 = binString.substring(25 + 16, 29 + 16); document.getElementById("value-0").value = sharedMemory; document.getElementById("value-1").value = little; document.getElementById("value-2").value = species1; document.getElementById("value-3").value = species2; - document.getElementById("value-11").value = food; - document.getElementById("value-12").value = magic; - document.getElementById("value-13").value = sensitivity; - document.getElementById("value-4").checked = median; document.getElementById("value-5").checked = protector; document.getElementById("value-6").checked = fictive; - document.getElementById("value-7").checked = notTalking; - document.getElementById("value-8").checked = host; document.getElementById("value-9").checked = robot; document.getElementById("value-10").checked = plush; - document.getElementById("value-14").value = species3; - document.getElementById("value-15").checked = ageSpells; + document.getElementById("value-11").value = food; document.getElementById("value-16").checked = nonverbal; document.getElementById("value-17").checked = lessFrequent; document.getElementById("value-18").checked = sexuallyActive; - document.getElementById("value-19").checked = ageRegressor; document.getElementById("value-20").checked = leader; document.getElementById("value-21").checked = persecutor; + document.getElementById("value-22").checked = polyamorous1; + document.getElementById("value-23").checked = polyamorous2; + document.getElementById("value-24").value = alignment1; + document.getElementById("value-25").value = alignment2; + + setColors(); + } + + function calculateOutput() { + let bin = [null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null].map((_, i) => { + let e = i + 1; + return document.getElementById("binary-bit-" + e).innerText; + }).join(""); + + document.getElementById("output-bin").innerText = "0b" + bin; + + let hex = parseInt(bin, 2).toString(16); + + document.getElementById("output-hex").innerText = "0x" + "0".repeat(12 - hex.length) + hex; + document.getElementById("output-dec").innerText = parseInt(bin, 2).toString(); + document.getElementById("input").value = parseInt(bin, 2).toString(); + } + function calculateInput() { + if (parseInt(document.getElementById("input").value).toString().length > 15) return; + + let binString = ("0".repeat(48 - parseInt(document.getElementById("input").value).toString(2).length)) + parseInt(document.getElementById("input").value).toString(2); + let bin = binString.split("").map((i) => parseInt(i)); + + for (let i = 1; i <= 48; i++) { + if (bin[i - 1]) { + document.getElementById("binary-bit-" + i).innerText = bin[i - 1].toString(); + } else { + document.getElementById("binary-bit-" + i).innerText = "0"; + } + } + + display(binString); calculateOutput(); + setColors(); return bin; } @@ -246,24 +228,20 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; let val1 = document.getElementById("value-1").value; let val2 = document.getElementById("value-2").value; let val3 = document.getElementById("value-3").value; - let val4 = document.getElementById("value-4").checked; let val5 = document.getElementById("value-5").checked; let val6 = document.getElementById("value-6").checked; - let val7 = document.getElementById("value-7").checked; - let val8 = document.getElementById("value-8").checked; let val9 = document.getElementById("value-9").checked; let val10 = document.getElementById("value-10").checked; let val11 = document.getElementById("value-11").value; - let val12 = document.getElementById("value-12").value; - let val13 = document.getElementById("value-13").value; - let val14 = document.getElementById("value-14").value; - let val15 = document.getElementById("value-15").checked; let val16 = document.getElementById("value-16").checked; let val17 = document.getElementById("value-17").checked; let val18 = document.getElementById("value-18").checked; - let val19 = document.getElementById("value-19").checked; let val20 = document.getElementById("value-20").checked; let val21 = document.getElementById("value-21").checked; + let val22 = document.getElementById("value-22").checked; + let val23 = document.getElementById("value-23").checked; + let val24 = document.getElementById("value-24").value; + let val25 = document.getElementById("value-25").value; let val0bin = parseInt(val0).toString(2); val0bin = val0bin.length === 1 ? "0" + val0bin : val0bin; @@ -274,32 +252,30 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; let val11bin = parseInt(val11).toString(2); val11bin = val11bin.length === 1 ? "0" + val11bin : val11bin; - let val12bin = parseInt(val12).toString(2); - val12bin = val12bin.length === 1 ? "00" + val12bin : (val12bin.length === 2 ? "0" + val12bin : val12bin); - - let val13bin = parseInt(val13).toString(2); - val13bin = val13bin.length === 1 ? "00" + val13bin : (val13bin.length === 2 ? "0" + val13bin : val13bin); - let val2bin = val2; let val3bin = val3; - let val14bin = val14; + let val24bin = val24; + let val25bin = val25; + + let val4bin = "0"; + let val7bin = "0"; + let val8bin = "0"; + let val15bin = "0"; + let val19bin = "0"; - let val4bin = val4 ? "1" : "0"; let val5bin = val5 ? "1" : "0"; let val6bin = val6 ? "1" : "0"; - let val7bin = val7 ? "1" : "0"; - let val8bin = val8 ? "1" : "0"; let val9bin = val9 ? "1" : "0"; let val10bin = val10 ? "1" : "0"; - let val15bin = val15 ? "1" : "0"; let val16bin = val16 ? "1" : "0"; let val17bin = val17 ? "1" : "0"; let val18bin = val18 ? "1" : "0"; - let val19bin = val19 ? "1" : "0"; let val20bin = val20 ? "1" : "0"; let val21bin = val21 ? "1" : "0"; + let val22bin = val22 ? "1" : "0"; + let val23bin = val23 ? "1" : "0"; - let bin = "0000000000" + val21bin + val20bin + val19bin + val18bin + val17bin + val16bin + val11bin + val12bin + val13bin + val0bin + val4bin + val1bin + val5bin + val6bin + val7bin + val8bin + val2bin + val3bin + val14bin + val9bin + val10bin + val15bin; + let bin = "0000000000" + val21bin + val20bin + val19bin + val18bin + val17bin + val16bin + val11bin + val22bin + val23bin + val24bin + val0bin + val4bin + val1bin + val5bin + val6bin + val7bin + val8bin + val2bin + val3bin + val25bin + val9bin + val10bin + val15bin; console.log(bin, parseInt(bin, 2)); @@ -314,85 +290,107 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; } calculateOutput(); + setColors(); } </script> + <table style="margin-bottom: 1rem;"> + <tbody> + <tr> + <td style="padding-right: 10px; text-align: right;"> + <b>Shared memory access: </b> + </td> + <td> + <select class="tooltip-nohelp form-select" style='display:inline-block;width:max-content;color:white;background-color:#111;border-color:#222;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' id="value-0" onchange="updateFromSelection();"> + <option value="2">Full direct access</option> + <option value="1">Partial direct access</option> + <option value="0" selected>No direct access</option> + </select> + </td> + </tr><tr> + <td style="padding-right: 10px; text-align: right;"> + <b>Food: </b> + </td> + <td> + <select class="tooltip-nohelp form-select" style='display:inline-block;width:max-content;color:white;background-color:#111;border-color:#222;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' id="value-11" onchange="updateFromSelection();"> + <option value="0" selected>Doesn't need to eat</option> + <option value="1">Can't eat fish or meat</option> + <option value="2">Can't eat meat</option> + <option value="3">Can eat everything</option> + </select> + </td> + </tr><tr> + <td style="padding-right: 10px; text-align: right;"> + <b>Little/younger: </b> + </td> + <td> + <select class="tooltip-nohelp form-select" style='display:inline-block;width:max-content;color:white;background-color:#111;border-color:#222;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' id="value-1" onchange="updateFromSelection();"> + <option value="0" selected>None</option> + <option value="2">Little</option> + <option value="3">Younger</option> + <option value="1" disabled>Age regressor (old)</option> + </select> + </td> + </tr><tr> + <td style="padding-right: 10px; text-align: right;"> + <b>Species: </b> + </td> + <td> + <select class="tooltip-nohelp form-select" style='display:inline-block;width:max-content;color:white;background-color:#111;border-color:#222;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' id="value-2" onchange="updateFromSelection();"> + <option value="0000" disabled>None</option> + <option value="0001">Earth pony</option> + <option value="0010">Unicorn</option> + <option value="0011">Pegasus</option> + <option value="0100">Alicorn</option> + <option value="0101">Bat pony</option> + <option value="0110">Crystal pony</option> + <option value="0111">Changeling</option> + </select> + <select class="tooltip-nohelp form-select" style='display:inline-block;width:max-content;color:white;background-color:#111;border-color:#222;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' id="value-3" onchange="updateFromSelection();"> + <option value="0000">None</option> + <option value="0001">Earth pony</option> + <option value="0010">Unicorn</option> + <option value="0011">Pegasus</option> + <option value="0100">Alicorn</option> + <option value="0101">Bat pony</option> + <option value="0110">Crystal pony</option> + <option value="0111">Changeling</option> + </select> + <select class="tooltip-nohelp form-select" style='display:none;width:max-content;color:white;background-color:#111;border-color:#222;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' id="value-14" onchange="updateFromSelection();"> + <option value="0000">None</option> + <option value="0001">Earth pony</option> + <option value="0010">Unicorn</option> + <option value="0011">Pegasus</option> + <option value="0100">Alicorn</option> + <option value="0101">Bat pony</option> + <option value="0110">Crystal pony</option> + <option value="0111">Changeling</option> + </select> + </td> + </tr><tr> + <td style="padding-right: 10px; text-align: right;"> + <b>Alignment: </b> + </td> + <td> + <select class="tooltip-nohelp form-select" style='display:inline-block;width:max-content;color:white;background-color:#111;border-color:#222;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' id="value-24" onchange="updateFromSelection();"> + <option value="0000">Asexual</option> + <option value="0001">Heterosexual</option> + <option value="0010">Homosexual</option> + <option value="0011">Bisexual</option> + <option value="0100">Pansexual</option> + </select> + <select class="tooltip-nohelp form-select" style='display:inline-block;width:max-content;color:white;background-color:#111;border-color:#222;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' id="value-25" onchange="updateFromSelection();"> + <option value="0000">Aromantic</option> + <option value="0001">Heteroromantic</option> + <option value="0010">Homoromantic</option> + <option value="0011">Biromantic</option> + <option value="0100">Panromantic</option> + </select> + </td> + </tr> + </tbody> + </table> <p> - <b>Shared memory access: </b><select class="tooltip-nohelp form-select" style='display:inline-block;width:max-content;color:white;background-color:#111;border-color:#222;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' id="value-0" onchange="updateFromSelection();"> - <option value="2">Full direct access</option> - <option value="1">Partial direct access</option> - <option value="0" selected>No direct access</option> - </select> - <br> - <b>Food: </b><select class="tooltip-nohelp form-select" style='display:inline-block;width:max-content;color:white;background-color:#111;border-color:#222;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' id="value-11" onchange="updateFromSelection();"> - <option value="0" selected>Doesn't need to eat</option> - <option value="1">Can't eat fish or meat</option> - <option value="2">Can't eat meat</option> - <option value="3">Can eat everything</option> - </select> - <br> - <b>Little/younger: </b><select class="tooltip-nohelp form-select" style='display:inline-block;width:max-content;color:white;background-color:#111;border-color:#222;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' id="value-1" onchange="updateFromSelection();"> - <option value="0" selected>None</option> - <option value="2">Little</option> - <option value="3">Younger</option> - <option value="1" disabled>Age regressor (old)</option> - </select> - <br> - <b>Species: </b><select class="tooltip-nohelp form-select" style='display:inline-block;width:max-content;color:white;background-color:#111;border-color:#222;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' id="value-2" onchange="updateFromSelection();"> - <option value="0000" disabled>None</option> - <option value="0001">Earth pony</option> - <option value="0010">Unicorn</option> - <option value="0011">Pegasus</option> - <option value="0100">Alicorn</option> - <option value="0101">Bat pony</option> - <option value="0110">Crystal pony</option> - <option value="0111">Changeling</option> - </select> - <select class="tooltip-nohelp form-select" style='display:inline-block;width:max-content;color:white;background-color:#111;border-color:#222;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' id="value-3" onchange="updateFromSelection();"> - <option value="0000">None</option> - <option value="0001">Earth pony</option> - <option value="0010">Unicorn</option> - <option value="0011">Pegasus</option> - <option value="0100">Alicorn</option> - <option value="0101">Bat pony</option> - <option value="0110">Crystal pony</option> - <option value="0111">Changeling</option> - </select> - <select class="tooltip-nohelp form-select" style='display:inline-block;width:max-content;color:white;background-color:#111;border-color:#222;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' id="value-14" onchange="updateFromSelection();"> - <option value="0000">None</option> - <option value="0001">Earth pony</option> - <option value="0010">Unicorn</option> - <option value="0011">Pegasus</option> - <option value="0100">Alicorn</option> - <option value="0101">Bat pony</option> - <option value="0110">Crystal pony</option> - <option value="0111">Changeling</option> - </select> - <br> - <div style="display: none;"> - <b>Magic: </b><select class="tooltip-nohelp form-select" style='display:inline-block;width:max-content;color:white;background-color:#111;border-color:#222;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' id="value-12" onchange="updateFromSelection();"> - <option value="0" selected>Can't use magic</option> - <option value="1" disabled>Can use magic in some cases (deprecated)</option> - <option value="2">Can use magic with a horn</option> - <option value="3">Can use magic with wings</option> - <option value="4">Can use magic with wings and a horn</option> - <option value="5">Can use magic with another part of the body</option> - </select> - <br> - </div> - <b>Sensitivity: </b><select class="tooltip-nohelp form-select" style='display:inline-block;width:max-content;color:white;background-color:#111;border-color:#222;background-image:url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");' id="value-13" onchange="updateFromSelection();"> - <option value="0" selected>None</option> - <option value="1" disabled>May be sensitive (deprecated)</option> - <option value="2">Affectionately sensitive</option> - <option value="3">Sexually sensitive</option> - <option value="4" disabled>Sensitive in both ways (deprecated)</option> - </select> - </p> - <p> - <label style="margin-bottom:5px;"> - <input type="checkbox" id="value-4" onchange="updateFromSelection();"> - Part of a median system - </label><br> <label style="margin-bottom:5px;"> <input type="checkbox" id="value-5" onchange="updateFromSelection();"> Protector @@ -407,11 +405,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; </label><br> <label style="margin-bottom:5px;"> <input type="checkbox" id="value-18" onchange="updateFromSelection();"> - Sexually active - </label><br> - <label style="margin-bottom:5px;"> - <input type="checkbox" id="value-7" onchange="updateFromSelection();"> - Not talking + Preemptive sexual consent </label><br> <label style="margin-bottom:5px;"> <input type="checkbox" id="value-9" onchange="updateFromSelection();"> @@ -422,6 +416,14 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; Plush </label><br> <label style="margin-bottom:5px;"> + <input type="checkbox" id="value-22" onchange="updateFromSelection();"> + Polyamorous (romantic) + </label><br> + <label style="margin-bottom:5px;"> + <input type="checkbox" id="value-23" onchange="updateFromSelection();"> + Polyamorous (sexual) + </label><br> + <label style="margin-bottom:5px;"> <input type="checkbox" id="value-16" onchange="updateFromSelection();"> Non verbal in real life </label><br> @@ -435,26 +437,14 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; </label><br> </p> - <hr> - <details> - <summary>Show deprecated options</summary> - - <br> - <p> - <label style="margin-bottom:5px;"> - <input type="checkbox" id="value-8" onchange="updateFromSelection();"> - Most common fronter - </label><img alt="" src="/assets/icons/visibility-public.svg" style="filter:invert(1);width:24px;margin-left:5px;margin-top:-5px;" title="This information will be shown publicly" data-bs-toggle="tooltip"><br> - <label style="margin-bottom:5px;"> - <input type="checkbox" id="value-15" onchange="updateFromSelection();"> - Affected by age spells - </label><img alt="" src="/assets/icons/visibility-private.svg" style="filter:invert(1);width:24px;margin-left:5px;margin-top:-5px;" title="This information will remain private" data-bs-toggle="tooltip"><br> - <label style="margin-bottom:5px;"> - <input type="checkbox" id="value-19" onchange="updateFromSelection();"> - Age regressor - </label><img alt="" src="/assets/icons/visibility-public.svg" style="filter:invert(1);width:24px;margin-left:5px;margin-top:-5px;" title="This information will be shown publicly" data-bs-toggle="tooltip"><br> - </p> - </details> + <div id="deprecated-options" style="display: none;"> + <hr> + <details> + <summary>Show deprecated options</summary> + + <p>Nothing here lol</p> + </details> + </div> </div> <?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.inc'; ?> diff --git a/pages/page.inc b/pages/page.inc index d13dd2f..f3859d3 100644 --- a/pages/page.inc +++ b/pages/page.inc @@ -38,11 +38,13 @@ $systemID = $system === "cloudburst" ? "ynmuc" : "gdapd"; if ($member === null) { global $_SystemName; $_SystemName = $system; + $pageFile = $_SERVER['DOCUMENT_ROOT'] . '/includes/system.inc'; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/system.inc'; } else if ($member === "-" && isset($parts[2])) { if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/includes/system/' . $parts[2] . '.inc')) { global $_SystemPage; $_SystemPage = $parts[2]; + $pageFile = $_SERVER['DOCUMENT_ROOT'] . '/includes/system/' . $parts[2] . '.inc'; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/system/' . $parts[2] . '.inc'; } else { header("Location: /?error=" . $lang["page"]["system"] . " " . $parts[2]) and die(); @@ -89,6 +91,7 @@ if ($member === null) { if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/includes/member/' . $parts[3] . '.inc')) { global $_MemberPage; $_MemberPage = $parts[3]; + $pageFile = $_SERVER['DOCUMENT_ROOT'] . '/includes/member/' . $parts[3] . '.inc'; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/member/' . $parts[3] . '.inc'; } else { header("Location: /?error=" . $lang["page"]["system"] . " " . $parts[3]) and die(); @@ -98,6 +101,7 @@ if ($member === null) { global $_MemberName; $_MemberName = $member; + $pageFile = $_SERVER['DOCUMENT_ROOT'] . '/includes/member.inc'; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/member.inc'; } diff --git a/pages/relations.inc b/pages/relations.inc index ce0d65c..8d14fe7 100644 --- a/pages/relations.inc +++ b/pages/relations.inc @@ -15,8 +15,8 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; } else { return true; } - })) as $member): if (count($member["_metadata"]["marefriends"]) > 0 || count($member["_metadata"]["sisters"]) > 0 || count($member["_metadata"]["caretakers"]) > 0): ?> - <div class="relation" style="background-color:rgba(255, 255, 255, .1);margin-bottom:10px;padding:10px;border-radius:10px;display:grid;grid-template-columns: 1.5fr <?= $member["_metadata"]["little"] === 2 ? "2fr 2fr 2fr" : "3fr 3fr" ?>;"> + })) as $member): ?> + <div class="relation" style="background-color:rgba(255, 255, 255, .1);margin-bottom:10px;padding:10px;border-radius:10px;display:grid;grid-template-columns: 1.5fr 2fr 2fr 2fr;"> <a class="relation-intro" style="background-color:rgba(255, 255, 255, .05);border-right:1px solid rgba(255, 255, 255, .1);margin:-10px;padding:10px;border-top-left-radius:10px;border-bottom-left-radius:10px;color: white;text-decoration: none;" href="/<?= $member["name"] ?>"> <img src="<?= getAsset($member["system"], $member["id"], "heads") ?>" style="width:24px;"> <?= $member["display_name"] ?? $member["name"] ?> </a> @@ -55,8 +55,8 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; </tr></tbody> </table> - <?php if ($member["_metadata"]["little"] === 2): ?> - <table class="relation-item relation-item-sisters" style="padding:0 20px;"> + <?php if ($member["_metadata"]["little"] >= 2): ?> + <table class="relation-item relation-item-caretakers" style="padding:0 20px;"> <tbody><tr> <td style="width: 50%;text-align:right;"> <b style="padding-right:5px;"><?= $lang["relations"]["caretakers"] ?></b><span class="list-separator-mobile"><br></span> @@ -74,7 +74,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; </table> <?php endif; ?> </div> - <?php endif; endforeach; ?> + <?php endforeach; ?> </div> <style> diff --git a/pages/rules-old.inc b/pages/rules-old.inc index 1fd7f94..a567bc5 100644 --- a/pages/rules-old.inc +++ b/pages/rules-old.inc @@ -1,253 +1,4 @@ <?php -require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; - -if (isset($_POST["updateRules"])) { - header("Content-Type: text/plain"); - - if (!isset($_POST['payload'])) { - header("Location: /-/rules"); - die(); - } - - foreach ($_POST['payload'] as $index => $rule) { - if (!isset($rule["name"]) || !isset($rule["content"]) && !is_numeric($index)) { - header("Location: /-/rules"); - die(); - } - - if (trim($rule["name"]) === "") { - unset($_POST["payload"][$index]); - continue; - } - - if (!isset($rule["approved"])) $rule["approved"] = []; - if (isset($rule["approved"][0])) $rule["approved"][0] = true; else $rule["approved"][0] = false; - if (isset($rule["approved"][1])) $rule["approved"][1] = true; else $rule["approved"][1] = false; - - $_POST["payload"][$index] = $rule; - } - - file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/rules/rules.json", utf8_encode(json_encode($_POST["payload"]))); - - header("Location: /-/rules"); - die(); -} - -require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; - -?> - -<br> -<div class="container"> - <div id="page-content"> - <h2>Systems rules</h2> - <p>Click on a rule to view additional details. <a onclick="event.target.blur();" href="#" data-bs-toggle="modal" data-bs-target="#editor">Edit rules</a></p> - - <?php - - $rules = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/rules/rules.json"), true); - - $protectorCloudburst = array_values(array_filter(scoreOrderGlobal(), function ($i) { - return $i["_system"] === "ynmuc" && $i["_metadata"]["protector"]; - }))[0]; - $protectorRaindrops = array_values(array_filter(scoreOrderGlobal(), function ($i) { - return $i["_system"] === "gdapd" && $i["_metadata"]["protector"]; - }))[0]; - - $pcName = getMiniName($protectorCloudburst["display_name"] ?? $protectorCloudburst["name"]); - $prName = getMiniName($protectorRaindrops["display_name"] ?? $protectorRaindrops["name"]); - - ?> - - <ul class="list-group"> - <?php $index = 1; foreach ($rules as $rule): ?> - <li class="list-group-item rule-outer"> - <details> - <summary class="rule"> - <b><?= $index ?>. <?= strip_tags($rule["name"]) ?></b> - <?php if (in_array(false, $rule["approved"])): ?> - <span class="badge bg-warning text-black rounded-pill">Unapproved</span> - <?php endif; ?> - </summary> - <?php if (in_array(false, $rule["approved"])): ?> - <div style="margin-top:10px;" class="alert alert-warning"> - <b>This rule has not yet been approved.</b> All rules need to be approved by the leaders from both systems. This rule is still missing approval from <?php - - if ($rule["approved"][0] === false) { - if ($rule["approved"][1] === false) { - echo($pcName . " and " . $prName); - } else { - echo($pcName); - } - } else if ($rule["approved"][1] === false) { - echo($prName); - } - - ?>. - </div> - <?php endif; ?> - <div <?= !in_array(false, $rule["approved"]) ? 'style="margin-top:10px;"' : '' ?> class="list-group-item"> - <?= strip_tags($rule["content"]) ?> - </div> - </details> - </li> - <?php $index++; endforeach; ?> - </ul> - </div> -</div> - -<div class="modal fade" id="editor"> - <div class="modal-dialog"> - <div class="modal-content"> - <div class="modal-header"> - <h4 class="modal-title">Rules editor</h4> - <button type="button" class="btn-close" data-bs-dismiss="modal"></button> - </div> - - <div class="modal-body"> - <p>Rules with an empty name are automatically deleted. Buttons to add new rules and save the changes are at the bottom of the list.</p> - <hr> - <form method="post"> - <div id="rules-editor"> - <?php $index = 1; foreach ($rules as $rule): ?> - <div <?= $index === 1 ? 'id="default-rule"' : '' ?>> - <p><b <?= $index === 1 ? 'id="default-rule--number"' : '' ?>>Rule #<?= $index ?>:</b></p> - <input <?= $index === 1 ? 'id="default-rule--name"' : '' ?> type="text" placeholder="Rule name" class="form-control" style="margin-bottom:15px;color:white;background:#111;border-color:#222;" name="payload[<?= $index - 1 ?>][name]" value="<?= str_replace('"', """, strip_tags($rule["name"])) ?>"> - - <textarea <?= $index === 1 ? 'id="default-rule--content"' : '' ?> name="payload[<?= $index - 1 ?>][content]" class="form-control" style="resize: none;color:white;background:#111;border-color:#222;" placeholder="Rule details"><?= strip_tags($rule["content"] ?? "") ?></textarea> - - <label style="margin-top:10px;margin-left:5px;"> - <input <?= $index === 1 ? 'id="default-rule--approval-1"' : '' ?> <?= ($rule["approved"][0] ?? false) ? "checked" : "" ?> type="checkbox" name="payload[<?= $index - 1 ?>][approved][0]"> - Approved by <?= $pcName ?> - </label><br> - <label style="margin-left:5px;"> - <input <?= $index === 1 ? 'id="default-rule--approval-2"' : '' ?> <?= ($rule["approved"][1] ?? false) ? "checked" : "" ?> type="checkbox" name="payload[<?= $index - 1 ?>][approved][1]"> - Approved by <?= $prName ?> - </label><br> - - <hr> - </div> - <?php $index++; endforeach; ?> - </div> - <input type="submit" value="Save" class="btn btn-primary"> - <a onclick="editorNewRule();" class="btn btn-secondary">New rule</a> - <input type="hidden" name="updateRules"> - </form> - </div> - </div> - </div> -</div> - -<script> - window.numberOfRules = <?= count($rules) ?>; - - Array.from(document.getElementsByClassName("rule-outer")).forEach((el) => { - let details = el.children[0]; - - el.onclick = () => { - Array.from(document.getElementsByClassName("rule-outer")).forEach((sel) => { - if (el === sel) return; - sel.children[0].open = false; - sel.classList.remove("open"); - }); - - details.open = !details.open; - - if (details.open) { - el.classList.add("open"); - } else { - el.classList.remove("open"); - } - } - }) - - function editorNewRule() { - let id = Math.random(36).toString().split(".")[1]; - - document.getElementById("default-rule").id = "added-" + id + "-1"; - document.getElementById("default-rule--number").id = "added-" + id + "-2"; - document.getElementById("default-rule--name").id = "added-" + id + "-3"; - document.getElementById("default-rule--content").id = "added-" + id + "-4"; - document.getElementById("default-rule--approval-1").id = "added-" + id + "-5"; - document.getElementById("default-rule--approval-2").id = "added-" + id + "-6"; - - let child = document.createElement("div"); - child.id = "temp-" + id; - window.numberOfRules++; - - document.getElementById("rules-editor").appendChild(child); - document.getElementById("temp-" + id).outerHTML = document.getElementById("added-" + id + "-1").outerHTML; - - document.getElementById("added-" + id + "-1").id = "default-rule"; - document.getElementById("added-" + id + "-2").id = "default-rule--number"; - document.getElementById("added-" + id + "-3").id = "default-rule--name"; - document.getElementById("added-" + id + "-4").id = "default-rule--content"; - document.getElementById("added-" + id + "-5").id = "default-rule--approval-1"; - document.getElementById("added-" + id + "-6").id = "default-rule--approval-2"; - - document.getElementById("added-" + id + "-3").name = "payload[" + (numberOfRules - 1) + "][name]"; - document.getElementById("added-" + id + "-4").name = "payload[" + (numberOfRules - 1) + "][content]"; - document.getElementById("added-" + id + "-5").name = "payload[" + (numberOfRules - 1) + "][approved][0]"; - document.getElementById("added-" + id + "-6").name = "payload[" + (numberOfRules - 1) + "][approved][1]"; - - document.getElementById("added-" + id + "-5").checked = false; - document.getElementById("added-" + id + "-6").checked = false; - document.getElementById("added-" + id + "-3").value = ""; - document.getElementById("added-" + id + "-4").value = ""; - document.getElementById("added-" + id + "-2").innerText = "Rule #" + numberOfRules + ":"; - } -</script> - -<style> - .list-group-item { - color: #fff; - background-color: #222; - border: 1px solid rgba(255, 255, 255, .125); - } - - .list-group-item.disabled { - color: #fff; - background-color: #222; - border-color: rgba(255, 255, 255, .125); - opacity: .75; - } - - .rule-outer:hover { - background-color: #252525; - color: #ddd; - } - - .rule-outer:active, .rule-outer:focus { - background-color: #272727; - color: #bbb; - } - - .rule-outer.open { - background-color: #333; - } - - .rule { - list-style: none; - pointer-events: none; - } - - .rule-outer { - cursor: pointer; - } - - .modal-header { - border-bottom: 1px solid #353738; - } - - .modal-content { - border: 1px solid rgba(255, 255, 255, .2); - background-color: #111; - } - - .btn-close { - filter: invert(1); - } -</style> - -<?php require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/footer.inc'; ?> +header("Location: /-/rules"); +die();
\ No newline at end of file diff --git a/pages/rules.inc b/pages/rules.inc index cf88eb1..2268e75 100644 --- a/pages/rules.inc +++ b/pages/rules.inc @@ -1,6 +1,40 @@ <?php require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/init.inc"; global $title; global $isLoggedIn; global $lang; global $pages; +require_once $_SERVER['DOCUMENT_ROOT'] . "/includes/Parsedown.php"; $Parsedown = new Parsedown(); + +if (isset($_POST["updateRules"])) { + header("Content-Type: text/plain"); + + if (!isset($_POST['payload'])) { + header("Location: /-/rules"); + die(); + } + + foreach ($_POST['payload'] as $index => $rule) { + if (!isset($rule["name"]) || !isset($rule["content"]) && !is_numeric($index)) { + header("Location: /-/rules"); + die(); + } + + if (trim($rule["name"]) === "") { + unset($_POST["payload"][$index]); + continue; + } + + if (!isset($rule["approved"])) $rule["approved"] = []; + if (isset($rule["approved"][0])) $rule["approved"][0] = true; else $rule["approved"][0] = false; + if (isset($rule["approved"][1])) $rule["approved"][1] = true; else $rule["approved"][1] = false; + + $_POST["payload"][$index] = $rule; + } + + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/rules/rules.json", utf8_encode(json_encode($_POST["payload"]))); + + header("Location: /-/rules"); + die(); +} + require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; ?> @@ -8,95 +42,159 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; <br> <div class="container"> <div id="page-content"> - <h2>General rules</h2> - <p>Click on a rule in the list to view the history of that rule, including all amendments. Note that older versions of a rule cannot be enforced anymore and are provided only for informational purposes.</p> + <h2>Rules</h2> + <p><a onclick="event.target.blur();" href="#" data-bs-toggle="modal" data-bs-target="#editor">Edit rules</a></p> <?php - $rules = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/rules/newrules.json"), true); - - $catindex = 0; - foreach ($rules as $category): ?> - - <?php if ($catindex === 0): ?> + $rules = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/rules/rules.json"), true); - <ul class="list-group"> - <li class="list-group-item rule-outer"> - <details> - <summary class="rule"> - <b><?= $category['title'] ?><?php if (count($category['rules'][0]['amendments']) > 0): ?>-<?= $category['rules'][0]['amendments'][count($category['rules'][0]['amendments']) - 1]['id'] ?>:</b> <?= $category['rules'][0]['amendments'][count($category['rules'][0]['amendments']) - 1]['text'] ?><?php else: ?>:</b> <?= $category['rules'][0]['text'] ?><?php endif; ?> - </summary> + $protectorCloudburst = array_values(array_filter(scoreOrderGlobal(), function ($i) { + return $i["_system"] === "ynmuc" && $i["_metadata"]["protector"]; + }))[0]; + $protectorRaindrops = array_values(array_filter(scoreOrderGlobal(), function ($i) { + return $i["_system"] === "gdapd" && $i["_metadata"]["protector"]; + }))[0]; - <ul class="list-group" style="margin-top:10px;"> - <?php if (count($category['rules'][0]['amendments']) > 0): ?> - <?php $aindex = 0; foreach (array_reverse($category['rules'][0]['amendments']) as $amendment): ?> + $pcName = getMiniName($protectorCloudburst["display_name"] ?? $protectorCloudburst["name"]); + $prName = getMiniName($protectorRaindrops["display_name"] ?? $protectorRaindrops["name"]); - <?php if ($aindex === 0): ?> - <li class="list-group-item"><b>Curent version:</b> <?= $amendment['text'] ?></li> - <?php else: ?> - <li class="list-group-item"><b>Amendment Preamble-<?= $amendment['id'] ?>:</b> <?= $amendment['text'] ?></li> - <?php endif; ?> + ?> - <?php $aindex++; endforeach; ?> - <li class="list-group-item"><b>Original rule:</b> <?= $category['rules'][0]['text'] ?></li> - <?php else: ?> - <li class="list-group-item"> - <i>This rule was never amended.</i> - </li> - <?php endif; ?> - </ul> - </details> - </li> - </ul> - - <?php else: - - if ($category["title"] === "@punishments") { - $catindex = "P"; - $category["title"] = "Planned punishments"; - } - - ?> - - <h4 style="margin-top: 15px;">Articles <?= $catindex ?>.1 to <?= $catindex ?>.<?= count($category['rules']) ?>: <?= $category["title"] ?></h4> - - <ul class="list-group"> - <?php $ruleindex = 1; foreach ($category['rules'] as $rule): ?> - <li class="list-group-item rule-outer"> - <details> - <summary class="rule"> - <b>Article <?= $catindex ?>.<?= $ruleindex ?><?php if (count($rule['amendments']) > 0): ?>-<?= $rule['amendments'][count($rule['amendments']) - 1]['id'] ?>:</b> <?= $rule['amendments'][count($rule['amendments']) - 1]['text'] ?><?php else: ?>:</b> <?= $rule['text'] ?><?php endif; ?> - </summary> - - <ul class="list-group" style="margin-top:10px;"> - <?php if (count($rule['amendments']) > 0): ?> - <?php $aindex = 0; foreach (array_reverse($rule['amendments']) as $amendment): ?> - - <?php if ($aindex === 0): ?> - <li class="list-group-item"><b>Curent version:</b> <?= $amendment['text'] ?></li> - <?php else: ?> - <li class="list-group-item"><b>Amendment Preamble-<?= $amendment['id'] ?>:</b> <?= $amendment['text'] ?></li> - <?php endif; ?> - - <?php $aindex++; endforeach; ?> - <li class="list-group-item"><b>Original rule:</b> <?= $rule['text'] ?></li> - <?php else: ?> - <li class="list-group-item"> - <i>This rule was never amended.</i> - </li> + <?php $index = 1; foreach ($rules as $rule): ?> + <h4 style="margin-top: 20px;"> + <b>Rule <?= $index ?>: <?= strip_tags($rule["name"]) ?></b> + <?php if (in_array(false, $rule["approved"])): ?> + <span class="badge bg-warning text-black rounded-pill">Unapproved</span> <?php endif; ?> - </ul> - </details> + </h4> + <?php if (in_array(false, $rule["approved"])): ?> + <div style="margin-top:10px;" class="alert alert-warning"> + <b>This rule has not yet been approved.</b> All rules need to be approved by the leaders from both systems. This rule is still missing approval from <?php + + if ($rule["approved"][0] === false) { + if ($rule["approved"][1] === false) { + echo($pcName . " and " . $prName); + } else { + echo($pcName); + } + } else if ($rule["approved"][1] === false) { + echo($prName); + } + + ?>. + </div> + <?php endif; ?> + <div> + <p><?= $Parsedown->text(strip_tags($rule["content"])) ?></p> + </div> </li> - <?php $ruleindex++; endforeach; ?> - </ul> - - <?php endif; ?> + <?php $index++; endforeach; ?> + </div> +</div> - <?php $catindex++; endforeach; ?> +<div class="modal fade" id="editor"> + <div class="modal-dialog"> + <div class="modal-content"> + <div class="modal-header"> + <h4 class="modal-title">Rules editor</h4> + <button type="button" class="btn-close" data-bs-dismiss="modal"></button> + </div> + + <div class="modal-body"> + <p>Rules with an empty name are automatically deleted. Buttons to add new rules and save the changes are at the bottom of the list.</p> + <hr> + <form method="post"> + <div id="rules-editor"> + <?php $index = 1; foreach ($rules as $rule): ?> + <div <?= $index === 1 ? 'id="default-rule"' : '' ?>> + <p><b <?= $index === 1 ? 'id="default-rule--number"' : '' ?>>Rule #<?= $index ?>:</b></p> + <input <?= $index === 1 ? 'id="default-rule--name"' : '' ?> type="text" placeholder="Rule name" class="form-control" style="margin-bottom:15px;color:white;background:#111;border-color:#222;" name="payload[<?= $index - 1 ?>][name]" value="<?= str_replace('"', """, strip_tags($rule["name"])) ?>"> + + <textarea <?= $index === 1 ? 'id="default-rule--content"' : '' ?> name="payload[<?= $index - 1 ?>][content]" rows="5" class="form-control" style="resize: none;color:white;background:#111;border-color:#222;" placeholder="Rule details"><?= strip_tags($rule["content"] ?? "") ?></textarea> + + <label style="margin-top:10px;margin-left:5px;"> + <input <?= $index === 1 ? 'id="default-rule--approval-1"' : '' ?> <?= ($rule["approved"][0] ?? false) ? "checked" : "" ?> type="checkbox" name="payload[<?= $index - 1 ?>][approved][0]"> + Approved by <?= $pcName ?> + </label><br> + <label style="margin-left:5px;"> + <input <?= $index === 1 ? 'id="default-rule--approval-2"' : '' ?> <?= ($rule["approved"][1] ?? false) ? "checked" : "" ?> type="checkbox" name="payload[<?= $index - 1 ?>][approved][1]"> + Approved by <?= $prName ?> + </label><br> + + <hr> + </div> + <?php $index++; endforeach; ?> + </div> + <input type="submit" value="Save" class="btn btn-primary"> + <a onclick="editorNewRule();" class="btn btn-secondary">New rule</a> + <input type="hidden" name="updateRules"> + </form> + </div> + </div> </div> </div> +<script> + window.numberOfRules = <?= count($rules) ?>; + + Array.from(document.getElementsByClassName("rule-outer")).forEach((el) => { + let details = el.children[0]; + + el.onclick = () => { + Array.from(document.getElementsByClassName("rule-outer")).forEach((sel) => { + if (el === sel) return; + sel.children[0].open = false; + sel.classList.remove("open"); + }); + + details.open = !details.open; + + if (details.open) { + el.classList.add("open"); + } else { + el.classList.remove("open"); + } + } + }) + + function editorNewRule() { + let id = Math.random(36).toString().split(".")[1]; + + document.getElementById("default-rule").id = "added-" + id + "-1"; + document.getElementById("default-rule--number").id = "added-" + id + "-2"; + document.getElementById("default-rule--name").id = "added-" + id + "-3"; + document.getElementById("default-rule--content").id = "added-" + id + "-4"; + document.getElementById("default-rule--approval-1").id = "added-" + id + "-5"; + document.getElementById("default-rule--approval-2").id = "added-" + id + "-6"; + + let child = document.createElement("div"); + child.id = "temp-" + id; + window.numberOfRules++; + + document.getElementById("rules-editor").appendChild(child); + document.getElementById("temp-" + id).outerHTML = document.getElementById("added-" + id + "-1").outerHTML; + + document.getElementById("added-" + id + "-1").id = "default-rule"; + document.getElementById("added-" + id + "-2").id = "default-rule--number"; + document.getElementById("added-" + id + "-3").id = "default-rule--name"; + document.getElementById("added-" + id + "-4").id = "default-rule--content"; + document.getElementById("added-" + id + "-5").id = "default-rule--approval-1"; + document.getElementById("added-" + id + "-6").id = "default-rule--approval-2"; + + document.getElementById("added-" + id + "-3").name = "payload[" + (numberOfRules - 1) + "][name]"; + document.getElementById("added-" + id + "-4").name = "payload[" + (numberOfRules - 1) + "][content]"; + document.getElementById("added-" + id + "-5").name = "payload[" + (numberOfRules - 1) + "][approved][0]"; + document.getElementById("added-" + id + "-6").name = "payload[" + (numberOfRules - 1) + "][approved][1]"; + + document.getElementById("added-" + id + "-5").checked = false; + document.getElementById("added-" + id + "-6").checked = false; + document.getElementById("added-" + id + "-3").value = ""; + document.getElementById("added-" + id + "-4").value = ""; + document.getElementById("added-" + id + "-2").innerText = "Rule #" + numberOfRules + ":"; + } +</script> + <style> .list-group-item { color: #fff; @@ -127,6 +225,7 @@ require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/header.inc'; .rule { list-style: none; + pointer-events: none; } .rule-outer { diff --git a/pages/stats.inc b/pages/stats.inc index 75b9e9d..510c317 100644 --- a/pages/stats.inc +++ b/pages/stats.inc @@ -263,6 +263,232 @@ $switchesCloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . } }); </script> + + <h3 style="margin-top: 15px;">Average switches per day of the week</h3> + <canvas id="graph-01" style="width: 100%; height: 300px; max-height: 100%;"></canvas> + <?php + + $switchesDaysRaindrops = [0, 0, 0, 0, 0, 0, 0]; + $amountDaysRaindrops = [0, 0, 0, 0, 0, 0, 0]; + $switchDoWRaindrops = [0, 0, 0, 0, 0, 0, 0]; + $daysRaindrops = []; + + $switchesDaysCloudburst = [0, 0, 0, 0, 0, 0, 0]; + $amountDaysCloudburst = [0, 0, 0, 0, 0, 0, 0]; + $switchDoWCloudburst = [0, 0, 0, 0, 0, 0, 0]; + $daysCloudburst = []; + + foreach ($switchesCloudburst as $switch) { + if (!in_array(date("Y-m-d", strtotime($switch["timestamp"])), $daysCloudburst)) { + $daysCloudburst[] = date("Y-m-d", strtotime($switch["timestamp"])); + $amountDaysCloudburst[(int)date('N', strtotime($switch["timestamp"])) - 1]++; + } + + $switchesDaysCloudburst[(int)date('N', strtotime($switch["timestamp"])) - 1]++; + } + + $switchDoWCloudburst = [ + $switchesDaysCloudburst[0] / $amountDaysCloudburst[0], + $switchesDaysCloudburst[1] / $amountDaysCloudburst[1], + $switchesDaysCloudburst[2] / $amountDaysCloudburst[2], + $switchesDaysCloudburst[3] / $amountDaysCloudburst[3], + $switchesDaysCloudburst[4] / $amountDaysCloudburst[4], + $switchesDaysCloudburst[5] / $amountDaysCloudburst[5], + $switchesDaysCloudburst[6] / $amountDaysCloudburst[6] + ]; + + foreach ($switchesRaindrops as $switch) { + if (!in_array(date("Y-m-d", strtotime($switch["timestamp"])), $daysRaindrops)) { + $daysRaindrops[] = date("Y-m-d", strtotime($switch["timestamp"])); + $amountDaysRaindrops[(int)date('N', strtotime($switch["timestamp"])) - 1]++; + } + + $switchesDaysRaindrops[(int)date('N', strtotime($switch["timestamp"])) - 1]++; + } + + $switchDoWRaindrops = [ + $switchesDaysRaindrops[0] / $amountDaysRaindrops[0], + $switchesDaysRaindrops[1] / $amountDaysRaindrops[1], + $switchesDaysRaindrops[2] / $amountDaysRaindrops[2], + $switchesDaysRaindrops[3] / $amountDaysRaindrops[3], + $switchesDaysRaindrops[4] / $amountDaysRaindrops[4], + $switchesDaysRaindrops[5] / $amountDaysRaindrops[5], + $switchesDaysRaindrops[6] / $amountDaysRaindrops[6] + ]; + + $switchDoW = [ + $switchDoWCloudburst[0] + $switchDoWRaindrops[0], + $switchDoWCloudburst[1] + $switchDoWRaindrops[1], + $switchDoWCloudburst[2] + $switchDoWRaindrops[2], + $switchDoWCloudburst[3] + $switchDoWRaindrops[3], + $switchDoWCloudburst[4] + $switchDoWRaindrops[4], + $switchDoWCloudburst[5] + $switchDoWRaindrops[5], + $switchDoWCloudburst[6] + $switchDoWRaindrops[6] + ]; + + ?> + <script> + const ctx1 = document.getElementById('graph-01').getContext('2d'); + window.chart01 = [ + { + label: "Switches per week", + data: JSON.parse(`<?= json_encode($switchDoW) ?>`), + backgroundColor: [ + 'rgba(255, 99, 132, 0.2)', + 'rgba(255, 159, 64, 0.2)', + 'rgba(255, 205, 86, 0.2)', + 'rgba(75, 192, 192, 0.2)', + 'rgba(54, 162, 235, 0.2)', + 'rgba(153, 102, 255, 0.2)', + 'rgba(201, 203, 207, 0.2)' + ], + borderColor: [ + 'rgb(255, 99, 132)', + 'rgb(255, 159, 64)', + 'rgb(255, 205, 86)', + 'rgb(75, 192, 192)', + 'rgb(54, 162, 235)', + 'rgb(153, 102, 255)', + 'rgb(201, 203, 207)' + ], + borderWidth: 1 + } + ]; + const graph1 = new Chart(ctx1, { + type: 'bar', + data: { + labels: ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"], + datasets: window.chart01 + }, + options: { + animation: { + duration: 0 + }, + scales: { + y: { + grid: { + color: "rgba(255,255,255,0.25)" + } + } + }, + plugins: { + legend: { + display: false + }, + tooltip: { + intersect: false + } + } + } + }); + </script> + + <h3 style="margin-top: 15px;">Switches per hour of the day</h3> + <canvas id="graph-02" style="width: 100%; height: 300px; max-height: 100%;"></canvas> + <?php + + $switchHoursRaindrops = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; + $switchHoursCloudburst = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; + + foreach ($switchesCloudburst as $switch) { + $switchHoursCloudburst[(int)date('G', strtotime($switch["timestamp"]))]++; + } + + foreach ($switchesRaindrops as $switch) { + $switchHoursRaindrops[(int)date('G', strtotime($switch["timestamp"]))]++; + } + + $switchHours = [ + $switchHoursRaindrops[0] + $switchHoursCloudburst[0], + $switchHoursRaindrops[1] + $switchHoursCloudburst[1], + $switchHoursRaindrops[2] + $switchHoursCloudburst[2], + $switchHoursRaindrops[3] + $switchHoursCloudburst[3], + $switchHoursRaindrops[4] + $switchHoursCloudburst[4], + $switchHoursRaindrops[5] + $switchHoursCloudburst[5], + $switchHoursRaindrops[6] + $switchHoursCloudburst[6], + $switchHoursRaindrops[7] + $switchHoursCloudburst[7], + $switchHoursRaindrops[8] + $switchHoursCloudburst[8], + $switchHoursRaindrops[9] + $switchHoursCloudburst[9], + $switchHoursRaindrops[10] + $switchHoursCloudburst[10], + $switchHoursRaindrops[11] + $switchHoursCloudburst[11], + $switchHoursRaindrops[12] + $switchHoursCloudburst[12], + $switchHoursRaindrops[13] + $switchHoursCloudburst[13], + $switchHoursRaindrops[14] + $switchHoursCloudburst[14], + $switchHoursRaindrops[15] + $switchHoursCloudburst[15], + $switchHoursRaindrops[16] + $switchHoursCloudburst[16], + $switchHoursRaindrops[17] + $switchHoursCloudburst[17], + $switchHoursRaindrops[18] + $switchHoursCloudburst[18], + $switchHoursRaindrops[19] + $switchHoursCloudburst[19], + $switchHoursRaindrops[20] + $switchHoursCloudburst[20], + $switchHoursRaindrops[21] + $switchHoursCloudburst[21], + $switchHoursRaindrops[22] + $switchHoursCloudburst[22], + $switchHoursRaindrops[23] + $switchHoursCloudburst[23], + ]; + + ?> + <script> + const ctx2 = document.getElementById('graph-02').getContext('2d'); + window.chart02 = [ + { + label: "Switches per hour of day", + data: JSON.parse(`<?= json_encode($switchHours) ?>`), + borderColor: "rgb(160,255,153)" + } + ]; + const graph2 = new Chart(ctx2, { + type: 'line', + data: { + labels: [ + "12am", + "1am", + "2am", + "3am", + "4am", + "5am", + "6am", + "7am", + "8am", + "9am", + "10am", + "11am", + "12pm", + "1pm", + "2pm", + "3pm", + "4pm", + "5pm", + "6pm", + "7pm", + "8pm", + "9pm", + "10pm", + "11pm" + ], + datasets: window.chart02 + }, + options: { + animation: { + duration: 0 + }, + scales: { + y: { + beginAtZero: true, + grid: { + color: "rgba(255,255,255,0.25)" + } + } + }, + plugins: { + legend: { + display: false + }, + tooltip: { + intersect: false + } + } + } + }); + </script> </div> </div> |