rule.html 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  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="prompt">' + 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("button","none");
  258. classDisplayAll("prompt","none");
  259. classDisplayAll("delete-module","none");
  260. var editableFields = document.getElementsByClassName("editable");
  261. // de-editable-ize the editable fields
  262. for (var i = 0; i < editableFields.length; i++) {
  263. editableFields[i].contentEditable = "false";
  264. editableFields[i].style.borderStyle = "none";
  265. // Remove empty fields entirely
  266. var content = editableFields[i].innerHTML;
  267. content = stripHTML(content);
  268. if (content === "") {
  269. editableFields[i].style.display = "none";
  270. }
  271. }
  272. // RuleBuilder sections
  273. if (builderEmpty()) {
  274. document.getElementById("rule-builder").style.display = "none";
  275. } else {
  276. document.getElementById("builder-field").innerHTML = displayBuilderHTML();
  277. document.getElementById("module-input").style.border = "none";
  278. }
  279. if (document.contains(document.getElementById("custom-field-container"))) {
  280. document.getElementById("custom-field-container").remove();
  281. }
  282. document.getElementById("module-menu").style.display = "none";
  283. // Handle author link
  284. var authorName = document.getElementById("author-text").value;
  285. var authorURL = document.getElementById("author-url").value;
  286. if (authorName != "") {
  287. document.getElementById("authorship-words").style.display = "inline";
  288. if (authorURL != "") { // both author and URL present
  289. document.getElementById("authorship-result").innerHTML = "<a href='" + authorURL +"'>" + authorName + "</a>";
  290. document.getElementById("authorship-result").style.display = "inline";
  291. } else { // only authorName present
  292. document.getElementById("authorship-result").innerHTML = authorName;
  293. document.getElementById("authorship-result").style.display = "inline";
  294. }
  295. } else {
  296. document.getElementById("authorship").style.display = "none";
  297. }
  298. // Finally, change button name
  299. document.getElementById("editToggle").innerHTML = "Customize";
  300. } else { // Switch to editMode
  301. editMode = true;
  302. classDisplayAll("button","block");
  303. classDisplayAll("prompt","block");
  304. classDisplayAll("editable","block");
  305. // RuleBuilder handling
  306. classDisplayAll("delete-module","inline");
  307. document.getElementById("rule-builder").style.display = "block";
  308. document.getElementById("module-menu").style.display = "block";
  309. document.getElementById("module-input").style.border = "";
  310. document.getElementById("builder-field").innerHTML = "";
  311. // link handling
  312. classDisplayAll("link-text","inline");
  313. classDisplayAll("link-url","inline");
  314. document.getElementById("authorship-result").style.display = "none";
  315. document.getElementById("authorship-words").style.display = "none";
  316. document.getElementById("authorship").style.display = "block";
  317. // make all editable fields visible
  318. var editableFields = document.getElementsByClassName("editable");
  319. for (var i = 0; i < editableFields.length; i++) {
  320. editableFields[i].style.borderStyle = "none none dashed none";
  321. editableFields[i].contentEditable = "true";
  322. }
  323. // Change button name
  324. document.getElementById("editToggle").innerHTML = "Preview";
  325. }
  326. }
  327. // toggleDisplayMode()
  328. // toggles full displayMode, the Rule-only display for a published Rule
  329. // first, initialize variable:
  330. var displayMode = false;
  331. function toggleDisplayMode() {
  332. if (displayMode == false) {
  333. editMode = true;
  334. toggleEditMode(); // turns off editMode
  335. classDisplayAll("site-nav","none");
  336. classDisplayAll("post-header","none");
  337. classDisplayAll("site-footer","none");
  338. document.getElementById("attribution").style.display = "block";
  339. document.getElementById("toggleDisplayMode").style.display = "inline-block";
  340. document.getElementById("publishRule").style.display = "none";
  341. document.getElementById("trash").style.display = "inline-block";
  342. displayMode = true;
  343. } else {
  344. toggleEditMode() // turns on editMode
  345. classDisplayAll("site-nav","block");
  346. classDisplayAll("post-header","block");
  347. classDisplayAll("site-footer","block");
  348. document.getElementById("attribution").style.display = "none";
  349. document.getElementById("toggleDisplayMode").style.display = "none";
  350. document.getElementById("publishRule").style.display = "inline-block";
  351. document.getElementById("trash").style.display = "none";
  352. displayMode = false;
  353. }
  354. }
  355. // textOutput()
  356. // Produces Markdown rendition of Rule from Export button
  357. function textOutput() {
  358. var filename = 'GOVERNANCE.md';
  359. // First, add title, whether there is one or not
  360. var content = '# '+ document.getElementById('communityname').innerHTML + '\n\n';
  361. content = stripHTML(content);
  362. // Next, add structure field
  363. var structure = document.getElementById('structure').innerHTML;
  364. if (structure != "") {
  365. content += stripHTML(structure) + '\n\n';
  366. }
  367. // Add Builder content
  368. if (!builderEmpty()) {
  369. content += displayBuilderMD() + "\n\n";
  370. }
  371. // Now, begin adding Writer elements
  372. var elements = document.getElementsByClassName('output');
  373. for (var i = 2; i < elements.length; i++) { // start after structure
  374. var thisBit = elements[i].innerHTML;
  375. thisBit = stripHTML(thisBit);
  376. if (thisBit != "") {
  377. if (elements[i].classList.contains("subhead")) {
  378. // Before printing subhead, make sure it's not empty
  379. var i2 = i + 1;
  380. while ((i2 < elements.length) &&
  381. (!(elements[i2].classList.contains("subhead")))) {
  382. if (elements[i2].innerHTML != "") {
  383. // in this case, it's not empty, so print and move on
  384. content += '## ';
  385. content += thisBit + '\n\n';
  386. break;
  387. } else { i2++; }
  388. } // won't print anything if a subhead has only empty children
  389. } else {
  390. // Non-subhead elements can just go ahead and print
  391. content += thisBit + '\n\n';
  392. }
  393. }
  394. }
  395. // Add authorship block
  396. var authorName = document.getElementById("author-text").value;
  397. var authorURL = document.getElementById("author-url").value;
  398. var authorshipBlock = "---\n\nCreated by ";
  399. if (authorName != "") {
  400. if (authorURL != "") { // both author and URL present
  401. authorshipBlock += ("[" + authorName + "](" + authorURL + ")");
  402. } else { // only authorName present
  403. authorshipBlock += authorName;
  404. }
  405. content += (authorshipBlock + "\n");
  406. }
  407. // Add attribution block
  408. content += document.getElementById('attributionMD').innerHTML;
  409. // Starting here, see https://stackoverflow.com/a/33542499
  410. var blob = new Blob([content], {type: 'text/plain'});
  411. if(window.navigator.msSaveOrOpenBlob) {
  412. window.navigator.msSaveBlob(blob, filename);
  413. }
  414. else{
  415. var elem = window.document.createElement('a');
  416. elem.href = window.URL.createObjectURL(blob);
  417. elem.download = filename;
  418. document.body.appendChild(elem);
  419. elem.click();
  420. document.body.removeChild(elem);
  421. URL.revokeObjectURL(); // This needs an arg but I can't figure out what
  422. }
  423. var myFile = new Blob([fileContent], {type: 'text/plain'});
  424. window.URL = window.URL || window.webkitURL; document.getElementById('download').setAttribute('href',window.URL.createObjectURL(myFile));
  425. document.getElementById('download').setAttribute('download', fileName);
  426. }
  427. // BEGIN Publish tools, via SteinHQ.com
  428. // publishRule()
  429. // Publishes existing fields to new page, /builder/?rule=[ruleID]
  430. // Opens new page in Display mode
  431. function publishRule() {
  432. // Confirm user knows what they're getting into
  433. var r = confirm("Publish to the public Library?");
  434. if (r == false) { return; }
  435. // Proceed with publication
  436. var now = new Date();
  437. // Numerical ID for published Rule
  438. var timeID = now.getTime();
  439. // Readable UTC timestamp
  440. var dateTime = now.getUTCFullYear()+'.'+(now.getUTCMonth()+1)+'.'+now.getUTCDate()
  441. +' '+now.getUTCHours()+":"+ now.getUTCMinutes()+":"+now.getUTCSeconds()
  442. + ' UTC';
  443. // TKTK: Check if ruleID exists; while yes, replace and repeat
  444. var rule = [{
  445. ruleID: timeID,
  446. timestamp: dateTime,
  447. }];
  448. // begin adding data
  449. // first, RuleBuilder data
  450. document.getElementById("builder-field").innerHTML = ""; // so it doesn't publish
  451. if (!builderEmpty()) {
  452. rule[0]["modules"] = document.getElementById("module-input").innerHTML;
  453. }
  454. // next, RuleWriter data
  455. var fields = document.getElementsByClassName("editable");
  456. for (var i = 0; i < fields.length; i++) {
  457. var key = fields[i].id;
  458. var value = "";
  459. // including input fields
  460. if (fields[i].nodeName == "INPUT") { // for <input>
  461. value = fields[i].value.replace(/(<([^>]+)>)/ig,"");
  462. } else { // for other fields
  463. value = fields[i].innerHTML.replace(/(<([^>]+)>)/ig,"");
  464. }
  465. rule[0][key] = value;
  466. }
  467. const store = new SteinStore(
  468. "https://api.steinhq.com/v1/storages/5e8b937ab88d3d04ae0816a5"
  469. );
  470. store.append("library", rule).then(data => {
  471. window.open("/create/?r=" + timeID, "_self", false);
  472. });
  473. }
  474. // displayRule(ID)
  475. // Displays content based on ID
  476. function displayRule(ID) {
  477. const store = new SteinStore(
  478. "https://api.steinhq.com/v1/storages/5e8b937ab88d3d04ae0816a5"
  479. );
  480. (async () => {
  481. var sheets = ["library","templates"];
  482. // create empty set of rules (should only get one member)
  483. var ruleArray = [];
  484. // read values from all sheets
  485. for (var i = 0; i < sheets.length; i++) {
  486. await store.read(sheets[i], { search: { ruleID: ID } }).then(data => {
  487. // test if there's anything in data
  488. if (data.length > 0) {
  489. ruleArray = data;
  490. }
  491. });
  492. }
  493. // Only runs the rest if the array has something
  494. if (ruleArray.length > 0) {
  495. var rule = ruleArray[0];
  496. var fields = document.getElementsByClassName("editable");
  497. for (var i = 0; i < fields.length; i++) {
  498. var key = fields[i].id;
  499. var value = rule[key];
  500. if (typeof value === "undefined") {
  501. value = "";
  502. } else if (key.includes("-")) { // links
  503. document.getElementById(key).value = value;
  504. } else {
  505. document.getElementById(key).innerHTML = value;
  506. }
  507. }
  508. // Add Builder content
  509. document.getElementById("module-input").innerHTML = rule["modules"];
  510. // Publish timestamp to Rule
  511. document.getElementById('dateTime').innerHTML = rule['timestamp'];
  512. // Finish
  513. displayMode = false;
  514. toggleDisplayMode();
  515. document.title = rule['communityname'] + " / CommunityRule";
  516. }
  517. })();
  518. }
  519. // deleteRule()
  520. // A temporary placeholder that sends an email requesting rule deletion
  521. function deleteRule() {
  522. var urlParamz = new URLSearchParams(window.location.search);
  523. var rID = urlParamz.get('r');
  524. window.open("mailto:medlab@colorado.edu?subject=Delete Rule request ("
  525. + rID + ")&body=Please explain your rationale:\n");
  526. }
  527. // END Publish tools
  528. // FINALLY, Page loading
  529. // First, grab the current URL
  530. var urlParams = new URLSearchParams(window.location.search);
  531. // Determine if it is a published Rule
  532. if (urlParams.has('r')) {
  533. // If so, grab the Rule from database and enter displayMode
  534. var rID = urlParams.get('r');
  535. displayRule(rID);
  536. } else {
  537. // Otherwise, open in editMode as default
  538. var editMode = true;
  539. }
  540. // eqip editable fields to remove formatting from pasted content
  541. window.onload = function() {
  542. var editableElements = document.getElementsByClassName("editable");
  543. for (var i = 0; i < editableElements.length; i++ ) {
  544. editableElements[i].addEventListener("paste", handleEditablePaste);
  545. }
  546. }
  547. </script>
  548. <article class="post">
  549. <header class="post-header">
  550. <h1 class="post-title" id="title">
  551. {{ page.title }}
  552. </h1>
  553. <button class="pushButton" id="editToggle" onclick="toggleEditMode()">
  554. Preview</button>
  555. <div class="post-content">
  556. {{ content }}
  557. </div>
  558. </header>
  559. <div id="rulebox">
  560. <span class="prompt">What is the community’s name?</span>
  561. <h1 contenteditable="true" class="editable output" id="communityname">{{ page.community-name }}</h1>
  562. <span class="prompt">Summarize its structure:</span>
  563. <p contenteditable="true" class="editable output" id="structure">{{ page.structure }}</p>
  564. <!-- RuleBuilder -->
  565. <div id="rule-builder">
  566. <button id="module-toggle" onclick="toggleVisible('module-menu')"
  567. class="button" title="Show/hide">
  568. <img src="{% link assets/tabler_icons/tool.svg %}" title="Modules" />
  569. </button>
  570. <div id="module-input"
  571. ondrop="drop(event)" ondragover="allowDrop(event)">
  572. <span class="prompt" id="drag-directions">Browse modules from below and drag them here.</span>
  573. </div>
  574. <div id="builder-field">
  575. </div>
  576. <div id="module-menu">
  577. <!-- Customizable module -->
  578. <span class="module" id="module-custom"
  579. draggable="true" ondragstart="drag(event)">
  580. <input contenteditable="true" draggable="false" placeholder="Custom..."/>
  581. <img src="{% link assets/tabler_icons/bulb.svg %}" class="module-logo"
  582. draggable="false" />
  583. <a onclick="this.parentNode.remove()" class="delete-module"
  584. style="display:none">
  585. <img src="{% link assets/tabler_icons/x.svg %}" /></a>
  586. </span>
  587. <!-- Load preset modules from _modules/ -->
  588. {% assign modules_array = site.modules | sort: "type" %}
  589. {% assign last_type = "" %}
  590. {% for module in modules_array %}
  591. {% if module.layout == "module" %}
  592. {% if module.type != last_type %}
  593. {% if last_type != "" %}</div>{% endif %}
  594. <div class="module-type-header">
  595. <img src="{{ site.baseurl }}/{{ site.data.module_types[module.type].icon }}" />
  596. {{ module.type }}
  597. <button onclick="toggleVisible('module-type-{{ module.type }}')" class="button chevrons"><img src="{% link assets/tabler_icons/chevrons-down.svg %}" title="Show/hide" /></button>
  598. </div>
  599. <div class="module-questions">{{ site.data.module_types[module.type].question }}</div>
  600. <div id="module-type-{{ module.type }}">
  601. {% endif %}
  602. {% assign last_type = module.type %}
  603. <span class="module" id="module-{{ module.title | slugify }}"
  604. draggable="true" ondragstart="drag(event)">
  605. <span id="module-name" title="{{ module.summary }}">{{ module.title }}</span>
  606. <a target="_blank" href="{{ module.url }}">
  607. <img title="More info" draggable="false" class="module-logo"
  608. src="{% link assets/tabler_icons/info-circle.svg %}" />
  609. </a>
  610. <a onclick="this.parentNode.remove()" class="delete-module"
  611. style="display:none">
  612. <img src="{% link assets/tabler_icons/x.svg %}" /></a>
  613. </span>
  614. {% endif %}
  615. {% endfor %}
  616. </div>
  617. </div>
  618. </div>
  619. <!-- END RuleBuilder -->
  620. <div id="rulewriter-box">
  621. <span class="prompt"></span>
  622. <p id="rulewriter" contenteditable="true" class="editable output"></p>
  623. </div>
  624. <div id="authorship" class="linkbox">
  625. <span id="authorship-words">Created by</span>
  626. <input contenteditable="true" class="editable link-text" id="author-text" placeholder="Created by" />
  627. <span class="link-divider"><img src="{% link assets/tabler_icons/pencil.svg %}" title="Add link" /></span>
  628. <input contenteditable="true" class="editable link-url" id="author-url" placeholder="Creator URL (http://, https://)" type="url" pattern="http://.*|https://.*" />
  629. <span id="authorship-result"></span>
  630. </div>
  631. </div><!--#rulebox-->
  632. <div id="attribution" style="display:none;">
  633. <br />
  634. <p><a href="https://communityrule.info">
  635. <img src="https://communityrule.info{% link assets/CommunityRule-derived-000000.svg %}" alt="CommunityRule derived"></a></p>
  636. <p id="dateTime"></p>
  637. <p>Created with <a href="https://communityrule.info">CommunityRule</a><br />
  638. <a href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons BY-SA</a></p>
  639. <p><strong>The Publish feature is experimental. Rules may be removed without notice</strong></p>
  640. </div>
  641. <div id="attributionMD" style="display:none;">
  642. ---
  643. [![CommunityRule derived](https://communityrule.info{% link assets/CommunityRule-derived-000000.svg %})](https://communityrule.info)
  644. [Creative Commons BY-SA](https://creativecommons.org/licenses/by-sa/4.0/)</div>
  645. <button class="pushButton" id="publishRule" onclick="publishRule()"
  646. title="Add to the public Library">Publish</button>
  647. <button class="pushButton" id="toggleDisplayMode" onclick="toggleDisplayMode()"
  648. title="Edit this Rule into a new one">Fork</button>
  649. <button class="pushButton" onclick="textOutput()"
  650. title="Download this Rule as a Markdown text file">Export</button>
  651. <button class="pushButton" id="trash" onclick="deleteRule()">
  652. <img src="{% link assets/tabler_icons/trash.svg %}" title="Rule deletion request" />
  653. </button>
  654. <button class="pushButton"
  655. onclick="javascript:location.href='https://www.colorado.edu/lab/medlab/content/communityrule-user-feedback'">
  656. Feedback
  657. </button>
  658. </article>