Created
March 17, 2015 18:35
-
-
Save akagomez/47e7bbac3ecf53dd5e8e to your computer and use it in GitHub Desktop.
Clickable tiles in node-webkit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<style type="text/css"> | |
body { margin: 0; padding: 0; } | |
div { float: left; background: #f00; } | |
</style> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
var gui = require('nw.gui'); | |
process.on('uncaughtException', function(err) { | |
return false; | |
}); | |
gui.Window.get().showDevTools(); | |
var win = window.win = gui.Window.get(window); | |
win.on('focus', function () { | |
console.log('The window is focused.'); | |
}) | |
var w = win.width; | |
var h = win.height; | |
var d = 10; | |
var cw = w / d; | |
var ch = h / d; | |
for (var r = 0; r < d; r++) { | |
for (var c = 0; c < d; c++) { | |
var div = document.createElement('div'); | |
div.style.width = cw + 'px'; | |
div.style.height = ch + 'px'; | |
div.id = r + 'x' + c; | |
div.onclick = function () { | |
this.style.backgroundColor = 'transparent'; | |
} | |
document.getElementsByTagName('body')[0].appendChild(div); | |
} | |
} | |
</script> | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is the test used for this issue: nwjs/nw.js#3255