Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Item14288: reorganize logging; fixed search dialog
  • Loading branch information
MichaelDaum committed May 2, 2017
1 parent 9b1c875 commit 476b859
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 76 deletions.
Expand Up @@ -24,7 +24,6 @@ BaseEngine = function() {
if (typeof(self.opts) === 'undefined') {
self.opts = {};
}
self.log("BaseEngine::constructor");
};


Expand All @@ -34,7 +33,7 @@ BaseEngine = function() {
BaseEngine.prototype.init = function() {
var self = this;

//self.log("BaseEngine::init");
//self.shell.log("init");

return $.Deferred().resolve(self).promise();
};
Expand Down Expand Up @@ -98,17 +97,6 @@ BaseEngine.prototype.setValue = function(val) {
elem.val(val);
};

/*************************************************************************
* debug logging
*/
BaseEngine.prototype.log = function() {
var self = this;

if (console && self.opts.debug) {
console && console.log.apply(console, arguments); // eslint-disable-line no-console
}
};

/*************************************************************************
* insert stuff at the given cursor position
*/
Expand Down Expand Up @@ -277,7 +265,7 @@ BaseEngine.prototype.insertTable = function(opts) {
BaseEngine.prototype.insertLink = function(opts) {
var self = this, markup;

console.log("insertLink opts=",opts);
//console.log("insertLink opts=",opts);

if (typeof(opts.url) !== 'undefined') {
// external link
Expand Down
Expand Up @@ -435,6 +435,7 @@ CodemirrorEngine.prototype.openSearchDialog = function() {
var self = this;

if (self._searchDialogOpen) {
self.shell.log("dialog is open");
return;
}

Expand Down Expand Up @@ -559,7 +560,6 @@ CodemirrorEngine.prototype.setValue = function(val) {
*/
CodemirrorEngine.defaults = {
//value
debug: true,
mode: 'foswiki',
theme: 'foswiki',
indentUnit: 3,
Expand Down
Expand Up @@ -366,7 +366,7 @@ RawEngine.prototype.getSelectionRange = function() {
var self = this, text, c, range, rangeCopy, pos, selection,
txtarea = self.shell.txtarea;

//self.log("NATEDIT: called getSelectionRange()");
//self.shell.log("called getSelectionRange()");
//$(txtarea).focus();

if (self.oldIE) {
Expand Down Expand Up @@ -434,7 +434,7 @@ RawEngine.prototype.getSelectionLines = function() {
end++;
}

//self.log("start=",start,"end=",end);
//self.shell.log("start=",start,"end=",end);

self.setSelectionRange(start, end);

Expand All @@ -448,7 +448,7 @@ RawEngine.prototype.setSelectionRange = function(start, end) {
var self = this, lineFeeds, range,
txtarea = self.shell.txtarea;

//self.log("setSelectionRange("+txtarea+", "+start+", "+end+")");
//self.shell.log("setSelectionRange("+txtarea+", "+start+", "+end+")");

//$(txtarea).focus();
if (typeof(txtarea.createTextRange) !== 'undefined' && !$.browser.opera) {
Expand All @@ -471,7 +471,7 @@ RawEngine.prototype.setSelectionRange = function(start, end) {
RawEngine.prototype.setCaretPosition = function(caretPos) {
var self = this;

//self.log("NATEDIT: setCaretPosition("+caretPos+")");
//self.shell.log("setCaretPosition("+caretPos+")");
self.setSelectionRange(caretPos, caretPos);
};

Expand Down Expand Up @@ -618,7 +618,7 @@ RawEngine.prototype.insertLineTag = function(markup) {
nrSpaces = 0,
txtarea = self.shell.txtarea;

//self.log("called insertLineTag(..., ",markup,")");
//self.shell.log("called insertLineTag(..., ",markup,")");

theSelection = self.getSelectionLines();
startPos = txtarea.selectionStart;
Expand Down Expand Up @@ -673,7 +673,7 @@ RawEngine.prototype.insertLineTag = function(markup) {
endPos = nrSpaces + startPos + modifiedSelection.length + 1;
}

//self.log("finally, startPos="+startPos+" endPos="+endPos);
//self.shell.log("finally, startPos="+startPos+" endPos="+endPos);

self.setSelectionRange(startPos, endPos);
txtarea.scrollTop = scrollTop;
Expand All @@ -693,7 +693,7 @@ RawEngine.prototype.insertTag = function(markup) {
text, scrollTop, theSelection,
subst, txtarea = self.shell.txtarea;

//self.log("called insertTag("+tagOpen+", "+sampleText+", "+tagClose+")");
//self.shell.log("called insertTag("+tagOpen+", "+sampleText+", "+tagClose+")");

self.getSelectionRange();
startPos = txtarea.selectionStart;
Expand All @@ -702,7 +702,7 @@ RawEngine.prototype.insertTag = function(markup) {
scrollTop = txtarea.scrollTop;
theSelection = text.substring(startPos, endPos) || sampleText;

//self.log("startPos="+startPos+" endPos="+endPos);
//self.shell.log("startPos="+startPos+" endPos="+endPos);

subst = tagOpen + theSelection.replace(/(\s*)$/, tagClose + "$1");

Expand Down Expand Up @@ -749,10 +749,10 @@ RawEngine.prototype.searchReplace = function(search, replace, ignoreCase) {
pos = copy.indexOf(search, pos + replace.length);
}

//self.log("NATEDIT: result=",text);
//self.shell.log("result=",text);
if (count) {
txtarea.value = text;
//self.log("caretPos=",caretPos,"scrollTop=",scrollTop);
//self.shell.log("caretPos=",caretPos,"scrollTop=",scrollTop);
self.setCaretPosition(caretPos);
txtarea.scrollTop = scrollTop;

Expand Down
Expand Up @@ -112,7 +112,7 @@ RawEngine.prototype.getSelectionRange = function() {
var self = this, text, c, range, rangeCopy, pos, selection,
txtarea = self.shell.txtarea;

//self.log("NATEDIT: called getSelectionRange()");
//self.shell.log("called getSelectionRange()");
//$(txtarea).focus();

if (self.oldIE) {
Expand Down Expand Up @@ -180,7 +180,7 @@ RawEngine.prototype.getSelectionLines = function() {
end++;
}

//self.log("start=",start,"end=",end);
//self.shell.log("start=",start,"end=",end);

self.setSelectionRange(start, end);

Expand All @@ -194,7 +194,7 @@ RawEngine.prototype.setSelectionRange = function(start, end) {
var self = this, lineFeeds, range,
txtarea = self.shell.txtarea;

//self.log("setSelectionRange("+txtarea+", "+start+", "+end+")");
//self.shell.log("setSelectionRange("+txtarea+", "+start+", "+end+")");

//$(txtarea).focus();
if (typeof(txtarea.createTextRange) !== 'undefined' && !$.browser.opera) {
Expand All @@ -217,7 +217,7 @@ RawEngine.prototype.setSelectionRange = function(start, end) {
RawEngine.prototype.setCaretPosition = function(caretPos) {
var self = this;

//self.log("NATEDIT: setCaretPosition("+caretPos+")");
//self.shell.log("setCaretPosition("+caretPos+")");
self.setSelectionRange(caretPos, caretPos);
};

Expand Down Expand Up @@ -364,7 +364,7 @@ RawEngine.prototype.insertLineTag = function(markup) {
nrSpaces = 0,
txtarea = self.shell.txtarea;

//self.log("called insertLineTag(..., ",markup,")");
//self.shell.log("called insertLineTag(..., ",markup,")");

theSelection = self.getSelectionLines();
startPos = txtarea.selectionStart;
Expand Down Expand Up @@ -419,7 +419,7 @@ RawEngine.prototype.insertLineTag = function(markup) {
endPos = nrSpaces + startPos + modifiedSelection.length + 1;
}

//self.log("finally, startPos="+startPos+" endPos="+endPos);
//self.shell.log("finally, startPos="+startPos+" endPos="+endPos);

self.setSelectionRange(startPos, endPos);
txtarea.scrollTop = scrollTop;
Expand All @@ -439,7 +439,7 @@ RawEngine.prototype.insertTag = function(markup) {
text, scrollTop, theSelection,
subst, txtarea = self.shell.txtarea;

//self.log("called insertTag("+tagOpen+", "+sampleText+", "+tagClose+")");
//self.shell.log("called insertTag("+tagOpen+", "+sampleText+", "+tagClose+")");

self.getSelectionRange();
startPos = txtarea.selectionStart;
Expand All @@ -448,7 +448,7 @@ RawEngine.prototype.insertTag = function(markup) {
scrollTop = txtarea.scrollTop;
theSelection = text.substring(startPos, endPos) || sampleText;

//self.log("startPos="+startPos+" endPos="+endPos);
//self.shell.log("startPos="+startPos+" endPos="+endPos);

subst = tagOpen + theSelection.replace(/(\s*)$/, tagClose + "$1");

Expand Down Expand Up @@ -495,10 +495,10 @@ RawEngine.prototype.searchReplace = function(search, replace, ignoreCase) {
pos = copy.indexOf(search, pos + replace.length);
}

//self.log("NATEDIT: result=",text);
//self.shell.log("result=",text);
if (count) {
txtarea.value = text;
//self.log("caretPos=",caretPos,"scrollTop=",scrollTop);
//self.shell.log("caretPos=",caretPos,"scrollTop=",scrollTop);
self.setCaretPosition(caretPos);
txtarea.scrollTop = scrollTop;

Expand Down
Expand Up @@ -55,7 +55,7 @@ TinyMCEEngine.prototype.init = function() {

self.opts.tinymce.init_instance_callback = function(editor) {

//self.log("tinymce instance", editor);
//self.shell.log("tinymce instance", editor);

self.editor = editor;

Expand Down Expand Up @@ -274,7 +274,7 @@ TinyMCEEngine.prototype.html2tml = function(html) {
var /*self = this,*/
url = foswiki.getScriptUrl("rest", "WysiwygPlugin", "html2tml");

//self.log("called html2tml", tml);
//self.shell.log("called html2tml", tml);

return $.post(url, {
topic: foswiki.getPreference("WEB")+"."+foswiki.getPreference("TOPIC"),
Expand Down Expand Up @@ -334,7 +334,7 @@ TinyMCEEngine.prototype.getSelectionLines = function() {
end = text.length - 1;
}

//console.log("start=",start,"end=",end,"range=",range,"text=",text,"len=",text.length);
//self.shell.log("start=",start,"end=",end,"range=",range,"text=",text,"len=",text.length);

range.setStart(node, start);
//range.setEnd(node, end);
Expand Down Expand Up @@ -395,7 +395,7 @@ TinyMCEEngine.prototype.insertLineTag = function(markup) {
selection = self.getSelectionLines() || markup[1],
tagClose = markup[2];

self.log("selection=",selection);
self.shell.log("selection=",selection);

self.editor.selection.setContent(tagOpen+selection+tagClose);
};
Expand Down

0 comments on commit 476b859

Please sign in to comment.