add old experiments

This commit is contained in:
Fabian Jakobs 2011-01-17 08:45:15 +01:00
commit 55313882c9
3 changed files with 184 additions and 0 deletions

45
experiments/capture.html Normal file
View file

@ -0,0 +1,45 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="author" content="Fabian Jakobs">
<!-- Date: 2010-04-07 -->
<style type="text/css" media="screen">
#juhu {
width: 100px;
height: 50px;
background: yellow;
}
</style>
</head>
<body>
<div id="juhu">
</div>
<script src="../src/ace.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
var el = document.getElementById("juhu");
ace.addListener(el, "mousedown", function(e) {
el.innerHTML = ace.getDocumentX(e) + " " + ace.getDocumentY(e);
ace.capture(
el,
function(e) {
el.innerHTML = ace.getDocumentX(e) + " " + ace.getDocumentY(e);
}, function() {
el.innerHTML = "";
}
);
});
</script>
</body>
</html>

105
experiments/cut_copy.html Normal file
View file

@ -0,0 +1,105 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Text Events</title>
<meta name="author" content="Fabian Jakobs">
<style type="text/css" media="screen">
#container {
border: 1px solid black;
width: 600px;
}
#canvas {
border: 1px solid black;
margin: 4px;
width: 590px;
height: 400px;
}
</style>
</head>
<body>
<div id="container">
<textarea id="text"></textarea>
<div id="canvas"></div>
</div>
<input type="button" value="Clear" id="some_name" onclick="document.getElementById('logger').innerHTML = ''">
<div id="logger">
</div>
<script type="text/javascript" charset="utf-8">
if (!window.console) window.console = {};
if (!console.log) {
var logger = document.getElementById("logger");
console.log = function() {
logger.innerHTML += Array.prototype.join.call(arguments, ", ") + "<br>";
}
}
function addListener(elem, type, callback) {
if (elem.addEventListener) {
return elem.addEventListener(type, callback, false);
}
if (elem.attachEvent) {
elem.attachEvent("on" + type, function() {
callback(window.event);
});
}
}
var container = document.getElementById("container");
var canvas = document.getElementById("canvas");
var text = document.getElementById("text");
function log(e) {
console.log(e.type, e);
}
function logKey(e) {
console.log(e.type, e.charCode, e.keyCode, e);
}
addListener(text, "keydown", logKey, false);
addListener(text, "keyup", logKey, false);
addListener(text, "keypress", logKey, false);
addListener(text, "textInput", function(e) {
console.log(e.type, e.data, e);
}, false);
function fillSelection() {
text.value = "Juhu Kinners";
text.select();
}
addListener(text, "copy", fillSelection, false);
addListener(text, "paste", log, false);
addListener(text, "cut", fillSelection, false);
addListener(text, "beforecopy", log, false);
addListener(text, "beforepaste", log, false);
addListener(text, "beforecut", log, false);
addListener(text, "compositionstart", log, false);
addListener(text, "compositionupdate", log, false);
addListener(text, "compositionend", log, false);
addListener(text, "propertychange", function(e) {
console.log(e.type, e.propertyName, e);
}, false);
</script>
</body>
</html>

View file

@ -0,0 +1,34 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>triple_click</title>
<meta name="author" content="Fabian Jakobs">
</head>
<body>
<div id="juhu">
Juhu Kinners
</div>
<script src="../src/ace/lib/core.js" type="text/javascript" charset="utf-8"></script>
<script src="../src/ace/lib/event.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
var el = document.getElementById("juhu");
ace.addTripleClickListener(el, function() {
console.log("triple");
});
ace.addListener(el, "selectstart", function(e) {
return ace.preventDefault(e);
});
</script>
</body>
</html>