rule.html 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831
  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, replacing line break tags with newlines
  202. function stripHTML(input) {
  203. input = input.replace(/<br ?\/?>/ig, "\n").replace(/(<([^>]+)>)/ig,'');
  204. return input;
  205. }
  206. // Intercepts the paste event for editable fields and
  207. // converts the pasted content to plain text,
  208. // stripping styles and unwanted markup added by programs like Word.
  209. function handleEditablePaste(event) {
  210. try {
  211. var pastedText = event.clipboardData
  212. ? event.clipboardData.getData("text/plain")
  213. : window.clipboardData.getData("Text"); // support IE
  214. var cleanedText = cleanPastedText(pastedText);
  215. // Pastes the cleaned up text.
  216. if (document.queryCommandSupported('insertText')) {
  217. document.execCommand('insertText', false, cleanedText);
  218. } else { // support IE
  219. document.execCommand('paste', false, cleanedText);
  220. }
  221. event.stopPropagation();
  222. event.preventDefault();
  223. return false;
  224. } catch (err) {
  225. // If anything goes wrong with browser compatibility,
  226. // pass the event through without modification.
  227. return true;
  228. }
  229. }
  230. // Removes junk that comes with pasting from text editors like Word.
  231. // taken from https://stackoverflow.com/questions/2875027/clean-microsoft-word-pasted-text-using-javascript
  232. function cleanPastedText(text) {
  233. return text.replace(/.*<!--.*-->/g, "");
  234. }
  235. // toggleVisible(id)
  236. // Toggles the visibility of a given element by given ID
  237. function toggleVisible(id) {
  238. var x = document.getElementById(id);
  239. if (x.style.display === "none") {
  240. x.style.display = "block";
  241. } else {
  242. x.style.display = "none";
  243. }
  244. }
  245. // classDisplayAll(className, value)
  246. // Assigns given display value to all elements with a given className
  247. function classDisplayAll(className, value) {
  248. var elements = document.getElementsByClassName(className);
  249. for (var i = 0; i < elements.length; i++) {
  250. elements[i].style.display = value;
  251. }
  252. }
  253. // toggleEditMode()
  254. // Toggles whether editable fields are editable or not
  255. // and removes editing tools.
  256. function toggleEditMode() {
  257. if (editMode === true) { // switch to preview mode
  258. editMode = false;
  259. classDisplayAll("section","block");
  260. classDisplayAll("button","none");
  261. classDisplayAll("question","none");
  262. classDisplayAll("metaheader","none");
  263. classDisplayAll("delete-module","none");
  264. var editableFields = document.getElementsByClassName("editable");
  265. // de-editable-ize the editable fields
  266. for (var i = 0; i < editableFields.length; i++) {
  267. editableFields[i].contentEditable = "false";
  268. editableFields[i].style.borderStyle = "none";
  269. // Remove empty fields entirely
  270. var content = editableFields[i].innerHTML;
  271. content = stripHTML(content);
  272. if (content === "") {
  273. editableFields[i].style.display = "none";
  274. }
  275. }
  276. // RuleBuilder sections
  277. if (builderEmpty()) {
  278. document.getElementById("rule-builder").style.display = "none";
  279. } else {
  280. document.getElementById("builder-field").innerHTML = displayBuilderHTML();
  281. document.getElementById("module-input").style.border = "none";
  282. }
  283. if (document.contains(document.getElementById("custom-field-container"))) {
  284. document.getElementById("custom-field-container").remove();
  285. }
  286. document.getElementById("module-menu").style.display = "none";
  287. // RuleWriter: Remove headers of empty sections
  288. var sections = document.getElementsByClassName("section");
  289. for (var i = 0; i < sections.length; i++) {
  290. var sectionQuestions = sections[i].getElementsByClassName("editable");
  291. var blanks = 0;
  292. for (var x = 0; x < sectionQuestions.length; x++) {
  293. var content = sectionQuestions[x].innerHTML;
  294. content = content.replace(/(<([^>]+)>)/ig,''); // strips stray tags
  295. if (content == "") { blanks++; }
  296. if (blanks == sectionQuestions.length) {
  297. var headerID = "header-s" + (i + 1);
  298. document.getElementById(headerID).style.display = "none";
  299. }
  300. }
  301. }
  302. // Handle author link
  303. var authorName = document.getElementById("author-text").value;
  304. var authorURL = document.getElementById("author-url").value;
  305. if (authorName != "") {
  306. document.getElementById("authorship-words").style.display = "inline";
  307. if (authorURL != "") { // both author and URL present
  308. document.getElementById("authorship-result").innerHTML = "<a href='" + authorURL +"'>" + authorName + "</a>";
  309. document.getElementById("authorship-result").style.display = "inline";
  310. } else { // only authorName present
  311. document.getElementById("authorship-result").innerHTML = authorName;
  312. document.getElementById("authorship-result").style.display = "inline";
  313. }
  314. } else {
  315. document.getElementById("authorship").style.display = "none";
  316. }
  317. // Finally, change button name
  318. document.getElementById("editToggle").innerHTML = "Customize";
  319. } else { // Switch to editMode
  320. editMode = true;
  321. classDisplayAll("button","block");
  322. classDisplayAll("question","block");
  323. classDisplayAll("editable","block");
  324. classDisplayAll("header","block");
  325. classDisplayAll("section","none");
  326. classDisplayAll("metaheader","block");
  327. classDisplayAll("link-text","inline");
  328. classDisplayAll("link-url","inline");
  329. classDisplayAll("delete-module","inline");
  330. // builder handling
  331. document.getElementById("rule-builder").style.display = "block";
  332. document.getElementById("module-input").style.border = "";
  333. document.getElementById("builder-field").innerHTML = "";
  334. // author handling
  335. document.getElementById("authorship-result").style.display = "none";
  336. document.getElementById("authorship-words").style.display = "none";
  337. document.getElementById("authorship").style.display = "block";
  338. // make all editable fields visible
  339. var editableFields = document.getElementsByClassName("editable");
  340. for (var i = 0; i < editableFields.length; i++) {
  341. editableFields[i].style.borderStyle = "none none dashed none";
  342. editableFields[i].contentEditable = "true";
  343. }
  344. // Change button name
  345. document.getElementById("editToggle").innerHTML = "Preview";
  346. }
  347. }
  348. // toggleDisplayMode()
  349. // toggles full displayMode, the Rule-only display for a published Rule
  350. // first, initialize variable:
  351. var displayMode = false;
  352. function toggleDisplayMode() {
  353. if (displayMode == false) {
  354. editMode = true;
  355. toggleEditMode(); // turns off editMode
  356. classDisplayAll("site-nav","none");
  357. classDisplayAll("post-header","none");
  358. classDisplayAll("site-footer","none");
  359. document.getElementById("attribution").style.display = "block";
  360. document.getElementById("toggleDisplayMode").style.display = "inline-block";
  361. document.getElementById("publishRule").style.display = "none";
  362. document.getElementById("trash").style.display = "inline-block";
  363. displayMode = true;
  364. } else {
  365. toggleEditMode() // turns on editMode
  366. classDisplayAll("site-nav","block");
  367. classDisplayAll("post-header","block");
  368. classDisplayAll("site-footer","block");
  369. document.getElementById("attribution").style.display = "none";
  370. document.getElementById("toggleDisplayMode").style.display = "none";
  371. document.getElementById("publishRule").style.display = "inline-block";
  372. document.getElementById("trash").style.display = "none";
  373. displayMode = false;
  374. }
  375. }
  376. // textOutput()
  377. // Produces Markdown rendition of Rule from Export button
  378. function textOutput() {
  379. var filename = 'GOVERNANCE.md';
  380. // First, add title, whether there is one or not
  381. var content = '# '+ document.getElementById('communityname').innerHTML + '\n\n';
  382. content = stripHTML(content);
  383. // Add Builder content
  384. if (!builderEmpty()) {
  385. content += displayBuilderMD() + "\n\n";
  386. }
  387. // Now, begin adding other elements
  388. var elements = document.getElementsByClassName('output');
  389. for (var i = 1; i < elements.length; i++) {
  390. var thisBit = elements[i].innerHTML;
  391. thisBit = stripHTML(thisBit);
  392. if (thisBit != "") {
  393. if (elements[i].classList.contains("subhead")) {
  394. // Before printing subhead, make sure it's not empty
  395. var i2 = i + 1;
  396. while ((i2 < elements.length) &&
  397. (!(elements[i2].classList.contains("subhead")))) {
  398. if (elements[i2].innerHTML != "") {
  399. // in this case, it's not empty, so print and move on
  400. content += '## ';
  401. content += thisBit + '\n\n';
  402. break;
  403. } else { i2++; }
  404. } // won't print anything if a subhead has only empty children
  405. } else {
  406. // Non-subhead elements can just go ahead and print
  407. content += thisBit + '\n\n';
  408. }
  409. }
  410. }
  411. // Add authorship block
  412. var authorName = document.getElementById("author-text").value;
  413. var authorURL = document.getElementById("author-url").value;
  414. var authorshipBlock = "---\n\nCreated by ";
  415. if (authorName != "") {
  416. if (authorURL != "") { // both author and URL present
  417. authorshipBlock += ("[" + authorName + "](" + authorURL + ")");
  418. } else { // only authorName present
  419. authorshipBlock += authorName;
  420. }
  421. content += (authorshipBlock + "\n");
  422. }
  423. // Add attribution block
  424. content += document.getElementById('attributionMD').innerHTML;
  425. // Starting here, see https://stackoverflow.com/a/33542499
  426. var blob = new Blob([content], {type: 'text/plain'});
  427. if(window.navigator.msSaveOrOpenBlob) {
  428. window.navigator.msSaveBlob(blob, filename);
  429. }
  430. else{
  431. var elem = window.document.createElement('a');
  432. elem.href = window.URL.createObjectURL(blob);
  433. elem.download = filename;
  434. document.body.appendChild(elem);
  435. elem.click();
  436. document.body.removeChild(elem);
  437. URL.revokeObjectURL(); // This needs an arg but I can't figure out what
  438. }
  439. var myFile = new Blob([fileContent], {type: 'text/plain'});
  440. window.URL = window.URL || window.webkitURL; document.getElementById('download').setAttribute('href',window.URL.createObjectURL(myFile));
  441. document.getElementById('download').setAttribute('download', fileName);
  442. }
  443. // BEGIN Publish tools, via SteinHQ.com
  444. // publishRule()
  445. // Publishes existing fields to new page, /builder/?rule=[ruleID]
  446. // Opens new page in Display mode
  447. function publishRule() {
  448. // Confirm user knows what they're getting into
  449. var r = confirm("Publish to the public Library?");
  450. if (r == false) { return; }
  451. // Proceed with publication
  452. var now = new Date();
  453. // Numerical ID for published Rule
  454. var timeID = now.getTime();
  455. // Readable UTC timestamp
  456. var dateTime = now.getUTCFullYear()+'.'+(now.getUTCMonth()+1)+'.'+now.getUTCDate()
  457. +' '+now.getUTCHours()+":"+ now.getUTCMinutes()+":"+now.getUTCSeconds()
  458. + ' UTC';
  459. // TKTK: Check if ruleID exists; while yes, replace and repeat
  460. var rule = [{
  461. ruleID: timeID,
  462. timestamp: dateTime,
  463. }];
  464. // begin adding data
  465. // first, RuleBuilder data
  466. document.getElementById("builder-field").innerHTML = ""; // so it doesn't publish
  467. if (!builderEmpty()) {
  468. rule[0]["modules"] = document.getElementById("module-input").innerHTML;
  469. }
  470. // next, RuleWriter data
  471. var fields = document.getElementsByClassName("editable");
  472. for (var i = 0; i < fields.length; i++) {
  473. var key = fields[i].id;
  474. var value = "";
  475. if (fields[i].nodeName == "INPUT") { // for <input>
  476. value = fields[i].value.replace(/(<([^>]+)>)/ig,"");
  477. } else { // for other fields
  478. value = fields[i].innerHTML.replace(/(<([^>]+)>)/ig,"");
  479. }
  480. rule[0][key] = value;
  481. }
  482. const store = new SteinStore(
  483. "https://api.steinhq.com/v1/storages/5e8b937ab88d3d04ae0816a5"
  484. );
  485. store.append("rules", rule).then(data => {
  486. window.open("/create/?r=" + timeID, "_self", false);
  487. });
  488. }
  489. // displayRule(ID)
  490. // Displays content based on ID
  491. function displayRule(ID) {
  492. const store = new SteinStore(
  493. "https://api.steinhq.com/v1/storages/5e8b937ab88d3d04ae0816a5"
  494. );
  495. (async () => {
  496. var sheets = ["library","templates"];
  497. // create empty set of rules (should only get one member)
  498. var ruleArray = [];
  499. // read values from all sheets
  500. for (var i = 0; i < sheets.length; i++) {
  501. await store.read(sheets[i], { search: { ruleID: ID } }).then(data => {
  502. // test if there's anything in data
  503. if (data.length > 0) {
  504. ruleArray = data;
  505. }
  506. });
  507. }
  508. // Only runs the rest if the array has something
  509. if (ruleArray.length > 0) {
  510. var rule = ruleArray[0];
  511. var fields = document.getElementsByClassName("editable");
  512. for (var i = 0; i < fields.length; i++) {
  513. var key = fields[i].id;
  514. var value = rule[key];
  515. if (typeof value === "undefined") {
  516. value = "";
  517. } else if (key.includes("-")) { // links
  518. document.getElementById(key).value = value;
  519. } else {
  520. document.getElementById(key).innerHTML = value;
  521. }
  522. }
  523. // Add Builder content
  524. document.getElementById("module-input").innerHTML = rule["modules"];
  525. // Publish timestamp to Rule
  526. document.getElementById('dateTime').innerHTML = rule['timestamp'];
  527. // Finish
  528. displayMode = false;
  529. toggleDisplayMode();
  530. document.title = rule['communityname'] + " / CommunityRule";
  531. }
  532. })();
  533. }
  534. // deleteRule()
  535. // A temporary placeholder that sends an email requesting rule deletion
  536. function deleteRule() {
  537. var urlParamz = new URLSearchParams(window.location.search);
  538. var rID = urlParamz.get('r');
  539. window.open("mailto:medlab@colorado.edu?subject=Delete Rule request ("
  540. + rID + ")&body=Please explain your rationale:\n");
  541. }
  542. // END Publish tools
  543. // FINALLY, Page loading
  544. // First, grab the current URL
  545. var urlParams = new URLSearchParams(window.location.search);
  546. // Determine if it is a published Rule
  547. if (urlParams.has('r')) {
  548. // If so, grab the Rule from database and enter displayMode
  549. var rID = urlParams.get('r');
  550. displayRule(rID);
  551. } else {
  552. // Otherwise, open in editMode as default
  553. var editMode = true;
  554. // switch out of editMode in special cases
  555. window.onload = function() {
  556. if ((window.location.href.indexOf("/templates/") != -1) ||
  557. (window.location.href.indexOf("/about/") != -1)) {
  558. toggleEditMode();
  559. }
  560. }
  561. }
  562. // eqip editable fields to remove formatting from pasted content
  563. window.onload = function() {
  564. var editableElements = document.getElementsByClassName("editable");
  565. for (var i = 0; i < editableElements.length; i++ ) {
  566. editableElements[i].addEventListener("paste", handleEditablePaste);
  567. }
  568. }
  569. </script>
  570. <article class="post">
  571. <header class="post-header">
  572. <h1 class="post-title" id="title">
  573. {{ page.title }}
  574. </h1>
  575. <button class="pushButton" id="editToggle" onclick="toggleEditMode()">
  576. Preview</button>
  577. <div class="post-content">
  578. {{ content }}
  579. </div>
  580. </header>
  581. <div id="rulebox">
  582. <span class="question">What is the community’s name?</span>
  583. <h1 contenteditable="true" class="editable output" id="communityname">{{ page.community-name }}</h1>
  584. <span class="question">Summarize its structure:</span>
  585. <p contenteditable="true" class="editable output" id="structure">{{ page.structure }}</p>
  586. <!-- RuleBuilder -->
  587. <div id="rule-builder">
  588. <button id="module-toggle" onclick="toggleVisible('module-menu')"
  589. class="button" title="Show/hide">
  590. <img src="{% link assets/tabler_icons/tool.svg %}" title="Modules" />
  591. </button>
  592. <div id="module-input"
  593. ondrop="drop(event)" ondragover="allowDrop(event)">
  594. <span class="question" id="drag-directions">Browse modules with the tool button and drag them here.</span>
  595. </div>
  596. <div id="builder-field">
  597. </div>
  598. <div id="module-menu" style="display:none;">
  599. <!-- Customizable module -->
  600. <span class="module" id="module-custom"
  601. draggable="true" ondragstart="drag(event)">
  602. <input contenteditable="true" draggable="false" placeholder="Custom..."/>
  603. <img src="{% link assets/tabler_icons/bulb.svg %}" class="module-logo"
  604. draggable="false" />
  605. <a onclick="this.parentNode.remove()" class="delete-module"
  606. style="display:none">
  607. <img src="{% link assets/tabler_icons/x.svg %}" /></a>
  608. </span>
  609. <!-- Load preset modules from _modules/ -->
  610. {% assign modules_array = site.modules | sort: "type" | reverse %}
  611. {% for module in modules_array %}
  612. {% if module.layout == "module" %}
  613. <span class="module" id="module-{{ module.title | slugify }}"
  614. draggable="true" ondragstart="drag(event)">
  615. <span id="module-title" title="{{ module.summary }}">{{ module.title }}</span>
  616. <a target="_blank" href="{{ module.url }}">
  617. <img title="{{ module.type }} (press for info)" draggable="false" class="module-logo"
  618. {% if module.type == "structure" %}
  619. src="{% link assets/tabler_icons/building.svg %}" {% endif %}
  620. {% if module.type == "process" %}
  621. src="{% link assets/tabler_icons/rotate.svg %}" {% endif %}
  622. {% if module.type == "decision" %}
  623. src="{% link assets/tabler_icons/thumb-up.svg %}" {% endif %}
  624. {% if module.type == "culture" %}
  625. src="{% link assets/tabler_icons/palette.svg %}" {% endif %}
  626. /></a>
  627. <a onclick="this.parentNode.remove()" class="delete-module"
  628. style="display:none">
  629. <img src="{% link assets/tabler_icons/x.svg %}" /></a>
  630. </span>
  631. {% endif %}
  632. {% endfor %}
  633. </div>
  634. </div>
  635. <div id="rule-writer">
  636. <!-- SECTION S1: BASICS -->
  637. <h2 id="header-s1" class="header">
  638. <img src="{% link assets/tabler_icons/info-circle.svg %}"
  639. class="icons" />
  640. <span class="subhead output">Basics</span>
  641. <button onclick="toggleVisible('s1')" class="button chevrons"><img src="{% link assets/tabler_icons/chevrons-down.svg %}" title="Show/hide" /></button>
  642. </h2>
  643. <div class="section" id="s1" style="display:none">
  644. <span class="question">What is the community’s mission?</span>
  645. <p contenteditable="true" class="editable output" id="mission">{{ page.mission }}</p>
  646. <span class="question">What core values does the community hold?</span>
  647. <p contenteditable="true" class="editable output" id="values">{{ page.values }}</p>
  648. <span class="question">What is the legal status of the community’s assets and creations?</span>
  649. <p contenteditable="true" class="editable output" id="legal">{{ page.legal }}</p>
  650. </div><!--hiding section s1-->
  651. <!-- SECTION s2: PARTICIPANTS -->
  652. <h2 id="header-s2" class="header">
  653. <img src="{% link assets/tabler_icons/user.svg %}"
  654. class="icons" />
  655. <span class="subhead output">Participants</span>
  656. <button onclick="toggleVisible('s2')" class="button chevrons"><img src="{% link assets/tabler_icons/chevrons-down.svg %}" title="Show/hide" /></button>
  657. </h2>
  658. <div class="section" id="s2" style="display:none">
  659. <span class="question">How does someone become a participant?</span>
  660. <p contenteditable="true" class="editable output" id="membership">{{ page.membership }}</p>
  661. <span class="question">How are participants suspended or removed?</span>
  662. <p contenteditable="true" class="editable output" id="removal">{{ page.removal }}</p>
  663. <span class="question">What special roles can participants hold, and how are roles assigned?</span>
  664. <p contenteditable="true" class="editable output" id="roles">{{ page.roles }}</p>
  665. <span class="question">Are there limits on the terms or powers of participant roles?</span>
  666. <p contenteditable="true" class="editable output" id="limits">{{ page.limits }}</p>
  667. </div><!--hiding section s2-->
  668. <!--SECTION s3: POLICY-->
  669. <h2 id="header-s3" class="header">
  670. <img src="{% link assets/tabler_icons/news.svg %}"
  671. class="icons" />
  672. <span class="subhead output">Policy</span>
  673. <button onclick="toggleVisible('s3')" class="button chevrons"><img src="{% link assets/tabler_icons/chevrons-down.svg %}" title="Show/hide" /></button>
  674. </h2>
  675. <div class="section" id="s3" style="display:none">
  676. <span class="question">What basic rights does this Rule guarantee?</span>
  677. <p contenteditable="true" class="editable output" id="rights">{{ page.rights }}</p>
  678. <span class="question">Who has the capacity to decide on policies, and how do they do so?</span>
  679. <p contenteditable="true" class="editable output" id="decision">{{ page.decision }}</p>
  680. <span class="question">How are policies implemented?</span>
  681. <p contenteditable="true" class="editable output" id="implementation">{{ page.implementation }}</p>
  682. <span class="question">How does the community monitor and evaluate its policy implementation? </span>
  683. <p contenteditable="true" class="editable output" id="oversight">{{ page.oversight }}</p>
  684. </div><!--hiding section s3-->
  685. <!-- SECTION s4: PROCESS -->
  686. <h2 id="header-s4" class="header">
  687. <img src="{% link assets/tabler_icons/refresh.svg %}"
  688. class="icons" />
  689. <span class="subhead output">Process</span>
  690. <button onclick="toggleVisible('s4')" class="button chevrons"><img src="{% link assets/tabler_icons/chevrons-down.svg %}" title="Show/hide" /></button>
  691. </h2>
  692. <div class="section" id="s4" style="display:none">
  693. <span class="question">Where does the community deliberate about policies and governance?</span>
  694. <p contenteditable="true" class="editable output" id="deliberation">{{ page.deliberation }}</p>
  695. <span class="question">How does the community manage access to administrative accounts and other tools?</span>
  696. <p contenteditable="true" class="editable output" id="access">{{ page.access }}</p>
  697. <span class="question">How does the community manage funds and economic flows?</span>
  698. <p contenteditable="true" class="editable output" id="economics">{{ page.economics }}</p>
  699. <span class="question">How are grievances among participants addressed?</span>
  700. <p contenteditable="true" class="editable output" id="grievances">{{ page.grievances }}</p>
  701. </div><!--hiding section s4-->
  702. <!-- SECTION s5: EVOLUTION -->
  703. <h2 id="header-s5" class="header">
  704. <img src="{% link assets/tabler_icons/adjustments.svg %}"
  705. class="icons" />
  706. <span class="subhead output">Evolution</span>
  707. <button onclick="toggleVisible('s5')" class="button chevrons"><img src="{% link assets/tabler_icons/chevrons-down.svg %}" title="Show/hide" /></button>
  708. </h2>
  709. <div class="section" id="s5" style="display:none">
  710. <span class="question">Where are policies and records kept?</span>
  711. <p contenteditable="true" class="editable output" id="records">{{ page.records }}</p>
  712. <span class="question">How can this Rule be modified?</span>
  713. <p contenteditable="true" class="editable output" id="modification">{{ page.modification }}</p>
  714. </div><!--hiding section s5-->
  715. </div><!--end: rule-writer-->
  716. <div id="authorship" class="linkbox">
  717. <span id="authorship-words">Created by</span>
  718. <input contenteditable="true" class="editable link-text" id="author-text" placeholder="Created by" />
  719. <span class="link-divider"><img src="{% link assets/tabler_icons/pencil.svg %}" title="Add link" /></span>
  720. <input contenteditable="true" class="editable link-url" id="author-url" placeholder="Creator URL (http://, https://)" type="url" pattern="http://.*|https://.*" />
  721. <span id="authorship-result"></span>
  722. </div>
  723. </div><!--#rulebox-->
  724. <div id="attribution" style="display:none;">
  725. <br />
  726. <p><a href="https://communityrule.info">
  727. <img src="https://communityrule.info{% link assets/CommunityRule-derived-000000.svg %}" alt="CommunityRule derived"></a></p>
  728. <p id="dateTime"></p>
  729. <p>Created with <a href="https://communityrule.info">CommunityRule</a><br />
  730. <a href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons BY-SA</a></p>
  731. <p><strong>The Publish feature is experimental. Rules may be removed without notice</strong></p>
  732. </div>
  733. <div id="attributionMD" style="display:none;">
  734. ---
  735. [![CommunityRule derived](https://communityrule.info{% link assets/CommunityRule-derived-000000.svg %})](https://communityrule.info)
  736. [Creative Commons BY-SA](https://creativecommons.org/licenses/by-sa/4.0/)</div>
  737. <button class="pushButton" id="publishRule" onclick="publishRule()"
  738. title="Add to the public Library">Publish</button>
  739. <button class="pushButton" id="toggleDisplayMode" onclick="toggleDisplayMode()"
  740. title="Edit this Rule into a new one">Fork</button>
  741. <button class="pushButton" onclick="textOutput()"
  742. title="Download this Rule as a Markdown text file">Export</button>
  743. <button class="pushButton" id="trash" onclick="deleteRule()">
  744. <img src="{% link assets/tabler_icons/trash.svg %}" title="Rule deletion request" />
  745. </button>
  746. <button class="pushButton"
  747. onclick="javascript:location.href='https://www.colorado.edu/lab/medlab/content/communityrule-user-feedback'">
  748. Feedback
  749. </button>
  750. </article>