Skip to content

Commit

Permalink
phantomjs script
Browse files Browse the repository at this point in the history
  • Loading branch information
ondras committed Jan 29, 2014
1 parent 43474a2 commit 253dabe
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions bin/phantomjs-my-mind.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,29 @@ var page = require("webpage").create();
page.onAlert = function(msg) { console.log(msg); }
page.open(url, function() {
page.evaluate(function(dataSource, data) {
document.querySelector("link[media~=print]").media = "all"; /* switch to print mode */
/* switch to print mode */
document.querySelector("link[media~=print]").media = "all";

/* auto-size the viewport */
var port = document.querySelector("#port");
port.style.width = port.style.height = "";

/* inject special css to fix the missing font issue */
var style = document.createElement("style");
var css = document.createTextNode(".status { font-family: dejavu sans, source sans pro, sans-serif; }");
style.appendChild(css);
document.body.appendChild(style);

var format = MM.Format.getByName(dataSource);
var json = format.from(data);
var map = MM.Map.fromJSON(json);
MM.App.setMap(map);
/* load the map, if necessary */
if (dataSource) {
var format = MM.Format.getByName(dataSource);
var json = format.from(data);
var map = MM.Map.fromJSON(json);
MM.App.setMap(map);
}

document.body.offsetWidth; /* to force reflow/repaint */
/* force reflow/repaint */
document.body.offsetWidth;
}, dataSource, data);

page.render(output);
Expand Down

0 comments on commit 253dabe

Please sign in to comment.