rule.html 33 KB

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