W key opens the game in a bare popup

This commit is contained in:
Eric Fredricksen
2021-12-15 00:32:01 -08:00
parent efc5475d36
commit 0e5fe905f2
3 changed files with 75 additions and 1 deletions
+19
View File
@@ -60,6 +60,25 @@ div.progress-container:hover div.hint {
width: 686px;
}
body.bare #main.window {
position: fixed;
left: 0;
top: 0;
}
/*
This is goood to get rid of in chrome, but other browsers don't have a sensible
title bar (on Mac at least)
*/
body.bare #titlebar {
display: none;
}
_::-webkit-full-page-media, _:future, :root body.bare #titlebar {
display: block;
}
#Trats,
#Plots, #Plots table,
#Quests, #Quests table {
+52 -1
View File
@@ -990,8 +990,39 @@ function FormCreate() {
var name = unescape(window.location.href.split('#')[1]);
storage.loadSheet(name, LoadGame);
if (window.opener) {
// Opened as a popup, so go bare style
prepPopup();
}
}
function prepPopup() {
document.body.classList.add("bare");
window.resizeBy($("#main")[0].offsetWidth - window.innerWidth,
$("#main")[0].offsetHeight - window.innerHeight);
let titlebar = $("#titlebar");
let delta;
titlebar.on("mousedown", e => {
delta = {
x: e.pageX,
y: e.pageY
};
console.log(delta);
});
$("html").on("mouseup", e => { delta = null; });
$("html").on("mousemove", e => {
if (!e.which) delta = null;
if (delta) {
window.moveBy(e.pageX - delta.x,
e.pageY - delta.y);
}
});
}
function pause(msec) {
@@ -1004,7 +1035,13 @@ function pause(msec) {
function quit() {
$(window).unbind('unload');
SaveGame(function () { window.location.href = "roster.html"; });
SaveGame(() => {
if (window.opener) {
window.close();
} else {
window.location.href = "roster.html";
}
});
}
@@ -1163,6 +1200,20 @@ function FormKeyDown(e) {
alert('Saved (' + JSON.stringify(game).length + ' bytes).');
}
if (key === 'w') {
if (window.opener) return;
$(window).unbind('unload'); // we're about to save it anyway
SaveGame(() => {
let ext = window.open(window.location.href, "Progress Quest",
`resizable,width=${$("#main")[0].offsetWidth},height=${$("#main")[0].offsetHeight},popup,location=0`);
console.log(ext);
if(ext && !ext.closed && typeof ext.closed !== 'undefined') {
// popup was apparently not blocked
window.location.href = "roster.html"; // this window can go back to the roster
}
});
}
/*
if (key === 't') {
TaskBar.reposition(TaskBar.Max());
+4
View File
@@ -112,6 +112,10 @@ body {
margin-top: 1em;
}
body.bare {
background: silver;
}
div.scroll {
overflow: scroll;
height: 100px;