rule.html 32 KB

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