Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
138 lines (124 sloc) 3.67 KB
<!DOCTYPE HTML>
<html lang="en">
<!--
This app is meant as means of demonstration and is thus
kind of messy at first sight.
You can simply replace this whole file with something own if you like.
-->
<head>
<meta charset="utf-8">
<title>The window title</title>
<style type="text/css" media="screen">
#response {
font-family:monospace;
font-size:10px;
white-space:pre;
border:1px solid #888;
overflow:auto;
background:white;
padding:2px;
position:absolute;
bottom:20px;
left:20px;
top:150px;
right:20px;
}
#url {
width:200px;
}
</style>
<script src="jquery.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
function demo_animation() {
var originalFrame = Win.frame;
console.log(originalFrame);
$('button').get(0).disabled = true;
var sequence = [null,
// Move window
function(){ Win.setFrame({origin:{x:100, y:200}, size:originalFrame.size, animate:true}) },
function(){ Win.setFrame({origin:{x:150, y:250}, size:{width:600, height:200}, animate:true}) },
function(){ Win.frame = originalFrame }, // property syntax also OK
// Toggle shadow
function(){ Win.shadow = false },
function(){ Win.shadow = true },
// Remove the toolbar
//function(){ Win.setToolbar(null) },
// Toggle minimized
function(){ Win.miniaturize() },
function(){ Win.deminiaturize() },
function(){ $('button').get(0).disabled = false; }
];
for (var i in sequence) {
i = parseInt(i);
setTimeout(sequence[i], 1000*i);
}
// App.terminate();
}
function demo_get_remote(url) {
$('#response').text("");
$.get(url, function(data){
$('#response').text(data);
});
}
// Register a handler for opening files
App.onOpenFiles = function() {
console.log("openFiles: " + arguments + ", arguments.length = "+arguments.length);
for (var i=0; i<arguments.length; i++)
console.log(" file "+i+": "+arguments[i]);
}
$(function(){
// Some basic properties
console.log(App);
console.log(App.version);
console.log(Win);
// User defaults
console.log(App.defaults);
console.log(App.defaults.someKey()); // get someKey
console.log(App.defaults.stringForKey('someKey')); // get someKey
App.defaults.someKey('hej'); // set someKey
console.log(App.defaults.someKey()); // get someKey
console.log(App.defaults.stringForKey('someKey')); // get someKey
App.defaults.removeObjectForKey('someKey'); // remove someKey
// Fetch a remote website
/*$.get("http://hunch.se/", function(data){
console.log("Data Loaded: " + data);
});*/
// events from NSApplication
document.addEventListener("applicationWillBecomeActive", function(ev){
console.log("app is becoming active");
}, false);
document.addEventListener("applicationWillResignActive", function(ev){
console.log("app resigns active");
}, false);
// Run a few animated demonstrations
//demo_animation();
// Misc stuff
//App.window.close();
//App.window.setTitle($('title').text());
//App.terminate();
});
</script>
</head>
<body>
<section>
<p>
Hello. I'm text and I'm happy.
</p>
<p>
<button onclick="demo_animation()">Run animated demo</button>
<button onclick="Win.fullscreen=(Win.fullscreen ? false : true)">Toggle fullscreen</button>
</p>
<hr>
<p>
<input type="text" id="url" value="http://hunch.se/">
<button onclick="demo_get_remote($('#url').get(0).value)">Fetch remote content</button>
</p>
<p>
<div id="response"></div>
</p>
</section>
<footer>
<address></address>
</footer>
</body>
</html>