summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatthewsotoudeh <matthewsot@outlook.com>2017-02-04 21:28:31 -0800
committermatthewsotoudeh <matthewsot@outlook.com>2017-02-04 21:28:31 -0800
commitd7f6e45c6574b3974b8d63396622528b07ef4ed2 (patch)
treea65d69cb2e9cc257dd4600c22efe8125096bad55
parent1c3bd31565bd1d6a42015eb5f16a6c0885a5468a (diff)
updated to use docs-plus
-rw-r--r--.speechless.js.swp0
-rw-r--r--docs.js24
-rw-r--r--speechless.js4
-rw-r--r--utils.js13
4 files changed, 18 insertions, 23 deletions
diff --git a/.speechless.js.swp b/.speechless.js.swp
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/.speechless.js.swp
diff --git a/docs.js b/docs.js
index 72c6a46..be19ca6 100644
--- a/docs.js
+++ b/docs.js
@@ -40,7 +40,7 @@ docs.getSelectionWithObserver = function (callback, defaultToParagraph, getRaw)
return;
}
- utils.observe($(".docs-texteventtarget-iframe").contents().find("[contenteditable=\"true\"]")[0], {
+ docs.utils.observe($(".docs-texteventtarget-iframe").contents().find("[contenteditable=\"true\"]")[0], {
childList: true
}, function(mutations) {
callback(getRaw ? mutations[0].target : $(mutations[0].target).text().trim());
@@ -59,7 +59,7 @@ docs.runWithCreateKeyboard = function (strToRun, funcName, params) {
toRun += funcName + '(' + params + ')';
- utils.runInPage(toRun.replace(/\r?\n|\r/g, " "));
+ docs.utils.runInPage(toRun.replace(/\r?\n|\r/g, " "));
};
docs.insertText = function (toInsert) {
@@ -75,7 +75,7 @@ docs.insertText = function (toInsert) {
key = specials[key];
}
- var e = utils.createKeyboardEvent("keypress", {
+ var e = docs.utils.createKeyboardEvent("keypress", {
"key": key,
"charCode": toInsert.charCodeAt(i),
"keyCode": null,
@@ -103,7 +103,7 @@ docs.backspace = function (counts) {
var keyboardType = "keypress";
if (navigator.vendor.toLowerCase().indexOf("google") !== -1) { keyboardType = "keydown"; }
- var e = utils.createKeyboardEvent(keyboardType, {
+ var e = docs.utils.createKeyboardEvent(keyboardType, {
"key": "Backspace",
"charCode": 8,
"keyCode": 8,
@@ -138,7 +138,7 @@ docs.backspace = function (counts) {
toRun += 'doBackspace(' + counts + ')';
setTimeout(function () {
- utils.runInPage(toRun.replace(/\r?\n|\r/g, " "));
+ docs.utils.runInPage(toRun.replace(/\r?\n|\r/g, " "));
}, (secondsTimeout * 1000));
return;
};
@@ -185,14 +185,14 @@ docs.toggleSubscript = function () {
"ctrlKey": true
};
- var ctrlDown = utils.createKeyboardEvent("keydown", ctrl);
+ var ctrlDown = docs.utils.createKeyboardEvent("keydown", ctrl);
- var commaDown = utils.createKeyboardEvent("keydown", comma);
- var commaUp = utils.createKeyboardEvent("keyup", comma);
- var commaPress = utils.createKeyboardEvent("keypress", comma);
+ var commaDown = docs.utils.createKeyboardEvent("keydown", comma);
+ var commaUp = docs.utils.createKeyboardEvent("keyup", comma);
+ var commaPress = docs.utils.createKeyboardEvent("keypress", comma);
- var ctrlUp = utils.createKeyboardEvent("keydown", ctrl);
- var ctrlPress = utils.createKeyboardEvent("keypress", ctrl);
+ var ctrlUp = docs.utils.createKeyboardEvent("keydown", ctrl);
+ var ctrlPress = docs.utils.createKeyboardEvent("keypress", ctrl);
var el = document.getElementsByClassName("docs-texteventtarget-iframe")[0].contentWindow.document.querySelector("[contenteditable=\"true\"]");
el.dispatchEvent(ctrlDown);
@@ -215,7 +215,7 @@ docs.getCurrentParagraphText = function(callback) {
//Set up an observer to observe all the paragraphs
var calledAlready = false;
- var observer = utils.observe($(".kix-paginateddocumentplugin")[0], {
+ var observer = docs.utils.observe($(".kix-paginateddocumentplugin")[0], {
childList: true,
subtree: true
}, function(mutations) {
diff --git a/speechless.js b/speechless.js
index d0893d0..34a0667 100644
--- a/speechless.js
+++ b/speechless.js
@@ -34,6 +34,6 @@ $("body").on("mouseup", ".kix-appview-editor", function (e) {
});
$(".docs-texteventtarget-iframe").contents().find("[contenteditable=\"true\"]").keydown(function (e) {
- if (e.keyCode !== 65 || e.ctrlKey != true) return;
+ if ((e.keyCode !== 65 || e.ctrlKey != true) && e.shiftKey != true) return;
setTimeout(refresh, 100);
-}); \ No newline at end of file
+});
diff --git a/utils.js b/utils.js
index 9372b71..2d4d913 100644
--- a/utils.js
+++ b/utils.js
@@ -23,12 +23,7 @@ docs.utils.observe = function (el, config, callback, observeOnce) {
return observer;
};
-utils.stopEvent = function (e) {
- utils.recipe(e, ["preventDefault", "stopPropagation"]);
-};
-
-
-utils.keyFromKeyCode = function (shifted, keyCode) {
+docs.utils.keyFromKeyCode = function (shifted, keyCode) {
var specialKeys = { 191: "/", 27: "Escape", 16: "Shift", 17: "Control", 18: "Alt", 8: "Backspace", 32: " ", 13: "Enter", 9: "Tab", 37: "ArrowLeft", 38: "ArrowUp", 39: "ArrowRight", 40: "ArrowDown" };
var shiftedSpecialKeys = { 191: "?" };
if (typeof specialKeys[keyCode] !== "undefined") {
@@ -50,7 +45,7 @@ utils.keyFromKeyCode = function (shifted, keyCode) {
}
};
-utils.createKeyboardEvent = function (type, info) {
+docs.utils.createKeyboardEvent = function (type, info) {
var e = new KeyboardEvent(type, info);
if(e.keyCode == 0) {
/* http://jsbin.com/awenaq/3/edit?js,output */
@@ -69,7 +64,7 @@ utils.createKeyboardEvent = function (type, info) {
return e;
}
-utils.runInPage = function (script) {
+docs.utils.runInPage = function (script) {
if (actionPluginPlatform === "firefox") {
var th = document.body;
var s = document.createElement('script');
@@ -82,7 +77,7 @@ utils.runInPage = function (script) {
};
//Thanks! https://stackoverflow.com/questions/1740700/how-to-get-hex-color-value-rather-than-rgb-value
-utils.rgb2hex = function(rgb) {
+docs.utils.rgb2hex = function(rgb) {
if (/^#[0-9A-F]{6}$/i.test(rgb)) return rgb;
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback