Created
November 7, 2014 19:36
-
-
Save morganrallen/e4f89e7678141c90454f to your computer and use it in GitHub Desktop.
Thrust window destruction on display change
This file contains hidden or 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> | |
webview { | |
height: 100%; | |
width: 100%; | |
} | |
webview.nofx { | |
} | |
webview.active { | |
display: block; | |
} | |
</style> | |
</head> | |
<body> | |
<script> | |
window.onload = function() { | |
var webview = document.createElement("webview"); | |
document.body.appendChild(webview); | |
webview.src = "http://www.google.com"; | |
webview.classList.add("nofx"); | |
webview.classList.add("active"); | |
} | |
</script> | |
</body> | |
</html> |
This file contains hidden or 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
"use strict"; | |
var async = require("async"); | |
var common = require("../lib/common.js"); | |
var api = null; | |
var window = null; | |
var fs = require("fs"); | |
var http = require("http"); | |
var port = 21024; | |
async.series([ | |
function(cb) { | |
var server = http.createServer(function(req, res) { | |
if(req.url === "/") { | |
req.url = "/close.html"; | |
} | |
req.url = "." + req.url; | |
console.log("attempting to load %s", req.url); | |
fs.createReadStream(req.url).pipe(res); | |
}); | |
server.listen(port, "127.0.0.1", function() { | |
console.log("listening on %s", port); | |
cb(null); | |
}); | |
}, | |
function(cb_) { | |
require("./base.js")(function(err, a) { | |
api = a; | |
return cb_(err); | |
}); | |
}, | |
function(cb_) { | |
window = api.window({ | |
root_url: "http://127.0.0.1:" + port, | |
size: { | |
width: 1024, | |
height: 768 | |
} | |
}); | |
return cb_(); | |
}, | |
function(cb_) { | |
window.show(cb_); | |
} | |
], function(err) { | |
if(err) { | |
common.log.out("FAILED"); | |
common.log.error(err); | |
} | |
common.log.out("OK"); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment