diff --git a/splunk_xml.js b/splunk_xml.js
index 751f98f..aecb102 100644
--- a/splunk_xml.js
+++ b/splunk_xml.js
@@ -1,6 +1,114 @@
var browser_ = typeof chrome !== "undefined" ? chrome : browser
let xml_enable_by_default = false;
+var Formatter = function (options) {
+ this.init(options);
+ //TODO - if options object maps any functions, add them as appropriately named methods
+ var methodName = this.options.method;
+ if (!$.isFunction(this[methodName])) {
+ $.error("'" + methodName + "' is not a Formatter method.");
+ };
+ this.format = function(text) { //alias to currently selected method
+ return this[this.options.method].call(this, text);
+ };
+};
+
+
+/**
+ * putting the methods into the prototype instead of the constructor method
+ * enables more efficient on-the-fly creation of Formatter instances
+ */
+var createShiftArr=function (step) {
+ var space = ' ';
+ if ( isNaN(parseInt(step)) ) { // argument is string
+ space = step;
+ } else { // argument is integer
+ space = new Array(step + 1).join(' '); //space is result of join (a string), not an array
+ }
+ var shift = ['\n']; // array of shifts
+ for(var ix=0;ix<100;ix++){
+ shift.push(shift[ix]+space);
+ }
+ return shift;
+};
+
+Formatter.prototype = {
+ options: {},
+
+ init: function(options) {
+ this.options = options;
+ this.step = this.options.step;
+ this.preserveComments = this.options.preserveComments;
+ this.shift = createShiftArr(this.step);
+ },
+
+ xml: function(text) {
+ var ar = text.replace(/>\s{0,}<")
+ .replace(/ or -1) {
+ str += this.shift[deep]+ar[ix];
+ inComment = true;
+ // end comment or //
+ if(ar[ix].search(/-->/) > -1 || ar[ix].search(/\]>/) > -1 || ar[ix].search(/!DOCTYPE/) > -1 ) {
+ inComment = false;
+ }
+ } else
+ // end comment or //
+ if(ar[ix].search(/-->/) > -1 || ar[ix].search(/\]>/) > -1) {
+ str += ar[ix];
+ inComment = false;
+ } else
+ //
');
}
function addListenerToEventExpander()
@@ -111,9 +223,10 @@ function processBlock(block)
if(is_string_valide_xml(raw_event))
{
let balise=$('Show raw event
');
- let content=$('
'+htmlEntities(formatXml(raw_event))+''); + hljs.configure({ tabReplace: ' '}); hljs.highlightBlock(block[0]); content.append(block); balise.click(function() { @@ -135,13 +248,29 @@ function processBlock(block) } } } +var waitForBlockInline = function(parentID, oldText, callback) +{ + let block = $("[data-cid='"+parentID+"']").find(".raw-event"); + new_text = block.text(); + if(new_text == oldText) { + setTimeout(function() { waitForBlockInline(parentID, oldText, callback); }, 2000); + } else { + callback(block); + } +} + var waitForBlockVisible = function(block, callback) { if(!block.attr("xml_done")) { if(!block.is(":visible")) { - setTimeout(waitForBlockVisible(block, callback), 2000); + setTimeout(function() { waitForBlockVisible(block, callback); }, 2000); + } + else if($(block.parent()).find(".showinline").length > 0) { + $(block.parent()).find(".showinline").click(function(){ + waitForBlockInline($(block.parent()).attr("data-cid"), block.text(), callback); + }); } else { @@ -212,6 +341,10 @@ $(document).keyup(function (e) { delete keys[e.which]; }); +$( document ).ajaxStart(function() { + console.info("Start AJAX Request"); +}); + if(typeof chrome !== "undefined"){ $( document ).ready(function() { browser_.runtime.sendMessage(message={"inject_splunk_js": checkForSplunk()}, responseCallback=function(response) { diff --git a/styles/splunk_xml.css b/styles/splunk_xml.css index cad2478..a720ae8 100644 --- a/styles/splunk_xml.css +++ b/styles/splunk_xml.css @@ -6,4 +6,6 @@ .beautiful_xml:hover { text-shadow: 0 0 red; text-decoration: underline; -} \ No newline at end of file +} + +.nowrap > pre { white-space: pre; } \ No newline at end of file