150 lines
4.1 KiB
HTML
150 lines
4.1 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>Frames Browser (WIP)</title>
|
||
<style>
|
||
:root {
|
||
--BtnHeight: 2em;
|
||
--BtnActionHeight: 3em;
|
||
}
|
||
* {
|
||
box-sizing: border-box;
|
||
}
|
||
body {
|
||
margin: 0px;
|
||
overflow: hidden;
|
||
max-width: 100vw;
|
||
max-height: 100vh;
|
||
}
|
||
button {
|
||
height: var(--BtnHeight);
|
||
}
|
||
iframe {
|
||
border: none;
|
||
width: 100vw;
|
||
height: calc(100vh - var(--BtnActionHeight));
|
||
position: relative;
|
||
}
|
||
#BoxControls table, #BoxControls table td, #BoxControls table td > * {
|
||
height: var(--BtnActionHeight);
|
||
min-width: var(--BtnActionHeight);
|
||
border-spacing: 0;
|
||
}
|
||
.BoxPopup {
|
||
position: absolute;
|
||
top: 0;
|
||
left: 0;
|
||
right: 0;
|
||
}
|
||
</style>
|
||
<script>
|
||
var FrameZoomLevels = [50, 200];
|
||
var AppInfoString = `
|
||
Frames Browser v2023-09-21.3 (WIP).
|
||
`.trim();
|
||
</script>
|
||
</head>
|
||
<body>
|
||
<div id="BoxControls"><table><tr>
|
||
<td><button onclick="ShowAppInfo()">ℹ️ Info</button></td>
|
||
<td>
|
||
<button onclick="this.nextElementSibling.click()">📄 File</button>
|
||
<input type="file" hidden="hidden" style="display: none;" onchange="LoadFile(this.files[0])"/>
|
||
</td>
|
||
<td><button onclick="ZoomFrame()">🔍️ Zoom</button></td>
|
||
<!--<td><button onclick="ListFrames()">🪟 Frames</button></td>-->
|
||
<td style="width: 100%;"><input type="text" style="width: 100%;"/></td>
|
||
<td><button onclick="LoadFrame()">↩️ Load</button></td>
|
||
<td><button onclick="ExciseFrame()">↗️ Excise</button></td>
|
||
<tr></table></div>
|
||
<div><iframe></iframe></div>
|
||
<script>
|
||
var FrameZoomIndex = -1;
|
||
|
||
//function $rule(prop){
|
||
// return getComputedStyle(document.body).getPropertyValue(prop);
|
||
//};
|
||
|
||
function $new(tag){
|
||
return document.createElement(tag);
|
||
};
|
||
|
||
function ShowAppInfo(){
|
||
alert(AppInfoString);
|
||
};
|
||
|
||
function SaveUrl(){
|
||
var url = document.querySelector('input[type="text"]').value;
|
||
localStorage.setItem('FramesBrowser.url', url);
|
||
return url;
|
||
}
|
||
|
||
function LoadFrame(){
|
||
document.querySelector('iframe').src = SaveUrl();
|
||
};
|
||
|
||
function ExciseFrame(){
|
||
var url = SaveUrl();
|
||
var extwindow = open(url, '_blank');
|
||
if (url.toLowerCase().startsWith('data:')) {
|
||
extwindow.document.write(`<style>body { margin: 0; } iframe { width: 100vw; height: 100vh; border: none; }</style><iframe src="${url}" frameborder="0"></iframe>`);
|
||
};
|
||
};
|
||
|
||
function LoadFile(file){
|
||
var reader = new FileReader();
|
||
reader.onload = function(){
|
||
document.querySelector('input[type="text"]').value = `data:text/html;utf8,${reader.result}`;
|
||
LoadFrame();
|
||
};
|
||
reader.readAsText(file);
|
||
};
|
||
|
||
function ZoomFrame(){
|
||
if (FrameZoomIndex == FrameZoomLevels.length - 1) {
|
||
FrameZoomIndex = -1;
|
||
} else {
|
||
FrameZoomIndex ++;
|
||
};
|
||
var level = FrameZoomLevels[FrameZoomIndex];
|
||
var levelopp = FrameZoomLevels[FrameZoomLevels.length - 1 - FrameZoomIndex];
|
||
var stylepos = (level < 100
|
||
? `right: ${level}vw; bottom: calc(${level}vh - 16px);`
|
||
: `left: ${levelopp/2}vw; top: calc(${levelopp/2}vh - 8px);`
|
||
);
|
||
document.querySelector('iframe').style = (FrameZoomIndex == -1
|
||
? ''
|
||
: `scale: ${level/100}; width: ${levelopp}vw; height: calc(${levelopp}vh - (var(--BtnActionHeight) * ${levelopp / 100})); ${stylepos}`
|
||
);
|
||
};
|
||
|
||
function ListFrames(){
|
||
var Box = NewBoxPopup();
|
||
var BtnAdd = $new('button');
|
||
BtnAdd.innerHTML = '➕ Add';
|
||
Box.appendChild(BtnAdd);
|
||
var BtnMain = $new('button');
|
||
BtnMain.innerHTML = 'No Frame';
|
||
Box.appendChild(BtnMain);
|
||
};
|
||
|
||
function NewBoxPopup(){
|
||
var Box = $new('div');
|
||
Box.className = 'BoxPopup';
|
||
var BtnClose = $new('button');
|
||
BtnClose.innerHTML = '❌ Close';
|
||
BtnClose.onclick = function(){ this.parentElement.remove() };
|
||
Box.appendChild(BtnClose);
|
||
document.body.appendChild(Box);
|
||
return Box;
|
||
};
|
||
|
||
onload = function(){
|
||
document.querySelector('input[type="text"]').value = localStorage.getItem('FramesBrowser.url');
|
||
};
|
||
</script>
|
||
</body>
|
||
</html>
|