Repository navigation
Use CodeMirror in ruleset debugger (#11794) #13560
Changes from all commits
e687645
4b19b49
818100d
7facfed
f2c334b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| external/* | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,40 @@ | ||
| .section-header{ | ||
| margin-bottom: 10px; | ||
| .cm-s-main{ | ||
| width: 100%; | ||
| height: 500px; | ||
| } | ||
|
|
||
| .cm-s-saved{ | ||
| border: 1px solid black; | ||
| } | ||
|
|
||
| .cm-s-unsaved{ | ||
| border: 1px solid red; | ||
| } | ||
|
|
||
| .section-explainer{ | ||
| margin-bottom: 5px; | ||
| } | ||
|
|
||
| .section-header{ | ||
| margin-bottom: 10px; | ||
| } | ||
|
|
||
| .section-header-span{ | ||
| border-bottom: 1px solid #ccc; | ||
| font-size: 15px; | ||
| } | ||
|
|
||
| #debugging-rulesets{ | ||
| width: 100%; | ||
| height: 500px; | ||
| #saved-text{ | ||
| display: none; | ||
| border: 1px solid black; | ||
| } | ||
|
|
||
| #debugging-rulesets.unsaved{ | ||
| border: 1px solid red; | ||
| color: green; | ||
| font-weight: bold; | ||
| margin: 30px; | ||
| } | ||
|
|
||
| #changed{ | ||
| #unsaved-text{ | ||
| font-weight: bold; | ||
| margin: 10px 0px; | ||
| color: #F00; | ||
| color: red; | ||
| visibility: hidden; | ||
| text-align: center; | ||
| } | ||
|
|
||
| #saved{ | ||
| display: none; | ||
| color: green; | ||
| font-weight: bold; | ||
| margin: 30px; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,37 +1,44 @@ | ||
| /* global sendMessage */ | ||
| /* global sendMessage, CodeMirror */ | ||
|
|
||
| "use strict"; | ||
|
|
||
| const debugging_rulesets_textarea = document.getElementById("debugging-rulesets"); | ||
| const changed = document.getElementById("changed"); | ||
| const default_title = "Debugging Rulesets"; | ||
| const unsaved_title = "* Debugging Rulesets"; | ||
| const savedTextElement = document.getElementById("saved-text"); | ||
| const unsavedTextElement = document.getElementById("unsaved-text"); | ||
| const savedTitle = "Debugging Rulesets"; | ||
| const unsavedTitle = "* Debugging Rulesets"; | ||
|
|
||
| debugging_rulesets_textarea.addEventListener("input", debugging_rulesets_changed); | ||
| document.getElementById("debugging-rulesets-form").addEventListener("submit", save_debugging_rulesets); | ||
| document.title = savedTitle; | ||
|
|
||
| document.title = default_title; | ||
| const cm = CodeMirror.fromTextArea( | ||
| document.getElementById("codemirror-textarea"), | ||
| { | ||
| mode: "xml", | ||
| theme: "default main saved" | ||
| } | ||
| ); | ||
|
|
||
| let valueHasChanged = false; | ||
| sendMessage("get_option", { debugging_rulesets: "" }, item => { | ||
| debugging_rulesets_textarea.value = item.debugging_rulesets; | ||
| debugging_rulesets_textarea.style.display = "block"; | ||
| cm.setValue(item.debugging_rulesets); | ||
| cm.on("change", cm => { | ||
| if (!(valueHasChanged)) { | ||
| valueHasChanged = true; | ||
| document.title = unsavedTitle; | ||
| cm.setOption("theme", "default main unsaved"); | ||
| unsavedTextElement.style.visibility = "visible"; | ||
| } | ||
| }); | ||
| }); | ||
|
|
||
| function save_debugging_rulesets(e){ | ||
| document.getElementById("save-button").addEventListener("click", e => { | ||
| e.preventDefault(); | ||
| sendMessage("set_option", { debugging_rulesets: debugging_rulesets_textarea.value }, () => { | ||
| const saved = document.getElementById("saved"); | ||
| saved.style.display = "block"; | ||
| setTimeout(() => { saved.style.display = "none" }, 1000); | ||
|
|
||
| document.title = default_title; | ||
| debugging_rulesets_textarea.className = ""; | ||
| changed.style.visibility = "hidden"; | ||
| sendMessage("set_option", { debugging_rulesets: cm.getValue() }, () => { | ||
| savedTextElement.style.display = "block"; | ||
| setTimeout(() => { savedTextElement.style.display = "none" }, 1000); | ||
|
|
||
| valueHasChanged = false; | ||
| document.title = savedTitle; | ||
| cm.setOption("theme", "default main saved"); | ||
| unsavedTextElement.style.visibility = "hidden"; | ||
| }); | ||
| } | ||
|
|
||
| function debugging_rulesets_changed(){ | ||
| debugging_rulesets_textarea.className = "unsaved"; | ||
| document.title = unsaved_title; | ||
| changed.style.visibility = "visible"; | ||
| } | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| # External dependencies | ||
|
|
||
| This directory contains files that are external dependencies for HTTPS Everywhere, with instructions on how to get or remake them. | ||
|
|
||
| ## CodeMirror 5.31.0 | ||
|
|
||
| ``` | ||
| $ npm install uglify-js@3.1.9 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is not a package dependency and is intended to be run as a command line app, let's add a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the drawback of defining all the dependencies in Global packages should be avoided when possible. Someone may skip those steps as they've already performed them before and not notice they've since installed different versions since some other project required different ones. Using local packages gets rid of that problem.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, but the above command will cause There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any reason to specify those packages directly instead of just having BTW, if you're referring to the binary by path, it's usually better to use
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mgol creating a dependency management system is on the table, but I don't want to block merging until we have one in place. See #13560 (comment) and resulting discussion.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These instructions are supposed to give someone who is knowledgeable about |
||
| $ npm install uglifycss@0.0.27 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #13560 (comment). |
||
| $ curl -o codemirror.zip https://codemirror.net/codemirror-5.31.0.zip | ||
| $ unzip codemirror.zip | ||
| ``` | ||
|
|
||
| ### codemirror-5.31.0.min.js | ||
|
|
||
| ```bash | ||
| uglifyjs \ | ||
| --compress \ | ||
| --mangle \ | ||
| --comments '/copyright|license/' \ | ||
| --output codemirror-5.31.0.min.js \ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Relating to the suggestion above of adding each external dependency to its own unique path, we'll want to change these output paths to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See #13560 (comment). |
||
| codemirror-5.31.0/lib/codemirror.js | ||
| ``` | ||
|
|
||
| ### codemirror-5.31.0.xml.min.js | ||
|
|
||
| ```bash | ||
| uglifyjs \ | ||
| --compress \ | ||
| --mangle \ | ||
| --comments '/copyright|license/' \ | ||
| --output codemirror-5.31.0.xml.min.js \ | ||
| codemirror-5.31.0/mode/xml/xml.js | ||
| ``` | ||
|
|
||
| ### codemirror-5.31.0.min.css | ||
|
|
||
| ```bash | ||
| uglifycss \ | ||
| --output codemirror-5.31.0.min.css \ | ||
| codemirror-5.31.0/lib/codemirror.css | ||
| ``` | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll want to add
chromium/.eslintignoreto the top-level.build_exclusionsas well.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.