Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/techsneeze/dmarcts-report-viewer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjnew-gh <github@hazelden.ca>2021-05-04 03:42:42 +0300
committerjnew-gh <github@hazelden.ca>2021-05-04 03:42:42 +0300
commit96ee35814927772fac5eed00d7f0b545e606600f (patch)
tree3f60c3afa9bfe51576cb596ed08deacf8d280f10 /dmarcts-report-viewer.js
parent8ac72871670f669aff66798f6845b4a537299c41 (diff)
Add functions for xml highlighting
New functions to enable xml highlighting. Changes to how the cursor is displayed in some areas of the page.
Diffstat (limited to 'dmarcts-report-viewer.js')
-rw-r--r--dmarcts-report-viewer.js89
1 files changed, 89 insertions, 0 deletions
diff --git a/dmarcts-report-viewer.js b/dmarcts-report-viewer.js
index 046479f..100d485 100644
--- a/dmarcts-report-viewer.js
+++ b/dmarcts-report-viewer.js
@@ -218,13 +218,22 @@ function report_data_xml_display_toggle() {
if (xml_data_open == 0) {
xml_data_open = 1;
+ cursor('pointer')
set_report_data_widths();
} else {
+ unpin_all();
xml_data_open = 0;
+ cursor('default')
set_report_data_widths();
}
}
+function cursor(type) {
+
+ document.getElementById('report_desc').style.cursor = type;
+ document.getElementById('report_data_table').getElementsByTagName('tbody')[0].style.cursor = type
+}
+
function set_report_data_widths () {
// An allowance to accomodate Report Data table width expanding/contracting when sorting arrow is added to/removed from the column title
@@ -350,6 +359,10 @@ function showReport(str) {
if ( xml_data_open == 1 ) {
set_report_data_widths();
+ cursor('pointer')
+ }
+ if ( xml_data_hljs ) {
+ hljs.highlightAll();
}
}
};
@@ -655,3 +668,79 @@ function cancelOptions() {
}
window.location.href = 'dmarcts-report-viewer.php';
}
+
+// Functions to highlight XML data
+
+function highlight(element) {
+
+ if ( xml_data_open == 1 && xml_data_highlight == 1 ) {
+ element.classList.add('highlight');
+ document.getElementById(other_element(element.id)).classList.add('highlight')
+ }
+}
+
+function unhighlight(element) {
+
+ if ( xml_data_open == 1 && xml_data_highlight == 1 ) {
+ element.classList.remove("highlight");
+ document.getElementById(other_element(element.id)).classList.remove('highlight')
+ }
+}
+
+function pin(element) {
+
+ if ( xml_data_open == 1 && xml_data_highlight == 1 ) {
+ if ( element.className.indexOf('pinned') != -1 ){
+ // Unpins element
+ element.classList.remove('pinned');
+ document.getElementById(other_element(element.id)).classList.remove('pinned');
+ } else {
+ // Pins element
+ unpin_all();
+ element.classList.add('pinned');
+ document.getElementById(other_element(element.id)).classList.add('pinned');
+ if ( element.id.indexOf('record') == 0 ) {
+ document.getElementById(other_element(element.id)).scrollIntoView({ behavior: 'smooth', block: 'center' });
+ } else {
+ document.getElementById(other_element(element.id)).scrollIntoView({ behavior: 'smooth', block: 'start' });
+ }
+ }
+ }
+}
+
+function other_element(str) {
+
+ num = str.replace(/[a-zA-Z]+/g,"");
+ name = str.replace(/[0-9]+/g,"");
+
+ // Special case of first section of xml (report_metadata) and Report Description (report_desc)
+ if ( str == "report_desc" ) {
+ return "report_metadata";
+ }
+ if( str == "report_metadata") {
+ return "report_desc";
+ }
+
+ switch (name) {
+ case "record":
+ other_name = "line";
+ break;
+ case "line":
+ other_name = "record";
+ break;
+ default:
+ other_name = "";
+ }
+
+ return other_name + num;
+}
+
+function unpin_all() {
+
+ pinned = document.getElementsByClassName('pinned')
+ if ( pinned.length != 0 ) {
+ for ( i = 0; i <= pinned.length; i++ ) {
+ pinned[0].classList.remove('pinned');
+ }
+ }
+}