cursor.js : make the console a little less noisy
This commit is contained in:
@@ -5,6 +5,14 @@ define([
|
|||||||
// do some function for the start and end of the cursor
|
// do some function for the start and end of the cursor
|
||||||
var startAndStop = function (f) { ['start', 'end'].forEach(f); };
|
var startAndStop = function (f) { ['start', 'end'].forEach(f); };
|
||||||
|
|
||||||
|
var log = function (x) {
|
||||||
|
console.log(x);
|
||||||
|
};
|
||||||
|
|
||||||
|
var error = function (x) {
|
||||||
|
console.log(x);
|
||||||
|
};
|
||||||
|
|
||||||
return function (CK, editor, inner) {
|
return function (CK, editor, inner) {
|
||||||
var makeCKElement = function (el) { return new CK.dom.node(el); };
|
var makeCKElement = function (el) { return new CK.dom.node(el); };
|
||||||
|
|
||||||
@@ -27,12 +35,13 @@ define([
|
|||||||
};
|
};
|
||||||
|
|
||||||
cursor.update = function () {
|
cursor.update = function () {
|
||||||
console.log("Updating cursor position");
|
log("Updating cursor position");
|
||||||
// get ranges
|
// get ranges
|
||||||
var ranges = editor.getSelection().getRanges();
|
var ranges = editor.getSelection().getRanges();
|
||||||
// there should be at least one
|
// there should be at least one
|
||||||
if (!ranges.length) {
|
if (!ranges.length) {
|
||||||
console.error("No ranges");
|
// FIXME make error
|
||||||
|
log("No ranges");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,7 +79,7 @@ define([
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (success) {
|
if (success) {
|
||||||
console.log("Found cursor!");
|
log("Found cursor!");
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
};
|
};
|
||||||
@@ -90,7 +99,7 @@ define([
|
|||||||
// TODO under what circumstances will the length of getRanges be zero?
|
// TODO under what circumstances will the length of getRanges be zero?
|
||||||
var range;
|
var range;
|
||||||
cursor.replace = function () {
|
cursor.replace = function () {
|
||||||
console.log("Attempting to replace cursor");
|
log("Attempting to replace cursor");
|
||||||
|
|
||||||
cursor.find();
|
cursor.find();
|
||||||
|
|
||||||
@@ -113,7 +122,7 @@ define([
|
|||||||
|
|
||||||
var ranges = sel.getRanges();
|
var ranges = sel.getRanges();
|
||||||
if (!ranges.length) {
|
if (!ranges.length) {
|
||||||
console.log("No cursor range found");
|
log("No cursor range found");
|
||||||
if (!range) {
|
if (!range) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -128,15 +137,16 @@ define([
|
|||||||
|
|
||||||
var seekToOffset = function (el, offset) {
|
var seekToOffset = function (el, offset) {
|
||||||
if (!el) {
|
if (!el) {
|
||||||
console.log("No element provided!");
|
log("No element provided!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
console.log("Seeking to offset");
|
log("Seeking to offset");
|
||||||
console.log(el, offset);
|
// FIXME better debugging
|
||||||
|
// console.log(el, offset);
|
||||||
if (!el.textContent) {
|
if (!el.textContent) {
|
||||||
// FIXME wat
|
// FIXME wat
|
||||||
var el2 = Tree.previousNode(el, inner);
|
var el2 = Tree.previousNode(el, inner);
|
||||||
console.log("No text content available!");
|
log("No text content available!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (offset === 0) {
|
if (offset === 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user