You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@community.apache.org by hu...@apache.org on 2019/08/01 23:50:51 UTC
svn commit: r1864189 - in /comdev/reporter.apache.org/trunk/site/wizard:
highlighter/highlighter.css highlighter/highlighter.js
js/source/generators.js js/source/primer.js js/source/unified.js
js/wizard.js unified.html
Author: humbedooh
Date: Thu Aug 1 23:50:51 2019
New Revision: 1864189
URL: http://svn.apache.org/viewvc?rev=1864189&view=rev
Log:
Updates:
- move section parser into its own function
- lightly highlight the active section being worked on
- stricter highlighting
Modified:
comdev/reporter.apache.org/trunk/site/wizard/highlighter/highlighter.css
comdev/reporter.apache.org/trunk/site/wizard/highlighter/highlighter.js
comdev/reporter.apache.org/trunk/site/wizard/js/source/generators.js
comdev/reporter.apache.org/trunk/site/wizard/js/source/primer.js
comdev/reporter.apache.org/trunk/site/wizard/js/source/unified.js
comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js
comdev/reporter.apache.org/trunk/site/wizard/unified.html
Modified: comdev/reporter.apache.org/trunk/site/wizard/highlighter/highlighter.css
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/highlighter/highlighter.css?rev=1864189&r1=1864188&r2=1864189&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/wizard/highlighter/highlighter.css (original)
+++ comdev/reporter.apache.org/trunk/site/wizard/highlighter/highlighter.css Thu Aug 1 23:50:51 2019
@@ -40,6 +40,7 @@
border-width: 1px;
border-style: solid;
background: none transparent !important;
+ caret-color: black;
}
.hwt-content mark {
@@ -60,11 +61,20 @@
background-color: #ffec99;
}
-.hwt-content mark.green {
- background-color: #ecff99;
+.hwt-content div.green {
+ background-color: #efe;
+ width: 100%;
+ display: inline-block;
}
+mark.green {
+ visibility: hidden;
+}
+
+
.hwt-content mark.none {
+/* color: red !important;*/
+ caret-color: red;
background-color: #DDD;
border-radius: 2px;
border: 0.5px dashed red;
Modified: comdev/reporter.apache.org/trunk/site/wizard/highlighter/highlighter.js
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/highlighter/highlighter.js?rev=1864189&r1=1864188&r2=1864189&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/wizard/highlighter/highlighter.js (original)
+++ comdev/reporter.apache.org/trunk/site/wizard/highlighter/highlighter.js Thu Aug 1 23:50:51 2019
@@ -285,8 +285,8 @@
getStringRanges: function(input, str) {
let ranges = [];
- let inputLower = input.toLowerCase();
- let strLower = str.toLowerCase();
+ let inputLower = input;//.toLowerCase();
+ let strLower = str;//.toLowerCase();
let index = 0;
while (index = inputLower.indexOf(strLower, index), index !== -1) {
ranges.push([index, index + strLower.length]);
@@ -390,6 +390,7 @@
input = input.replace(/\{\{hwt-mark-start\|(\d+)\}\}/g, function(match, submatch) {
var className = boundaries[+submatch].className;
if (className) {
+ if (className == 'green') return '<div class="green"><mark class="green">'
return '<mark class="' + className + '">';
} else {
return '<mark>';
@@ -397,7 +398,7 @@
});
// replace stop tokens with closing </mark> tags
- input = input.replace(/\{\{hwt-mark-stop\}\}/g, '</mark>');
+ input = input.replace(/\{\{hwt-mark-stop\}\}/g, '</mark></div>');
this.$highlights.html(input);
},
Modified: comdev/reporter.apache.org/trunk/site/wizard/js/source/generators.js
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/js/source/generators.js?rev=1864189&r1=1864188&r2=1864189&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/wizard/js/source/generators.js (original)
+++ comdev/reporter.apache.org/trunk/site/wizard/js/source/generators.js Thu Aug 1 23:50:51 2019
@@ -232,34 +232,7 @@ function check_compile(data) {
let text = "";
if (editor_type == 'unified') {
let required_sections = [];
- let sections = [];
- let tmp = document.getElementById('unified-report').value;
- while (tmp.length > 0) {
- let nextheader = tmp.match(/^## ([^\r\n]+)\r?\n/m);
- if (nextheader) {
- console.log("Found report header: %s".format(nextheader[0]))
- let title = nextheader[1];
- let spos = tmp.indexOf(nextheader[0]);
- if (spos != -1) {
- tmp = tmp.substr(spos + nextheader[0].length);
- let epos = tmp.search(/^## [^\r\n]+/m);
- epos = (epos == -1) ? tmp.length : epos;
- let section = tmp.substr(0, epos);
- if (title.length > 2) {
- sections.push({
- title: title.replace(/:.*$/, ''),
- text: section
- });
- }
- console.log("Section contains:");
- console.log(section)
- tmp = tmp.substr(epos);
- } else { break }
- } else {
- console.log("No more report headers found.");
- }
-
- }
+ let sections = parse_unified();
for (var i = 0; i < step_json.length; i++) {
let step = step_json[i];
Modified: comdev/reporter.apache.org/trunk/site/wizard/js/source/primer.js
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/js/source/primer.js?rev=1864189&r1=1864188&r2=1864189&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/wizard/js/source/primer.js (original)
+++ comdev/reporter.apache.org/trunk/site/wizard/js/source/primer.js Thu Aug 1 23:50:51 2019
@@ -47,7 +47,9 @@ function prime_steps(state, json) {
build_steps(0, true);
}
-function build_steps(s, start, noclick) {
+let hilite_timer = null;
+
+function build_steps(s, start, noclick, e) {
s = s || 0;
let text = document.getElementById('step_text');
@@ -56,6 +58,7 @@ function build_steps(s, start, noclick)
}
text.innerText = '';
+ let step_changed = (s == current_step) ? false : true;
current_step = s;
let stepParent = document.getElementById('steps');
@@ -172,7 +175,15 @@ function build_steps(s, start, noclick)
helper.innerHTML += data;
}
// If clicked to a section, move cursor
- if (!noclick) set_position(step.description);
+ if (!noclick) {
+ set_position(step.description);
+ }
+ if (step_changed || !noclick) mark_section(step.description);
+ else {
+ window.clearTimeout(hilite_timer);
+ if (event && event.keyCode == 13) mark_section(step.description);
+ else hilite_timer = window.setTimeout(() => { mark_section(step.description)}, 100);
+ }
}
}
Modified: comdev/reporter.apache.org/trunk/site/wizard/js/source/unified.js
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/js/source/unified.js?rev=1864189&r1=1864188&r2=1864189&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/wizard/js/source/unified.js (original)
+++ comdev/reporter.apache.org/trunk/site/wizard/js/source/unified.js Thu Aug 1 23:50:51 2019
@@ -1,25 +1,33 @@
-function hilite_sections() {
- if (highlighted) return;
+function hilite_sections(b) {
+ if (highlighted && !b) return;
highlighted = true;
- let hilites = [
- {highlight: /^## [^\r\n]+:/mg, className: 'blue' },
- {highlight: PLACEHOLDER, className: 'none' }
- ];
- let hcolors = ['blue', 'green', 'red', 'yellow'];
- for (var i = 1; i < step_json.length-1; i++) {
- let step = step_json[i];
- let tline = "## %s:".format(step.description);
- console.log(step.description);
+ let hilites = [];
+
+
+ hilites.push({highlight: /^## [^\r\n]+:/mg, className: 'blue' });
+ hilites.push({highlight: PLACEHOLDER, className: 'none' });
+
+ let x = $('#unified-report').selectionStart;
+ let y = $('#unified-report').selectionEnd;
+
+ if (b) {
+ $('#unified-report').highlightWithinTextarea('destroy');
hilites.push({
- highlight: tline,
- className: hcolors[i%hcolors.length]
+ highlight: b,
+ className: 'green'
});
-
}
+
+
$('#unified-report').highlightWithinTextarea({
- highlight: hilites
- });
+ highlight: hilites
+ });
+ if (x == y) {
+ $('#unified-report').selectionStart = x;
+ $('#unified-report').selectionEnd = y;
+ $('#unified-report').focus();
+ }
}
@@ -27,7 +35,7 @@ let report_unified = "";
let report_changed = true;
let highlighted = false;
-function find_section() {
+function find_section(e) {
let tmp = document.getElementById('unified-report').value;
report_changed = (report_unified == tmp) ? false : true;
report_unified = tmp;
@@ -48,7 +56,7 @@ function find_section() {
}
if (at_step) {
- build_steps(at_step, false, true);
+ build_steps(at_step, false, true, e);
} else {
helper.innerText = "";
@@ -63,4 +71,60 @@ function set_position(text) {
editor.selectionEnd = (pos + text.length + 2);
editor.focus();
}
+}
+
+// Parses a unified report into sections
+function parse_unified(quiet) {
+ let sections = [];
+ let sX = 0;
+ let tmp = document.getElementById('unified-report').value;
+ while (tmp.length > 0) {
+ let nextheader = tmp.match(/^## ([^\r\n]+)\r?\n/m);
+ if (nextheader) {
+ if (!quiet) console.log("Found report header: %s".format(nextheader[0]))
+ let title = nextheader[1];
+ let spos = tmp.indexOf(nextheader[0]);
+ if (spos != -1) {
+ sX += spos + nextheader[0].length;
+ sY = sX;
+ tmp = tmp.substr(spos + nextheader[0].length);
+ let epos = tmp.search(/^## [^\r\n]+/m);
+ epos = (epos == -1) ? tmp.length : epos;
+ let section = tmp.substr(0, epos);
+ if (title.length > 2) {
+ sections.push({
+ title: title.replace(/:.*$/, ''),
+ text: section,
+ start: sX,
+ end: sX + epos
+ });
+ }
+ if (!quiet) console.log("Section contains:");
+ if (!quiet) console.log(section)
+ tmp = tmp.substr(epos);
+ } else { break }
+ } else {
+ if (!quiet) console.log("No more report headers found.");
+ }
+
+ }
+ return sections;
+}
+
+
+// Mark a section using the highlighter
+function mark_section(title) {
+ let sections = parse_unified(true);
+ let foundit = false;
+ for (var i = 0; i < sections.length; i++) {
+ if (sections[i].title == title && sections[i].text.indexOf(PLACEHOLDER) == -1 && sections[i].text.length > 4) {
+ //console.log("Marking entire %s section from %u to %u".format(title, sections[i].start, sections[i].end))
+ hilite_sections(sections[i].text);
+ foundit = true;
+ break
+ }
+ }
+ if (!foundit) {
+ hilite_sections("<-- EXTERMINATE -->");
+ }
}
\ No newline at end of file
Modified: comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js?rev=1864189&r1=1864188&r2=1864189&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js (original)
+++ comdev/reporter.apache.org/trunk/site/wizard/js/wizard.js Thu Aug 1 23:50:51 2019
@@ -1381,34 +1381,7 @@ function check_compile(data) {
let text = "";
if (editor_type == 'unified') {
let required_sections = [];
- let sections = [];
- let tmp = document.getElementById('unified-report').value;
- while (tmp.length > 0) {
- let nextheader = tmp.match(/^## ([^\r\n]+)\r?\n/m);
- if (nextheader) {
- console.log("Found report header: %s".format(nextheader[0]))
- let title = nextheader[1];
- let spos = tmp.indexOf(nextheader[0]);
- if (spos != -1) {
- tmp = tmp.substr(spos + nextheader[0].length);
- let epos = tmp.search(/^## [^\r\n]+/m);
- epos = (epos == -1) ? tmp.length : epos;
- let section = tmp.substr(0, epos);
- if (title.length > 2) {
- sections.push({
- title: title.replace(/:.*$/, ''),
- text: section
- });
- }
- console.log("Section contains:");
- console.log(section)
- tmp = tmp.substr(epos);
- } else { break }
- } else {
- console.log("No more report headers found.");
- }
-
- }
+ let sections = parse_unified();
for (var i = 0; i < step_json.length; i++) {
let step = step_json[i];
@@ -1598,7 +1571,9 @@ function prime_steps(state, json) {
build_steps(0, true);
}
-function build_steps(s, start, noclick) {
+let hilite_timer = null;
+
+function build_steps(s, start, noclick, e) {
s = s || 0;
let text = document.getElementById('step_text');
@@ -1607,6 +1582,7 @@ function build_steps(s, start, noclick)
}
text.innerText = '';
+ let step_changed = (s == current_step) ? false : true;
current_step = s;
let stepParent = document.getElementById('steps');
@@ -1723,7 +1699,15 @@ function build_steps(s, start, noclick)
helper.innerHTML += data;
}
// If clicked to a section, move cursor
- if (!noclick) set_position(step.description);
+ if (!noclick) {
+ set_position(step.description);
+ }
+ if (step_changed || !noclick) mark_section(step.description);
+ else {
+ window.clearTimeout(hilite_timer);
+ if (event && event.keyCode == 13) mark_section(step.description);
+ else hilite_timer = window.setTimeout(() => { mark_section(step.description)}, 100);
+ }
}
}
@@ -1978,27 +1962,35 @@ function toggleView(id) {
******************************************/
-function hilite_sections() {
- if (highlighted) return;
+function hilite_sections(b) {
+ if (highlighted && !b) return;
highlighted = true;
- let hilites = [
- {highlight: /^## [^\r\n]+:/mg, className: 'blue' },
- {highlight: PLACEHOLDER, className: 'none' }
- ];
- let hcolors = ['blue', 'green', 'red', 'yellow'];
- for (var i = 1; i < step_json.length-1; i++) {
- let step = step_json[i];
- let tline = "## %s:".format(step.description);
- console.log(step.description);
+ let hilites = [];
+
+
+ hilites.push({highlight: /^## [^\r\n]+:/mg, className: 'blue' });
+ hilites.push({highlight: PLACEHOLDER, className: 'none' });
+
+ let x = $('#unified-report').selectionStart;
+ let y = $('#unified-report').selectionEnd;
+
+ if (b) {
+ $('#unified-report').highlightWithinTextarea('destroy');
hilites.push({
- highlight: tline,
- className: hcolors[i%hcolors.length]
+ highlight: b,
+ className: 'green'
});
-
}
+
+
$('#unified-report').highlightWithinTextarea({
- highlight: hilites
- });
+ highlight: hilites
+ });
+ if (x == y) {
+ $('#unified-report').selectionStart = x;
+ $('#unified-report').selectionEnd = y;
+ $('#unified-report').focus();
+ }
}
@@ -2006,7 +1998,7 @@ let report_unified = "";
let report_changed = true;
let highlighted = false;
-function find_section() {
+function find_section(e) {
let tmp = document.getElementById('unified-report').value;
report_changed = (report_unified == tmp) ? false : true;
report_unified = tmp;
@@ -2027,7 +2019,7 @@ function find_section() {
}
if (at_step) {
- build_steps(at_step, false, true);
+ build_steps(at_step, false, true, e);
} else {
helper.innerText = "";
@@ -2042,4 +2034,60 @@ function set_position(text) {
editor.selectionEnd = (pos + text.length + 2);
editor.focus();
}
+}
+
+// Parses a unified report into sections
+function parse_unified(quiet) {
+ let sections = [];
+ let sX = 0;
+ let tmp = document.getElementById('unified-report').value;
+ while (tmp.length > 0) {
+ let nextheader = tmp.match(/^## ([^\r\n]+)\r?\n/m);
+ if (nextheader) {
+ if (!quiet) console.log("Found report header: %s".format(nextheader[0]))
+ let title = nextheader[1];
+ let spos = tmp.indexOf(nextheader[0]);
+ if (spos != -1) {
+ sX += spos + nextheader[0].length;
+ sY = sX;
+ tmp = tmp.substr(spos + nextheader[0].length);
+ let epos = tmp.search(/^## [^\r\n]+/m);
+ epos = (epos == -1) ? tmp.length : epos;
+ let section = tmp.substr(0, epos);
+ if (title.length > 2) {
+ sections.push({
+ title: title.replace(/:.*$/, ''),
+ text: section,
+ start: sX,
+ end: sX + epos
+ });
+ }
+ if (!quiet) console.log("Section contains:");
+ if (!quiet) console.log(section)
+ tmp = tmp.substr(epos);
+ } else { break }
+ } else {
+ if (!quiet) console.log("No more report headers found.");
+ }
+
+ }
+ return sections;
+}
+
+
+// Mark a section using the highlighter
+function mark_section(title) {
+ let sections = parse_unified(true);
+ let foundit = false;
+ for (var i = 0; i < sections.length; i++) {
+ if (sections[i].title == title && sections[i].text.indexOf(PLACEHOLDER) == -1 && sections[i].text.length > 4) {
+ //console.log("Marking entire %s section from %u to %u".format(title, sections[i].start, sections[i].end))
+ hilite_sections(sections[i].text);
+ foundit = true;
+ break
+ }
+ }
+ if (!foundit) {
+ hilite_sections("<-- EXTERMINATE -->");
+ }
}
\ No newline at end of file
Modified: comdev/reporter.apache.org/trunk/site/wizard/unified.html
URL: http://svn.apache.org/viewvc/comdev/reporter.apache.org/trunk/site/wizard/unified.html?rev=1864189&r1=1864188&r2=1864189&view=diff
==============================================================================
--- comdev/reporter.apache.org/trunk/site/wizard/unified.html (original)
+++ comdev/reporter.apache.org/trunk/site/wizard/unified.html Thu Aug 1 23:50:51 2019
@@ -16,7 +16,7 @@ let editor_type = 'unified';
</script>
<title>ASF Board Report Wizard</title>
-<link rel="stylesheet" href="css/wizard.css?foo"/>
+<link rel="stylesheet" href="css/wizard.css?foo2"/>
<link rel="stylesheet" href="highlighter/highlighter.css"/>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
@@ -34,7 +34,7 @@ let editor_type = 'unified';
</div>
<div id="unified-editor">
- <textarea id="unified-report" onmouseup="find_section();" onkeyup="find_section();"></textarea>
+ <textarea id="unified-report" onmouseup="find_section();" onkeyup="find_section(event);"></textarea>
</div>
<div id="unified-helper"></div>