rule.html 33 KB

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