rule.html 36 KB

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