123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545 |
- ---
- layout: default
- # This is where most of the code for CommunityRule lives
- # Follow comments below in various sections for further explanation
- ---
- <style type="text/css">
- /* CLASSES */
- .editable { /* All editable fields */
- padding: 10px 10px 10px 10px;
- min-height: 1.5em;
- font-family: serif;
- border-bottom: 1px dashed gray;
- }
- .question {
- color: gray;
- }
- /* Tooltip for Modules
- https://www.w3schools.com/css/tryit.asp?filename=trycss_tooltip_right
- This could bear substantial improvement. */
- .button {
- position: relative;
- display: inline-block;
- float: right;
- border: 1px solid gray;
- color: gray;
- background-color: white;
- text-align: center;
- border-radius: 6px;
- padding: 0 5px 0 5px;
- }
- .button .tooltiptext {
- visibility: hidden;
- width: 250px;
- border: 1px solid black;
- background-color: white;
- text-align: center;
- border-radius: 6px;
- padding: 5px 0;
- /* Position the tooltip */
- position: absolute;
- z-index: 1;
- right: 100%;
- }
- .button:hover {
- background-color: lightgray;
- }
- .button:hover .tooltiptext {
- visibility: visible;
- }
- /* pushButton
- These are the major functional buttons*/
- .pushButton {
- border: 1px solid gray;
- color: gray;
- background-color: white;
- text-align: center;
- border-radius: 6px;
- padding: 5px;
- font-size: 1.2em;
- }
- .pushButton:hover {
- background-color: lightgray;
- }
- .plus { /* The maximize/minimize button */
- font-size: 1em;
- }
- .icons {
- /* icons are from https://github.com/tabler/tabler-icons */
- margin: 0 5px 0 0;
- }
- /* VARIOUS IDs */
- #rulebox {
- border: 1px solid lightgray;
- padding: 20px;
- margin: 20px 0 30px 0;
- }
- #rulebox h2 {
- font-family: serif;
- }
- #communityname {
- font-weight: bold;
- }
- #editToggle {
- float: right;
- clear: both;
- }
- #toggleDisplayMode {
- margin: 0 0 10px 0;
- display: none;
- }
- #publishRule {
- margin: 0 0 10px 0;
- }
- #structure {
- font-size: 1.3em;
- }
- #attribution {
- font-family: serif;
- font-size: .8em;
- text-align: right;
- }
- #trash {
- display: none;
- }
- </style>
- <script>
- // Enter JavaScript-land!
- // First, some functions, followed by initialization commands
-
- // toggleVisible(id)
- // Toggles the visibility of a given element by given ID
- function toggleVisible(id) {
- var x = document.getElementById(id);
- if (x.style.display === "none") {
- x.style.display = "block";
- } else {
- x.style.display = "none";
- }
- }
- // classDisplayAll(className, value)
- // Assigns given display value to all elements with a given className
- function classDisplayAll(className, value) {
- var elements = document.getElementsByClassName(className);
- for (var i = 0; i < elements.length; i++) {
- elements[i].style.display = value;
- }
- }
- // toggleEditMode()
- // Toggles whether editable fields are editable or not
- // and removes editing tools.
- function toggleEditMode() {
- if (editMode === true) {
- editMode = false;
- classDisplayAll("section","block");
- classDisplayAll("button","none");
- classDisplayAll("question","none");
- var editableFields = document.getElementsByClassName("editable");
- // de-editable-ize the editable fields
- for (var i = 0; i < editableFields.length; i++) {
- editableFields[i].contentEditable = "false";
- editableFields[i].style.borderStyle = "none";
- // Remove empty fields entirely
- var content = editableFields[i].innerHTML;
- content = content.replace(/(<([^>]+)>)/ig,''); // strips stray tags
- if (content === "") {
- editableFields[i].style.display = "none";
- }
- }
- // Remove headers of empty sections
- // Inefficient! Might be merged with the above iteration
- var sections = document.getElementsByClassName("section");
- for (var i = 0; i < sections.length; i++) {
- var sectionQuestions = sections[i].getElementsByClassName("editable");
- var blanks = 0;
- for (var x = 0; x < sectionQuestions.length; x++) {
- var content = sectionQuestions[x].innerHTML;
- content = content.replace(/(<([^>]+)>)/ig,''); // strips stray tags
- if (content == "") { blanks++; }
- if (blanks == sectionQuestions.length) {
- var headerID = "header-s" + (i + 1);
- document.getElementById(headerID).style.display = "none";
- }
- }
- }
- // Finally, change button name
- document.getElementById("editToggle").innerHTML = "Customize";
- } else {
- editMode = true;
- classDisplayAll("button","block");
- classDisplayAll("question","block");
- classDisplayAll("editable","block");
- classDisplayAll("header","block");
- classDisplayAll("section","none");
- var editableFields = document.getElementsByClassName("editable");
- for (var i = 0; i < editableFields.length; i++) {
- editableFields[i].style.borderStyle = "none none dashed none";
- editableFields[i].contentEditable = "true";
- }
- // Change button name
- document.getElementById("editToggle").innerHTML = "Preview";
- }
- }
- // toggleDisplayMode()
- // toggles full displayMode, the Rule-only display for a published Rule
- // first, initialize variable:
- var displayMode = false;
- function toggleDisplayMode() {
- if (displayMode == false) {
- editMode = true;
- toggleEditMode(); // turns off editMode
- classDisplayAll("site-nav","none");
- classDisplayAll("post-header","none");
- classDisplayAll("site-footer","none");
- document.getElementById("attribution").style.display = "block";
- document.getElementById("toggleDisplayMode").style.display = "inline-block";
- document.getElementById("publishRule").style.display = "none";
- document.getElementById("trash").style.display = "inline-block";
- document.getElementById("title").innerHTML =
- document.getElementById("communityname").innerHTML + " / CommunityRule";
- displayMode = true;
- } else {
- toggleEditMode() // turns on editMode
- classDisplayAll("site-nav","block");
- classDisplayAll("post-header","block");
- classDisplayAll("site-footer","block");
- document.getElementById("attribution").style.display = "none";
- document.getElementById("toggleDisplayMode").style.display = "none";
- document.getElementById("publishRule").style.display = "inline-block";
- document.getElementById("trash").style.display = "none";
- displayMode = false;
- }
- }
- // textOutput()
- // Produces Markdown rendition of Rule
- function textOutput() {
- var filename = 'CommunityRule.txt';
- var content = '# '+ document.getElementById('communityname').innerHTML + '\n\n';
- content = content.replace(/(<([^>]+)>)/ig,''); // strips stray tags
- var elements = document.getElementsByClassName('output');
- for (var i = 1; i < elements.length; i++) {
- var thisBit = elements[i].innerHTML;
- thisBit = thisBit.replace(/(<([^>]+)>)/ig,''); // strips stray tags
- if (thisBit != "") {
- if (elements[i].classList.contains("subhead")) {
- content += '## ';
- }
- content += elements[i].innerHTML + '\n\n';
- }
- }
- content += document.getElementById('attributionMD').innerHTML;
- // Starting here, see https://stackoverflow.com/a/33542499
- var blob = new Blob([content], {type: 'text/plain'});
- if(window.navigator.msSaveOrOpenBlob) {
- window.navigator.msSaveBlob(blob, filename);
- }
- else{
- var elem = window.document.createElement('a');
- elem.href = window.URL.createObjectURL(blob);
- elem.download = filename;
- document.body.appendChild(elem);
- elem.click();
- document.body.removeChild(elem);
- URL.revokeObjectURL(); // This needs an arg but I can't figure out what
- }
- var myFile = new Blob([fileContent], {type: 'text/plain'});
- window.URL = window.URL || window.webkitURL; document.getElementById('download').setAttribute('href',window.URL.createObjectURL(myFile));
- document.getElementById('download').setAttribute('download', fileName);
- }
- // BEGIN Publish tools, via SteinHQ.com
- // publishRule()
- // Publishes existing fields to new page, /create/?rule=[ruleID]
- // Opens new page in Display mode
- function publishRule() {
- var now = new Date();
- // Numerical ID for published Rule
- var timeID = now.getTime();
- // Readable UTC timestamp
- var dateTime = now.getUTCFullYear()+'.'+(now.getUTCMonth()+1)+'.'+now.getUTCDate()
- +' '+now.getUTCHours()+":"+ now.getUTCMinutes()+":"+now.getUTCSeconds()
- + ' UTC';
- // TKTK: Check if ruleID exists; while yes, replace and repeat
- var rule = [{
- ruleID: timeID,
- timestamp: dateTime,
- }];
- var fields = document.getElementsByClassName("editable");
- for (var i = 0; i < fields.length; i++) {
- var key = fields[i].id;
- var value = fields[i].innerHTML.replace(/(<([^>]+)>)/ig,"");
- rule[0][key] = value;
- }
- const store = new SteinStore(
- "https://api.steinhq.com/v1/storages/5e8b937ab88d3d04ae0816a5"
- );
- store.append("rules", rule).then(data => {
- window.open("/create/?r=" + timeID, "_self", false);
- });
- }
- // displayRule(ID)
- // Displays content based on ID
- function displayRule(ID) {
- const store = new SteinStore(
- "https://api.steinhq.com/v1/storages/5e8b937ab88d3d04ae0816a5"
- );
- store.read("rules", { search: { ruleID: ID } }).then(data => {
- // only runs when we have the data from Goog:
- var rule = data[0];
- var fields = document.getElementsByClassName("editable");
- for (var i = 0; i < fields.length; i++) {
- var key = fields[i].id;
- var value = rule[key];
- if (typeof value === "undefined") {
- value = "";
- }
- document.getElementById(key).innerHTML = value;
- }
- // Publish timestamp to Rule
- document.getElementById('dateTime').innerHTML = rule['timestamp'];
- // Finish
- displayMode = false;
- toggleDisplayMode();
- document.title = rule['communityname'] + " / CommunityRule";
- });
- }
- // deleteRule()
- // A temporary placeholder that sends an email requesting rule deletion
- function deleteRule() {
- var urlParamz = new URLSearchParams(window.location.search);
- var rID = urlParamz.get('r');
- window.open("mailto:medlab@colorado.edu?subject=Delete Rule request ("
- + rID + ")&body=Please explain your rationale:\n");
- }
-
- // END Publish tools
-
- // FINALLY, Page loading
- // First, grab the current URL
- var urlParams = new URLSearchParams(window.location.search);
- // Determine if it is a published Rule
- if (urlParams.has('r')) {
- // If so, grab the Rule from database and enter displayMode
- var rID = urlParams.get('r');
- displayRule(rID);
- } else {
- // Otherwise, open in editMode as default
- var editMode = true;
- // switch out of editMode in special cases
- window.onload = function() {
- if ((window.location.href.indexOf("/templates/") != -1) ||
- (window.location.href.indexOf("/about/") != -1)) {
- toggleEditMode();
- }
- }
- }
- </script>
- <article class="post">
- <header class="post-header">
- <h1 class="post-title" id="title">
- {{ page.title }}
- </h1>
- <button class="pushButton" id="editToggle" onclick="toggleEditMode()">
- Preview</button>
- <div class="post-content">
- {{ content }}
- </div>
- </header>
-
- <div id="rulebox">
- <span class="question">What is the community’s name?</span>
- <h1 contenteditable="true" class="editable output" id="communityname">{{ page.community-name }}</h1>
- <!-- SECTION S1: BASICS -->
- <h2 id="header-s1" class="header">
- <img src="{% link assets/tabler_icons/info-circle.svg %}"
- class="icons" />
- <span class="subhead output">Basics</span>
- <button onclick="toggleVisible('s1')" class="button plus"> + </button>
- </h2>
- <div class="section" id="s1" style="display:none">
-
- <span class="question">What is the basic structure of the community?</span>
- <div class="button">Modules
- <span class="tooltiptext"><a target="_blank" href="https://democraticmediums.info/mediums/federation/">federation</a>, <a target="_blank" href="https://democraticmediums.info/mediums/friendship/">friendship</a>, <a target="_blank" href="https://democraticmediums.info/mediums/membership/">membership</a>, <a target="_blank" href="https://democraticmediums.info/mediums/multicameralism/">multicameralism</a>, <a target="_blank" href="https://democraticmediums.info/mediums/ritual/">ritual</a>, <a target="_blank" href="https://democraticmediums.info/mediums/separation_of_powers/">separation of powers</a>, <a target="_blank" href="https://democraticmediums.info/mediums/stake_weight/">stake weight</a></span>
- </div>
- <p contenteditable="true" class="editable output" id="structure">{{ page.structure }}</p>
- <span class="question">What is the community’s mission?</span>
- <p contenteditable="true" class="editable output" id="mission">{{ page.mission }}</p>
- <span class="question">What core values does the community hold?</span>
- <div class="button">Modules
- <span class="tooltiptext"><a target="_blank" href="https://democraticmediums.info/mediums/secrecy/">secrecy</a>, <a target="_blank" href="https://democraticmediums.info/mediums/solidarity/">solidarity</a>, <a target="_blank" href="https://democraticmediums.info/mediums/transparency/">transparency</a></span>
- </div>
- <p contenteditable="true" class="editable output" id="values">{{ page.values }}</p>
- <span class="question">What is the legal status of the community’s assets and creations?</span>
- <div class="button">Modules
- <span class="tooltiptext"><a target="_blank" href="https://medlabboulder.gitlab.io/democraticmediums/mediums/ownership/">ownership</a></span>
- </div>
- <p contenteditable="true" class="editable output" id="legal">{{ page.legal }}</p>
-
- </div><!--hiding section s1-->
- <!-- SECTION s2: PARTICIPANTS -->
- <h2 id="header-s2" class="header">
- <img src="{% link assets/tabler_icons/user.svg %}"
- class="icons" />
- <span class="subhead output">Participants</span>
- <button onclick="toggleVisible('s2')" class="button plus"> + </button>
- </h2>
-
- <div class="section" id="s2" style="display:none">
-
- <span class="question">How does someone become a participant?</span>
- <div class="button">Modules
- <span class="tooltiptext"><a target="_blank" href="https://democraticmediums.info/mediums/do-ocracy/">do-ocracy</a>, <a target="_blank" href="https://democraticmediums.info/mediums/friendship/">friendship</a>, <a target="_blank" href="https://democraticmediums.info/mediums/membership/">membership</a>, <a target="_blank" href="https://democraticmediums.info/mediums/reputation/">reputation</a></span>
- </div>
- <p contenteditable="true" class="editable output" id="membership">{{ page.membership }}</p>
-
- <span class="question">How are participants suspended or removed?</span>
- <div class="button">Modules
- <span class="tooltiptext"><a target="_blank" href="https://democraticmediums.info/mediums/exclusion/">exclusion</a>, <a target="_blank" href="https://democraticmediums.info/mediums/friendship/">friendship</a>, <a target="_blank" href="https://democraticmediums.info/mediums/reputation/">reputation</a></span>
- </div>
- <p contenteditable="true" class="editable output" id="removal">{{ page.removal }}</p>
- <span class="question">What special roles can participants hold, and how are roles assigned?</span>
- <div class="button">Modules
- <span class="tooltiptext"><a target="_blank" href="https://democraticmediums.info/mediums/delegation/">delegation</a>, <a target="_blank" href="https://democraticmediums.info/mediums/representation/">representation</a>, <a target="_blank" href="https://democraticmediums.info/mediums/separation_of_powers/">separation of powers</a></span>
- </div>
- <p contenteditable="true" class="editable output" id="roles">{{ page.roles }}</p>
- <span class="question">Are there limits on the terms or powers of participant roles?</span>
- <div class="button">Modules
- <span class="tooltiptext"><a target="_blank" href="https://democraticmediums.info/mediums/fact_finding/">fact-finding</a>, <a target="_blank" href="https://democraticmediums.info/mediums/ranked_choice/">ranked choice</a>, <a target="_blank" href="https://democraticmediums.info/mediums/representation/">representation</a>, <a target="_blank" href="https://democraticmediums.info/mediums/reputation/">reputation</a>, <a target="_blank" href="https://democraticmediums.info/mediums/sortition/">sortition</a>, <a target="_blank" href="https://democraticmediums.info/mediums/term_limit/">term limits</a></span>
- </div>
- <p contenteditable="true" class="editable output" id="limits">{{ page.limits }}</p>
-
- </div><!--hiding section s2-->
- <!--SECTION s3: POLICY-->
- <h2 id="header-s3" class="header">
- <img src="{% link assets/tabler_icons/news.svg %}"
- class="icons" />
- <span class="subhead output">Policy</span>
- <button onclick="toggleVisible('s3')" class="button plus"> + </button>
- </h2>
- <div class="section" id="s3" style="display:none">
- <span class="question">What basic rights does this Rule guarantee?</span>
- <p contenteditable="true" class="editable output" id="rights">{{ page.rights }}</p>
-
- <span class="question">Who has the capacity to decide on policies, and how do they do so?</span>
- <div class="button">Modules
- <span class="tooltiptext"><a target="_blank" href="https://democraticmediums.info/mediums/disapproval_voting/">disapproval voting</a>, <a target="_blank" href="https://democraticmediums.info/mediums/do-ocracy/">do-ocracy</a>, <a target="_blank" href="https://democraticmediums.info/mediums/holographic_consensus/">holographic consensus</a>, <a target="_blank" href="https://democraticmediums.info/mediums/quadratic_voting/">quadratic voting</a>, <a target="_blank" href="https://democraticmediums.info/mediums/referendum/">referendum</a>, <a target="_blank" href="https://democraticmediums.info/mediums/representation/">representation</a>, <a target="_blank" href="https://democraticmediums.info/mediums/sortition/">sortition</a></span>
- </div>
- <p contenteditable="true" class="editable output" id="decision">{{ page.decision }}</p>
-
- <span class="question">How are policies implemented?</span>
- <div class="button">Modules
- <span class="tooltiptext"><a target="_blank" href="https://democraticmediums.info/mediums/exclusion/">exclusion</a>, <a target="_blank" href="https://democraticmediums.info/mediums/lazy_consensus/">lazy consensus</a>, <a target="_blank" href="https://democraticmediums.info/mediums/restorative_justice/">restorative justice</a></span>
- </div>
- <p contenteditable="true" class="editable output" id="implementation">{{ page.implementation }}</p>
-
- <span class="question">How does the community monitor and evaluate its policy implementation? </span>
- <div class="button">Modules
- <span class="tooltiptext"><a target="_blank" href="https://democraticmediums.info/mediums/board/">board</a>, <a target="_blank" href="https://democraticmediums.info/mediums/disapproval_voting/">disapproval voting</a>, <a target="_blank" href="https://democraticmediums.info/mediums/judiciary/">jury</a>, <a target="_blank" href="https://democraticmediums.info/mediums/precedent/">precedent</a>, <a target="_blank" href="https://democraticmediums.info/mediums/refusal/">refusal</a>, <a target="_blank" href="https://democraticmediums.info/mediums/rough_consensus/">rough consensus</a></span>
- </div>
- <p contenteditable="true" class="editable output" id="oversight">{{ page.oversight }}</p>
-
- </div><!--hiding section s3-->
- <!-- SECTION s4: PROCESS -->
- <h2 id="header-s4" class="header">
- <img src="{% link assets/tabler_icons/refresh.svg %}"
- class="icons" />
- <span class="subhead output">Process</span>
- <button onclick="toggleVisible('s4')" class="button plus"> + </button>
- </h2>
- <div class="section" id="s4" style="display:none">
- <span class="question">How does the community manage access to administrative accounts and other tools?</span>
- <p contenteditable="true" class="editable output" id="access">{{ page.access }}</p>
- <span class="question">How does the community manage funds and economic flows?</span>
- <p contenteditable="true" class="editable output" id="economics">{{ page.economics }}</p>
- <span class="question">Where does the community deliberate about policies and governance?</span>
- <div class="button">Modules
- <span class="tooltiptext"><a target="_blank" href="https://democraticmediums.info/mediums/caucus/">caucus</a>, <a target="_blank" href="https://democraticmediums.info/mediums/coalition/">coalition</a>, <a target="_blank" href="https://democraticmediums.info/mediums/board/">board</a>, <a target="_blank" href="https://democraticmediums.info/mediums/debate/">debate</a>, <a target="_blank" href="https://democraticmediums.info/mediums/lobbying/">lobbying</a>, <a target="_blank" href="https://democraticmediums.info/mediums/recess/">recess</a>, <a target="_blank" href="https://democraticmediums.info/mediums/secrecy/">secrecy</a>, <a target="_blank" href="https://democraticmediums.info/mediums/transparency/">transparency</a></span>
- </div>
- <p contenteditable="true" class="editable output" id="deliberation">{{ page.deliberation }}</p>
-
- <span class="question">How are grievances among participants addressed?</span>
- <div class="button">Modules
- <span class="tooltiptext"><a target="_blank" href="https://democraticmediums.info/mediums/audit/">audit</a>, <a target="_blank" href="https://democraticmediums.info/mediums/debate/">debate</a>, <a target="_blank" href="https://democraticmediums.info/mediums/friendship/">friendship</a>, <a target="_blank" href="https://democraticmediums.info/mediums/restorative_justice/">restorative justice</a>, <a target="_blank" href="https://democraticmediums.info/mediums/recess/">recess</a></span>
- </div>
- <p contenteditable="true" class="editable output" id="grievances">{{ page.grievances }}</p>
-
- </div><!--hiding section s4-->
- <!-- SECTION s5: EVOLUTION -->
- <h2 id="header-s5" class="header">
- <img src="{% link assets/tabler_icons/adjustments.svg %}"
- class="icons" />
- <span class="subhead output">Evolution</span>
- <button onclick="toggleVisible('s5')" class="button plus"> + </button>
- </h2>
- <div class="section" id="s5" style="display:none">
- <span class="question">Where are policies and records kept?</span>
- <p contenteditable="true" class="editable output" id="records">{{ page.records }}</p>
- <span class="question">How can this Rule be modified?</span>
- <p contenteditable="true" class="editable output" id="modification">{{ page.modification }}</p>
- </div><!--hiding section s5-->
- <div id="attribution" style="display:none;">
- <br />
- <p><a href="https://communityrule.info">
- <img src="https://communityrule.info{% link assets/CommunityRule-derived-000000.svg %}" alt="CommunityRule derived"></a></p>
- <p id="dateTime"></p>
- <p>Created with <a href="https://communityrule.info">CommunityRule</a><br />
- <a href="https://creativecommons.org/licenses/by-sa/4.0/">Creative Commons BY-SA</a></p>
- <p><strong>The Publish feature is experimental. Rules may be removed without notice</strong></p>
- </div>
- <div id="attributionMD" style="display:none;">
- ---
- [](https://communityrule.info)
- Created with [CommunityRule](https://communityrule.info)
- [Creative Commons BY-SA](https://creativecommons.org/licenses/by-sa/4.0/)</div>
-
- </div><!--#rulebox-->
- <button class="pushButton" id="publishRule" onclick="publishRule()">Publish</button>
- <button class="pushButton" id="toggleDisplayMode" onclick="toggleDisplayMode()">Fork</button>
- <button class="pushButton" onclick="textOutput()">Markdown</button>
- <button class="pushButton" id="trash" onclick="deleteRule()">
- <img src="{% link assets/tabler_icons/trash.svg %}" title="Rule deletion request" />
- </button>
-
- </article>
|