rule.html 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773
  1. ---
  2. layout: default
  3. # This is where most of the code for CommunityRule lives
  4. # Follow comments below in various sections for further explanation
  5. ---
  6. <!-- Enables dragging on mobile
  7. https://github.com/Bernardo-Castilho/dragdroptouch -->
  8. <script src="/assets/DragDropTouch.js"></script>
  9. <script>
  10. // Enter JavaScript-land!
  11. // First, some functions, followed by initialization commands
  12. // Begin BUILDER functions
  13. // source: https://www.codecanal.com/html5-drag-and-copy/
  14. function allowDrop(ev) {
  15. ev.preventDefault();
  16. }
  17. function drag(ev) {
  18. ev.dataTransfer.setData("text", ev.target.id);
  19. }
  20. function drop(ev) {
  21. ev.preventDefault();
  22. var target = ev.target;
  23. // First, confirm target location is valid
  24. function targetCheck () {
  25. if (target.id == "module-input") {
  26. return true;
  27. } else if (!document.getElementById("module-input").contains(target)) {
  28. // Ignore destinations not in the correct area
  29. return false;
  30. } else if (target.id == "drag-directions") {
  31. // Prevents dropping into dummy text field
  32. target = target.parentElement;
  33. return true;
  34. } else if (target.classList[0] == "module") {
  35. return true;
  36. } else {
  37. // be sure we're adding to module, not its children
  38. target = target.parentElement;
  39. return targetCheck();
  40. }
  41. }
  42. if (!targetCheck()) { return; }
  43. // Set up transfer
  44. var data = ev.dataTransfer.getData("text");
  45. // Iff module is from the menu clone it
  46. var module = document.getElementById(data);
  47. if (module.parentElement.id == "module-menu") {
  48. module = module.cloneNode(true);
  49. var name = null;
  50. if (module.id == "module-custom") {
  51. // For custom modules: replace the <input> with text
  52. name = module.getElementsByTagName("input")[0].value;
  53. module.getElementsByTagName("input")[0].remove();
  54. var customText = document.createElement("span");
  55. customText.onclick = function() {
  56. moduleEditField(this.parentNode.id);
  57. }
  58. customText.id = "module-name";
  59. customText.append(name);
  60. module.prepend(customText);
  61. }
  62. // append id with unique timestamp
  63. var nowModule = new Date();
  64. module.id += "-" + nowModule.getTime();
  65. }
  66. // display the deletion button
  67. module.children[2].style.display = "inline";
  68. // pop it in!
  69. target.appendChild(module);
  70. // set up the editing field
  71. module.children.item("module-name").onclick = function() {
  72. moduleEditField(this.parentNode.id);
  73. }
  74. moduleEditField(module.id);
  75. // be sure the dummy text is gone
  76. if (document.contains(document.getElementById("drag-directions"))) {
  77. document.getElementById("drag-directions").remove();
  78. }
  79. }
  80. // Edits the title field of a given module based on #custom-field
  81. function moduleTitleEdit(moduleID) {
  82. var module = document.getElementById(moduleID).children[0];
  83. var content =
  84. stripHTML(document.getElementById("custom-field").innerHTML);
  85. module.title = content;
  86. }
  87. // Sets up a field for displaying and editing module details
  88. function moduleEditField(moduleID) {
  89. var module = document.getElementById(moduleID);
  90. var moduleName = module.children[0].innerHTML;
  91. var moduleTitle = module.children[0].title;
  92. if (editMode) {
  93. var query = "Explain how the <strong>" + moduleName
  94. + "</strong> module works.";
  95. var destination = document.getElementById("builder-field");
  96. if (moduleName == null) { moduleName = ""; }
  97. var output = '\n<div id="custom-field-container">';
  98. output += '<span class="question">' + query + '</span>';
  99. output += '<div class="field-controls"><a onclick="this.parentNode.parentNode.remove()"><img src="{% link assets/tabler_icons/x.svg %}" class="delete-module" /></a></div>';
  100. output += '<p contenteditable="true" class="editable" id="custom-field" oninput="moduleTitleEdit(\'' + moduleID + '\')">' + moduleTitle + '</p>';
  101. output += '</div>\n';
  102. destination.innerHTML = output;
  103. } else {
  104. var output = '\n<div id="custom-field-container">';
  105. output += '<div class="field-controls"><a onclick="this.parentNode.parentNode.remove()"><img src="{% link assets/tabler_icons/x.svg %}" class="delete-module" /></a></div>';
  106. output += '<p class="editable" id="custom-field">'
  107. + moduleTitle + '</p>';
  108. }
  109. }
  110. // Tests if the RuleBuilder is empty
  111. function builderEmpty() {
  112. var builder = document.getElementById("module-input");
  113. var childs = builder.children;
  114. if (builder.getElementsByClassName("module").length > 0) {
  115. return false;
  116. } else {
  117. return true;
  118. }
  119. }
  120. // Turns RuleBuilder contents into an output-ready nested array
  121. // Returns empty array if no modules
  122. function builderArray() {
  123. var modules = document.getElementById("module-input").children;
  124. // takes an array of children
  125. // returns an array with all modules in the array, recursively nested
  126. function iterateArray (childs) {
  127. var moduleArray = [];
  128. if (childs.length > 0) {
  129. for (var i = 0; i < childs.length; i++) {
  130. module = childs[i];
  131. if (module.classList[0] == "module") {
  132. var moduleName = module.children.item("module-name");
  133. var moduleData = moduleName.title;
  134. var moduleChilds = module.children;
  135. moduleArray.push(
  136. [stripHTML(moduleName.innerHTML),
  137. stripHTML(moduleData),
  138. iterateArray(moduleChilds)]);
  139. }
  140. }
  141. }
  142. return moduleArray;
  143. } // end function
  144. return iterateArray(modules);
  145. }
  146. // returns HTML version of Builder content
  147. function displayBuilderHTML() {
  148. var output = "";
  149. var mainArray = builderArray();
  150. function arrayHTML(thisArray) {
  151. var thisOutput = "";
  152. if (thisArray.length > 0) {
  153. thisOutput += '<div class="builder-list">\n';
  154. thisOutput += '<ul>\n';
  155. for (var i = 0; i < thisArray.length; i++) {
  156. var item = thisArray[i];
  157. thisOutput += '<li><strong>' + item[0] + '</strong> ';
  158. thisOutput += item[1] + '</li>\n';
  159. if (item[2].length > 0) {
  160. thisOutput += arrayHTML(item[2]);
  161. }
  162. }
  163. thisOutput += '</ul>\n';
  164. }
  165. return thisOutput
  166. }
  167. if (mainArray.length > 0) {
  168. output += '<div class="builder-list">\n';
  169. output += arrayHTML(mainArray) + '\n</div>\n';
  170. }
  171. return output;
  172. }
  173. // returns Markdown version of Builder content
  174. function displayBuilderMD() {
  175. var mainArray = builderArray();
  176. var indentLevel = 0;
  177. function arrayMD(thisArray) {
  178. var thisOutput = "";
  179. if (thisArray.length > 0) {
  180. for (var i = 0; i < thisArray.length; i++) {
  181. var item = thisArray[i];
  182. for (var x = 0; x < indentLevel; x++) {
  183. thisOutput += " ";
  184. }
  185. thisOutput += "* **" + item[0] + "** ";
  186. thisOutput += item[1] + "\n";
  187. if (item[2].length > 0) {
  188. indentLevel++;
  189. thisOutput += arrayMD(item[2]);
  190. indentLevel--;
  191. }
  192. }
  193. }
  194. return thisOutput;
  195. }
  196. return arrayMD(mainArray);
  197. }
  198. // end RuleBuilder functions
  199. // Removes all HTML content
  200. function stripHTML(input) {
  201. input = input.replace(/(<([^>]+)>)/ig,'');
  202. return input;
  203. }
  204. // toggleVisible(id)
  205. // Toggles the visibility of a given element by given ID
  206. function toggleVisible(id) {
  207. var x = document.getElementById(id);
  208. if (x.style.display === "none") {
  209. x.style.display = "block";
  210. } else {
  211. x.style.display = "none";
  212. }
  213. }
  214. // classDisplayAll(className, value)
  215. // Assigns given display value to all elements with a given className
  216. function classDisplayAll(className, value) {
  217. var elements = document.getElementsByClassName(className);
  218. for (var i = 0; i < elements.length; i++) {
  219. elements[i].style.display = value;
  220. }
  221. }
  222. // toggleEditMode()
  223. // Toggles whether editable fields are editable or not
  224. // and removes editing tools.
  225. function toggleEditMode() {
  226. if (editMode === true) { // switch to preview mode
  227. editMode = false;
  228. classDisplayAll("section","block");
  229. classDisplayAll("button","none");
  230. classDisplayAll("question","none");
  231. classDisplayAll("metaheader","none");
  232. classDisplayAll("delete-module","none");
  233. var editableFields = document.getElementsByClassName("editable");
  234. // de-editable-ize the editable fields
  235. for (var i = 0; i < editableFields.length; i++) {
  236. editableFields[i].contentEditable = "false";
  237. editableFields[i].style.borderStyle = "none";
  238. // Remove empty fields entirely
  239. var content = editableFields[i].innerHTML;
  240. content = stripHTML(content);
  241. if (content === "") {
  242. editableFields[i].style.display = "none";
  243. }
  244. }
  245. // RuleBuilder sections
  246. if (builderEmpty()) {
  247. document.getElementById("rule-builder").style.display = "none";
  248. } else {
  249. document.getElementById("builder-field").innerHTML = displayBuilderHTML();
  250. document.getElementById("module-input").style.border = "none";
  251. }
  252. if (document.contains(document.getElementById("custom-field-container"))) {
  253. document.getElementById("custom-field-container").remove();
  254. }
  255. document.getElementById("module-menu").style.display = "none";
  256. // RuleWriter: Remove headers of empty sections
  257. var sections = document.getElementsByClassName("section");
  258. for (var i = 0; i < sections.length; i++) {
  259. var sectionQuestions = sections[i].getElementsByClassName("editable");
  260. var blanks = 0;
  261. for (var x = 0; x < sectionQuestions.length; x++) {
  262. var content = sectionQuestions[x].innerHTML;
  263. content = content.replace(/(<([^>]+)>)/ig,''); // strips stray tags
  264. if (content == "") { blanks++; }
  265. if (blanks == sectionQuestions.length) {
  266. var headerID = "header-s" + (i + 1);
  267. document.getElementById(headerID).style.display = "none";
  268. }
  269. }
  270. }
  271. // Handle author link
  272. var authorName = document.getElementById("author-text").value;
  273. var authorURL = document.getElementById("author-url").value;
  274. if (authorName != "") {
  275. document.getElementById("authorship-words").style.display = "inline";
  276. if (authorURL != "") { // both author and URL present
  277. document.getElementById("authorship-result").innerHTML = "<a href='" + authorURL +"'>" + authorName + "</a>";
  278. document.getElementById("authorship-result").style.display = "inline";
  279. } else { // only authorName present
  280. document.getElementById("authorship-result").innerHTML = authorName;
  281. document.getElementById("authorship-result").style.display = "inline";
  282. }
  283. } else {
  284. document.getElementById("authorship").style.display = "none";
  285. }
  286. // Finally, change button name
  287. document.getElementById("editToggle").innerHTML = "Customize";
  288. } else { // Switch to editMode
  289. editMode = true;
  290. classDisplayAll("button","block");
  291. classDisplayAll("question","block");
  292. classDisplayAll("editable","block");
  293. classDisplayAll("header","block");
  294. classDisplayAll("section","none");
  295. classDisplayAll("metaheader","block");
  296. classDisplayAll("link-text","inline");
  297. classDisplayAll("link-url","inline");
  298. classDisplayAll("delete-module","inline");
  299. // builder handling
  300. document.getElementById("rule-builder").style.display = "block";
  301. document.getElementById("module-input").style.border = "";
  302. document.getElementById("builder-field").innerHTML = "";
  303. // author handling
  304. document.getElementById("authorship-result").style.display = "none";
  305. document.getElementById("authorship-words").style.display = "none";
  306. document.getElementById("authorship").style.display = "block";
  307. // make all editable fields visible
  308. var editableFields = document.getElementsByClassName("editable");
  309. for (var i = 0; i < editableFields.length; i++) {
  310. editableFields[i].style.borderStyle = "none none dashed none";
  311. editableFields[i].contentEditable = "true";
  312. }
  313. // Change button name
  314. document.getElementById("editToggle").innerHTML = "Preview";
  315. }
  316. }
  317. // toggleDisplayMode()
  318. // toggles full displayMode, the Rule-only display for a published Rule
  319. // first, initialize variable:
  320. var displayMode = false;
  321. function toggleDisplayMode() {
  322. if (displayMode == false) {
  323. editMode = true;
  324. toggleEditMode(); // turns off editMode
  325. classDisplayAll("site-nav","none");
  326. classDisplayAll("post-header","none");
  327. classDisplayAll("site-footer","none");
  328. document.getElementById("attribution").style.display = "block";
  329. document.getElementById("toggleDisplayMode").style.display = "inline-block";
  330. document.getElementById("publishRule").style.display = "none";
  331. document.getElementById("trash").style.display = "inline-block";
  332. displayMode = true;
  333. } else {
  334. toggleEditMode() // turns on editMode
  335. classDisplayAll("site-nav","block");
  336. classDisplayAll("post-header","block");
  337. classDisplayAll("site-footer","block");
  338. document.getElementById("attribution").style.display = "none";
  339. document.getElementById("toggleDisplayMode").style.display = "none";
  340. document.getElementById("publishRule").style.display = "inline-block";
  341. document.getElementById("trash").style.display = "none";
  342. displayMode = false;
  343. }
  344. }
  345. // textOutput()
  346. // Produces Markdown rendition of Rule from Export button
  347. function textOutput() {
  348. var filename = 'GOVERNANCE.md';
  349. // First, add title, whether there is one or not
  350. var content = '# '+ document.getElementById('communityname').innerHTML + '\n\n';
  351. content = stripHTML(content);
  352. // Add Builder content
  353. if (!builderEmpty()) {
  354. content += displayBuilderMD() + "\n\n";
  355. }
  356. // Now, begin adding other elements
  357. var elements = document.getElementsByClassName('output');
  358. for (var i = 1; i < elements.length; i++) {
  359. var thisBit = elements[i].innerHTML;
  360. thisBit = stripHTML(thisBit);
  361. if (thisBit != "") {
  362. if (elements[i].classList.contains("subhead")) {
  363. // Before printing subhead, make sure it's not empty
  364. var i2 = i + 1;
  365. while ((i2 < elements.length) &&
  366. (!(elements[i2].classList.contains("subhead")))) {
  367. if (elements[i2].innerHTML != "") {
  368. // in this case, it's not empty, so print and move on
  369. content += '## ';
  370. content += thisBit + '\n\n';
  371. break;
  372. } else { i2++; }
  373. } // won't print anything if a subhead has only empty children
  374. } else {
  375. // Non-subhead elements can just go ahead and print
  376. content += thisBit + '\n\n';
  377. }
  378. }
  379. }
  380. // Add authorship block
  381. var authorName = document.getElementById("author-text").value;
  382. var authorURL = document.getElementById("author-url").value;
  383. var authorshipBlock = "---\n\nCreated by ";
  384. if (authorName != "") {
  385. if (authorURL != "") { // both author and URL present
  386. authorshipBlock += ("[" + authorName + "](" + authorURL + ")");
  387. } else { // only authorName present
  388. authorshipBlock += authorName;
  389. }
  390. content += (authorshipBlock + "\n");
  391. }
  392. // Add attribution block
  393. content += document.getElementById('attributionMD').innerHTML;
  394. // Starting here, see https://stackoverflow.com/a/33542499
  395. var blob = new Blob([content], {type: 'text/plain'});
  396. if(window.navigator.msSaveOrOpenBlob) {
  397. window.navigator.msSaveBlob(blob, filename);
  398. }
  399. else{
  400. var elem = window.document.createElement('a');
  401. elem.href = window.URL.createObjectURL(blob);
  402. elem.download = filename;
  403. document.body.appendChild(elem);
  404. elem.click();
  405. document.body.removeChild(elem);
  406. URL.revokeObjectURL(); // This needs an arg but I can't figure out what
  407. }
  408. var myFile = new Blob([fileContent], {type: 'text/plain'});
  409. window.URL = window.URL || window.webkitURL; document.getElementById('download').setAttribute('href',window.URL.createObjectURL(myFile));
  410. document.getElementById('download').setAttribute('download', fileName);
  411. }
  412. // BEGIN Publish tools, via SteinHQ.com
  413. // publishRule()
  414. // Publishes existing fields to new page, /builder/?rule=[ruleID]
  415. // Opens new page in Display mode
  416. function publishRule() {
  417. // Confirm user knows what they're getting into
  418. var r = confirm("Publish to the public Library?");
  419. if (r == false) { return; }
  420. // Proceed with publication
  421. var now = new Date();
  422. // Numerical ID for published Rule
  423. var timeID = now.getTime();
  424. // Readable UTC timestamp
  425. var dateTime = now.getUTCFullYear()+'.'+(now.getUTCMonth()+1)+'.'+now.getUTCDate()
  426. +' '+now.getUTCHours()+":"+ now.getUTCMinutes()+":"+now.getUTCSeconds()
  427. + ' UTC';
  428. // TKTK: Check if ruleID exists; while yes, replace and repeat
  429. var rule = [{
  430. ruleID: timeID,
  431. timestamp: dateTime,
  432. }];
  433. // begin adding data
  434. // first, RuleBuilder data
  435. document.getElementById("builder-field").innerHTML = ""; // so it doesn't publish
  436. if (!builderEmpty()) {
  437. rule[0]["modules"] = document.getElementById("module-input").innerHTML;
  438. }
  439. // next, RuleWriter data
  440. var fields = document.getElementsByClassName("editable");
  441. for (var i = 0; i < fields.length; i++) {
  442. var key = fields[i].id;
  443. var value = "";
  444. if (fields[i].nodeName == "INPUT") { // for <input>
  445. value = fields[i].value.replace(/(<([^>]+)>)/ig,"");
  446. } else { // for other fields
  447. value = fields[i].innerHTML.replace(/(<([^>]+)>)/ig,"");
  448. }
  449. rule[0][key] = value;
  450. }
  451. const store = new SteinStore(
  452. "https://api.steinhq.com/v1/storages/5e8b937ab88d3d04ae0816a5"
  453. );
  454. store.append("rules", rule).then(data => {
  455. window.open("/create/?r=" + timeID, "_self", false);
  456. });
  457. }
  458. // displayRule(ID)
  459. // Displays content based on ID
  460. function displayRule(ID) {
  461. const store = new SteinStore(
  462. "https://api.steinhq.com/v1/storages/5e8b937ab88d3d04ae0816a5"
  463. );
  464. store.read("rules", { search: { ruleID: ID } }).then(data => {
  465. // reads sheet variable from below
  466. // only runs when we have the data from Goog:
  467. var rule = data[0];
  468. var fields = document.getElementsByClassName("editable");
  469. for (var i = 0; i < fields.length; i++) {
  470. var key = fields[i].id;
  471. var value = rule[key];
  472. if (typeof value === "undefined") {
  473. value = "";
  474. } else if (key.includes("-")) { // links
  475. document.getElementById(key).value = value;
  476. } else {
  477. document.getElementById(key).innerHTML = value;
  478. }
  479. }
  480. // Add Builder content
  481. document.getElementById("module-input").innerHTML = rule["modules"];
  482. // Publish timestamp to Rule
  483. document.getElementById('dateTime').innerHTML = rule['timestamp'];
  484. // Finish
  485. displayMode = false;
  486. toggleDisplayMode();
  487. document.title = rule['communityname'] + " / CommunityRule";
  488. });
  489. }
  490. // deleteRule()
  491. // A temporary placeholder that sends an email requesting rule deletion
  492. function deleteRule() {
  493. var urlParamz = new URLSearchParams(window.location.search);
  494. var rID = urlParamz.get('r');
  495. window.open("mailto:medlab@colorado.edu?subject=Delete Rule request ("
  496. + rID + ")&body=Please explain your rationale:\n");
  497. }
  498. // END Publish tools
  499. // FINALLY, Page loading
  500. // First, grab the current URL
  501. var urlParams = new URLSearchParams(window.location.search);
  502. // Determine if it is a published Rule
  503. if (urlParams.has('r')) {
  504. // If so, grab the Rule from database and enter displayMode
  505. var rID = urlParams.get('r');
  506. displayRule(rID);
  507. } else {
  508. // Otherwise, open in editMode as default
  509. var editMode = true;
  510. // switch out of editMode in special cases
  511. window.onload = function() {
  512. if ((window.location.href.indexOf("/templates/") != -1) ||
  513. (window.location.href.indexOf("/about/") != -1)) {
  514. toggleEditMode();
  515. }
  516. }
  517. }
  518. </script>
  519. <article class="post">
  520. <header class="post-header">
  521. <h1 class="post-title" id="title">
  522. {{ page.title }}
  523. </h1>
  524. <button class="pushButton" id="editToggle" onclick="toggleEditMode()">
  525. Preview</button>
  526. <div class="post-content">
  527. {{ content }}
  528. </div>
  529. </header>
  530. <div id="rulebox">
  531. <span class="question">What is the community’s name?</span>
  532. <h1 contenteditable="true" class="editable output" id="communityname">{{ page.community-name }}</h1>
  533. <span class="question">Summarize its structure:</span>
  534. <p contenteditable="true" class="editable output" id="structure">{{ page.structure }}</p>
  535. <!-- RuleBuilder -->
  536. <div id="rule-builder">
  537. <button id="module-toggle" onclick="toggleVisible('module-menu')"
  538. class="button" title="Show/hide">
  539. <img src="{% link assets/tabler_icons/tool.svg %}" title="Modules" />
  540. </button>
  541. <div id="module-input"
  542. ondrop="drop(event)" ondragover="allowDrop(event)">
  543. <span class="question" id="drag-directions">Browse modules with the tool button and drag them here.</span>
  544. </div>
  545. <div id="builder-field">
  546. </div>
  547. <div id="module-menu" style="display:none;">
  548. <!-- Customizable module -->
  549. <span class="module" id="module-custom"
  550. draggable="true" ondragstart="drag(event)">
  551. <input contenteditable="true" placeholder="Custom..."/>
  552. <img src="{% link assets/tabler_icons/bulb.svg %}" class="module-logo"
  553. draggable="false" />
  554. <a onclick="this.parentNode.remove()" class="delete-module"
  555. style="display:none">
  556. <img src="{% link assets/tabler_icons/x.svg %}" /></a>
  557. </span>
  558. <!-- Load preset modules from _data/modules.csv -->
  559. {% for module in site.data.modules %}
  560. <span class="module" id="module-{{ module.id }}"
  561. draggable="true" ondragstart="drag(event)">
  562. <span id="module-name">{{ module.name }}</span>
  563. <a target="_blank" href="{{ module.url }}">
  564. <img title="{{ module.type }}" draggable="false" class="module-logo"
  565. {% if module.type == "structure" %}
  566. src="{% link assets/tabler_icons/building.svg %}" {% endif %}
  567. {% if module.type == "process" %}
  568. src="{% link assets/tabler_icons/rotate.svg %}" {% endif %}
  569. {% if module.type == "decision" %}
  570. src="{% link assets/tabler_icons/thumb-up.svg %}" {% endif %}
  571. {% if module.type == "culture" %}
  572. src="{% link assets/tabler_icons/palette.svg %}" {% endif %}
  573. /></a>
  574. <a onclick="this.parentNode.remove()" class="delete-module"
  575. style="display:none">
  576. <img src="{% link assets/tabler_icons/x.svg %}" /></a>
  577. </span>
  578. {% endfor %}
  579. </div>
  580. </div>
  581. <div id="rule-writer">
  582. <!-- SECTION S1: BASICS -->
  583. <h2 id="header-s1" class="header">
  584. <img src="{% link assets/tabler_icons/info-circle.svg %}"
  585. class="icons" />
  586. <span class="subhead output">Basics</span>
  587. <button onclick="toggleVisible('s1')" class="button chevrons"><img src="{% link assets/tabler_icons/chevrons-down.svg %}" title="Show/hide" /></button>
  588. </h2>
  589. <div class="section" id="s1" style="display:none">
  590. <span class="question">What is the community’s mission?</span>
  591. <p contenteditable="true" class="editable output" id="mission">{{ page.mission }}</p>
  592. <span class="question">What core values does the community hold?</span>
  593. <p contenteditable="true" class="editable output" id="values">{{ page.values }}</p>
  594. <span class="question">What is the legal status of the community’s assets and creations?</span>
  595. <p contenteditable="true" class="editable output" id="legal">{{ page.legal }}</p>
  596. </div><!--hiding section s1-->
  597. <!-- SECTION s2: PARTICIPANTS -->
  598. <h2 id="header-s2" class="header">
  599. <img src="{% link assets/tabler_icons/user.svg %}"
  600. class="icons" />
  601. <span class="subhead output">Participants</span>
  602. <button onclick="toggleVisible('s2')" class="button chevrons"><img src="{% link assets/tabler_icons/chevrons-down.svg %}" title="Show/hide" /></button>
  603. </h2>
  604. <div class="section" id="s2" style="display:none">
  605. <span class="question">How does someone become a participant?</span>
  606. <p contenteditable="true" class="editable output" id="membership">{{ page.membership }}</p>
  607. <span class="question">How are participants suspended or removed?</span>
  608. <p contenteditable="true" class="editable output" id="removal">{{ page.removal }}</p>
  609. <span class="question">What special roles can participants hold, and how are roles assigned?</span>
  610. <p contenteditable="true" class="editable output" id="roles">{{ page.roles }}</p>
  611. <span class="question">Are there limits on the terms or powers of participant roles?</span>
  612. <p contenteditable="true" class="editable output" id="limits">{{ page.limits }}</p>
  613. </div><!--hiding section s2-->
  614. <!--SECTION s3: POLICY-->
  615. <h2 id="header-s3" class="header">
  616. <img src="{% link assets/tabler_icons/news.svg %}"
  617. class="icons" />
  618. <span class="subhead output">Policy</span>
  619. <button onclick="toggleVisible('s3')" class="button chevrons"><img src="{% link assets/tabler_icons/chevrons-down.svg %}" title="Show/hide" /></button>
  620. </h2>
  621. <div class="section" id="s3" style="display:none">
  622. <span class="question">What basic rights does this Rule guarantee?</span>
  623. <p contenteditable="true" class="editable output" id="rights">{{ page.rights }}</p>
  624. <span class="question">Who has the capacity to decide on policies, and how do they do so?</span>
  625. <p contenteditable="true" class="editable output" id="decision">{{ page.decision }}</p>
  626. <span class="question">How are policies implemented?</span>
  627. <p contenteditable="true" class="editable output" id="implementation">{{ page.implementation }}</p>
  628. <span class="question">How does the community monitor and evaluate its policy implementation? </span>
  629. <p contenteditable="true" class="editable output" id="oversight">{{ page.oversight }}</p>
  630. </div><!--hiding section s3-->
  631. <!-- SECTION s4: PROCESS -->
  632. <h2 id="header-s4" class="header">
  633. <img src="{% link assets/tabler_icons/refresh.svg %}"
  634. class="icons" />
  635. <span class="subhead output">Process</span>
  636. <button onclick="toggleVisible('s4')" class="button chevrons"><img src="{% link assets/tabler_icons/chevrons-down.svg %}" title="Show/hide" /></button>
  637. </h2>
  638. <div class="section" id="s4" style="display:none">
  639. <span class="question">Where does the community deliberate about policies and governance?</span>
  640. <p contenteditable="true" class="editable output" id="deliberation">{{ page.deliberation }}</p>
  641. <span class="question">How does the community manage access to administrative accounts and other tools?</span>
  642. <p contenteditable="true" class="editable output" id="access">{{ page.access }}</p>
  643. <span class="question">How does the community manage funds and economic flows?</span>
  644. <p contenteditable="true" class="editable output" id="economics">{{ page.economics }}</p>
  645. <span class="question">How are grievances among participants addressed?</span>
  646. <p contenteditable="true" class="editable output" id="grievances">{{ page.grievances }}</p>
  647. </div><!--hiding section s4-->
  648. <!-- SECTION s5: EVOLUTION -->
  649. <h2 id="header-s5" class="header">
  650. <img src="{% link assets/tabler_icons/adjustments.svg %}"
  651. class="icons" />
  652. <span class="subhead output">Evolution</span>
  653. <button onclick="toggleVisible('s5')" class="button chevrons"><img src="{% link assets/tabler_icons/chevrons-down.svg %}" title="Show/hide" /></button>
  654. </h2>
  655. <div class="section" id="s5" style="display:none">
  656. <span class="question">Where are policies and records kept?</span>
  657. <p contenteditable="true" class="editable output" id="records">{{ page.records }}</p>
  658. <span class="question">How can this Rule be modified?</span>
  659. <p contenteditable="true" class="editable output" id="modification">{{ page.modification }}</p>
  660. </div><!--hiding section s5-->
  661. </div><!--end: rule-writer-->
  662. <div id="authorship" class="linkbox">
  663. <span id="authorship-words">Created by</span>
  664. <input contenteditable="true" class="editable link-text" id="author-text" placeholder="Created by" />
  665. <span class="link-divider"><img src="{% link assets/tabler_icons/pencil.svg %}" title="Add link" /></span>
  666. <input contenteditable="true" class="editable link-url" id="author-url" placeholder="Creator URL (http://, https://)" type="url" pattern="http://.*|https://.*" />
  667. <span id="authorship-result"></span>
  668. </div>
  669. </div><!--#rulebox-->
  670. <div id="attribution" style="display:none;">
  671. <br />
  672. <p><a href="https://communityrule.info">
  673. <img src="https://communityrule.info{% link assets/CommunityRule-derived-000000.svg %}" alt="CommunityRule derived"></a></p>
  674. <p id="dateTime"></p>
  675. <p>Created with <a href="https://communityrule.info">CommunityRule</a><br />
  676. <a href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons BY-SA</a></p>
  677. <p><strong>The Publish feature is experimental. Rules may be removed without notice</strong></p>
  678. </div>
  679. <div id="attributionMD" style="display:none;">
  680. ---
  681. [![CommunityRule derived](https://communityrule.info{% link assets/CommunityRule-derived-000000.svg %})](https://communityrule.info)
  682. [Creative Commons BY-SA](https://creativecommons.org/licenses/by-sa/4.0/)</div>
  683. <button class="pushButton" id="publishRule" onclick="publishRule()"
  684. title="Add to the public Library">Publish</button>
  685. <button class="pushButton" id="toggleDisplayMode" onclick="toggleDisplayMode()"
  686. title="Edit this Rule into a new one">Fork</button>
  687. <button class="pushButton" onclick="textOutput()"
  688. title="Download this Rule as a Markdown text file">Export</button>
  689. <button class="pushButton" id="trash" onclick="deleteRule()">
  690. <img src="{% link assets/tabler_icons/trash.svg %}" title="Rule deletion request" />
  691. </button>
  692. <button class="pushButton"
  693. onclick="javascript:location.href='https://www.colorado.edu/lab/medlab/content/communityrule-user-feedback'">
  694. Feedback
  695. </button>
  696. </article>