0
0
mirror of https://github.com/Doodle3D/doodle3d-client.git synced 2024-11-06 03:53:23 +01:00

Silliness.

This commit is contained in:
Wouter R 2014-01-15 20:16:46 +01:00
parent e8c9932014
commit c697806385
2 changed files with 49 additions and 15 deletions

View File

@ -1,10 +1,21 @@
var keyboardShortcutsEnabled = true;
var wordBuffer = "";
var wordFuncs = {
"idbeholdl": function() {
alert("Light!");
},
"idspispopd": function() {
drawTextOnCanvas("Im in ur kanvas drawin' ur stuffz.");
}
};
function initKeyboard() {
$(document).keypress(function(event) {
if (!keyboardShortcutsEnabled) return;
if (event.ctrlKey && event.altKey && ! event.metaKey) processWords(event);
if (event.altKey || event.ctrlKey || event.metaKey) return; //ignore key presses with modifier keys except shift
var ch = String.fromCharCode(event.which);
@ -41,3 +52,23 @@ function initKeyboard() {
})
}
function processWords(e) {
wordBuffer += String.fromCharCode(e.which);
var match = false;
for (var k in wordFuncs) {
if (k.indexOf(wordBuffer) == 0) {
if (k.length == wordBuffer.length) match = wordFuncs[k];
else match = true;
break;
}
}
if (typeof(match) == 'function') {
match();
wordBuffer = "";
} else if (!match) {
wordBuffer = "";
}
}

View File

@ -22,9 +22,12 @@ function onWordArtOk() {
hidePopup(popupWordArt);
var s = $("#txtWordArt").val();
drawTextOnCanvas(s);
}
if (s!=undefined) {
var points = getStringAsPoints(s);
function drawTextOnCanvas(text) {
if (typeof(text) == 'string') {
var points = getStringAsPoints(text);
var bounds = getBounds(points);
var scaleX = (canvasWidth-50) / bounds.width;