Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 617c293a89
Fetching contributors…

Cannot retrieve contributors at this time

157 lines (141 sloc) 3.925 kb
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<title>microwriter</title>
<meta name="author" content="automata">
<meta name="description" content="microwriter clone, more at http://www.loper-os.org/?p=861" />
<!-- we have to include jquery and meemoo -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script src="http://meemoo.org/meemoo/v1/meemoo-min.js"></script>
<!-- include your style too -->
<style type="text/css">
body {
color: white;
background-color: #003;
margin: 0px
}
#horizon {
text-align: center;
position: absolute;
top: 50%;
left: 0px;
width: 100%;
height: 1px;
overflow: visible;
visibility: visible;
display: block
}
#content {
font-family: Verdana, Geneva, Arial, sans-serif;
margin-left: -50px;
position: absolute;
top: -80px;
left: 50%;
width: 100px;
height: 100px;
visibility: visible
}
.headline {
font-weight: bold;
font-size: 100px;
}
</style>
</head>
<body>
<div id="horizon">
<div id="content">
<span id="display" class="headline"></span>
</div>
</div>
<script type="text/javascript">
// [109 -] [61 =]
// [79 0] [220 \]
//
//
// [0 META]
// conf the ASCII keys here, for now -^
var keys = {0: 0,
79: 1,
109: 2,
61: 3,
220: 4};
var keys_to_alpha = function (pressed_keys) {
var pattern = [0,0,0,0,0];
for (var i=0; i<pressed_keys.length; i++) {
pattern[keys[pressed_keys[i]]] = 1;
}
return patterns[pattern.toString()];
};
// add more patterns here...
var patterns = {"0,1,1,0,0": "a",
"0,0,1,1,1": "b",
"1,0,1,0,0": "c",
"1,1,1,0,0": "d",
"0,1,0,0,0": "e",
"1,1,1,1,0": "f",
"0,0,0,1,1": "g",
"1,0,0,0,1": "h",
"1,1,0,0,0": "i",
"1,0,0,1,1": "j",
"1,0,0,1,0": "k",
"1,1,0,0,1": "l",
"0,1,1,1,1": "m",
"0,0,1,1,0": "n",
"0,0,1,0,0": "o",
"1,1,1,1,1": "p",
"0,0,1,0,1": "q",
"1,1,0,1,0": "r",
"0,0,0,1,0": "s",
"0,1,0,1,0": "t",
"0,0,0,0,1": "u",
"0,1,0,0,1": "v",
"1,1,0,1,1": "w",
"1,0,1,1,1": "x",
"1,0,1,1,0": "y",
"1,0,1,0,1": "z"};
var is_in = function (a, array) {
for (var i=0; i<array.length; i++) {
if (a === array[i]) {
return true;
}
}
return false;
};
var keysPressed = [];
var keysUpped = [];
var keyDown = 0;
var keyUp = 0;
document.onkeyup = function (evt) {
keyUp++;
if (!is_in(evt.keyCode, keysUpped)) {
keysUpped.push(evt.keyCode);
}
if (keyDown === keyUp) {
var alpha = keys_to_alpha(keysUpped);
$("#display").text(alpha);
Meemoo.send("out", alpha);
keysPressed = [];
keysUpped = [];
}
};
document.onkeydown = function (evt) {
// push to a stack of pressed keys, just when not a repeated key
if (!is_in(evt.keyCode, keysPressed)) {
keysPressed.push(evt.keyCode);
// count how many unrepeated keys were pressed
keyDown++;
}
};
Meemoo.setInfo({
title: "microwriter",
author: "automata",
description: "microwriter clone, more at http://www.loper-os.org/?p=861"
}).addOutputs({
out: {
type: "string"
}
});
</script>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.