mirror of
https://github.com/pkimpel/retro-b5500.git
synced 2026-04-20 02:22:55 +00:00
Correct additional line-ending differences between Windows and Linux.
This commit is contained in:
@@ -1,168 +1,168 @@
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<title>B5500 LibMaint Decoder</title>
|
||||
<meta name="Author" content="Paul Kimpel">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta http-equiv="Content-Script-Type" content="text/javascript">
|
||||
<meta http-equiv="Content-Style-Type" content="text/css">
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
window.onload = function() {
|
||||
var fs = null;
|
||||
var writer = null;
|
||||
|
||||
var BICtoANSI = [
|
||||
"0", "1", "2", "3", "4", "5", "6", "7",
|
||||
"8", "9", "#", "@", "?", ":", ">", "}",
|
||||
"+", "A", "B", "C", "D", "E", "F", "G",
|
||||
"H", "I", ".", "[", "&", "(", "<", "~",
|
||||
"|", "J", "K", "L", "M", "N", "O", "P",
|
||||
"Q", "R", "$", "*", "-", ")", ";", "{",
|
||||
" ", "/", "S", "T", "U", "V", "W", "X",
|
||||
"Y", "Z", ",", "%", "!", "=", "]", "\""];
|
||||
|
||||
function appendLine(panel, text) {
|
||||
/* Appends "text"+NL as a new text node to the panel DOM element */
|
||||
var e = document.createTextNode(text + "\n");
|
||||
|
||||
panel.appendChild(e);
|
||||
writer.write(new Blob([text, "\n"]));
|
||||
}
|
||||
|
||||
function clearPanel(panel) {
|
||||
/* Clears the text panel */
|
||||
var kid;
|
||||
|
||||
while (kid = panel.firstChild) {
|
||||
panel.removeChild(kid);
|
||||
}
|
||||
}
|
||||
|
||||
function fileLoader_onLoad(ev) {
|
||||
/* Handle the onload event for an ArrayBuffer FileReader */
|
||||
var buf = ev.target.result;
|
||||
var bytes = buf.byteLength;
|
||||
var data = new DataView(buf); // use DataView() to avoid problems with littleendians.
|
||||
var panel = document.getElementById("TextPanel");
|
||||
var text = "";
|
||||
var v;
|
||||
var x = 0;
|
||||
|
||||
clearPanel(panel);
|
||||
|
||||
window.webkitStorageInfo.requestQuota(PERSISTENT, 50e6, function(granted) {
|
||||
var rqfs = window.requestFileSystem || window.webkitRequestFileSystem;
|
||||
|
||||
rqfs(window.PERSISTENT, granted, function(fileSystem) {
|
||||
fs = fileSystem;
|
||||
alert("File system " + fileSystem.name + " obtained");
|
||||
|
||||
fs.root.getFile("test1.txt", {create:true, exclusive:false}, function(f) {
|
||||
alert(f.fullPath + " created");
|
||||
|
||||
f.createWriter(function(fileWriter) {
|
||||
writer = fileWriter;
|
||||
writer.write(new Blob(["This is the first line\n"], {type: "text/plain"}));
|
||||
|
||||
do {
|
||||
v = data.getUint8(x);
|
||||
if (v & 0x80) {
|
||||
appendLine(panel, text);
|
||||
panel.appendChild(document.createElement("hr"));
|
||||
if (v == 0x8F) {
|
||||
text = "\\\\\\\\\\ [EOF] /////";
|
||||
} else {
|
||||
text = BICtoANSI[v & 0x3F];
|
||||
}
|
||||
} else {
|
||||
if (text.length >= 80) {
|
||||
appendLine(panel, text);
|
||||
text = "";
|
||||
}
|
||||
text += BICtoANSI[v & 0x3F];
|
||||
}
|
||||
} while (++x < bytes);
|
||||
appendLine(panel, text);
|
||||
|
||||
});
|
||||
|
||||
}, function(e) {alert("Create Error:" + e)});
|
||||
|
||||
}, function(e) {alert("RQFS Error:" + e)});
|
||||
|
||||
}, function(e) {alert("Quota Error:" + e)});
|
||||
|
||||
//document.getElementById("RunBtn").disabled = false;
|
||||
}
|
||||
|
||||
function fileSelector_onChange(ev) {
|
||||
/* Handle the <input type=file> onchange event when a file is selected */
|
||||
var f = ev.target.files[0];
|
||||
var reader = new FileReader();
|
||||
|
||||
document.getElementById("GoBtn").disabled = true;
|
||||
|
||||
alert("File selected: " + f.name +
|
||||
"\nModified " + f.lastModifiedDate +
|
||||
"\nType=" + f.type + ", Size=" + f.size + " octets");
|
||||
|
||||
reader.onload = fileLoader_onLoad;
|
||||
reader.readAsArrayBuffer(f.slice(0,65536));
|
||||
}
|
||||
|
||||
function goBtn_onClick(ev) {
|
||||
/* Driver to process the data file */
|
||||
|
||||
}
|
||||
|
||||
function checkBrowser() {
|
||||
/* Checks whether this browser can support the necessary stuff */
|
||||
var missing = "";
|
||||
|
||||
if (!window.File) {missing += ", File"}
|
||||
if (!window.FileReader) {missing += ", FileReader"}
|
||||
if (!window.webkitRequestFileSystem) {missing += ", webkitRequestFileSystem"}
|
||||
if (!window.FileList) {missing += ", FileList"}
|
||||
if (!window.Blob) {missing += ", Blob"}
|
||||
if (!window.ArrayBuffer) {missing += ", ArrayBuffer"}
|
||||
if (!window.DataView) {missing += ", DataView"}
|
||||
|
||||
if (missing.length == 0) {
|
||||
return false;
|
||||
} else {
|
||||
alert("No can do... your browser does not support the following features:\n" + missing.substring(2));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Start of window.onload() */
|
||||
if (checkBrowser()) {
|
||||
return;
|
||||
}
|
||||
document.getElementById("FileSelector").addEventListener("change", fileSelector_onChange, false);
|
||||
document.getElementById("GoBtn").addEventListener("click", goBtn_onClick, false);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div style="position:relative; width:100%">
|
||||
<div style="position:absolute; left:0; top:0; width:auto">
|
||||
retro-B5500 LibMaint Tape Decoder
|
||||
</div>
|
||||
<div style="position:absolute; top:0; right:0; width:auto">
|
||||
<input id=FileSelector type=file size=60>
|
||||
|
||||
<input id=GoBtn type=button value=Go disabled>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<pre id=TextPanel>
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
<!DOCTYPE html>
|
||||
<head>
|
||||
<title>B5500 LibMaint Decoder</title>
|
||||
<meta name="Author" content="Paul Kimpel">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta http-equiv="Content-Script-Type" content="text/javascript">
|
||||
<meta http-equiv="Content-Style-Type" content="text/css">
|
||||
|
||||
<script>
|
||||
"use strict";
|
||||
|
||||
window.onload = function() {
|
||||
var fs = null;
|
||||
var writer = null;
|
||||
|
||||
var BICtoANSI = [
|
||||
"0", "1", "2", "3", "4", "5", "6", "7",
|
||||
"8", "9", "#", "@", "?", ":", ">", "}",
|
||||
"+", "A", "B", "C", "D", "E", "F", "G",
|
||||
"H", "I", ".", "[", "&", "(", "<", "~",
|
||||
"|", "J", "K", "L", "M", "N", "O", "P",
|
||||
"Q", "R", "$", "*", "-", ")", ";", "{",
|
||||
" ", "/", "S", "T", "U", "V", "W", "X",
|
||||
"Y", "Z", ",", "%", "!", "=", "]", "\""];
|
||||
|
||||
function appendLine(panel, text) {
|
||||
/* Appends "text"+NL as a new text node to the panel DOM element */
|
||||
var e = document.createTextNode(text + "\n");
|
||||
|
||||
panel.appendChild(e);
|
||||
writer.write(new Blob([text, "\n"]));
|
||||
}
|
||||
|
||||
function clearPanel(panel) {
|
||||
/* Clears the text panel */
|
||||
var kid;
|
||||
|
||||
while (kid = panel.firstChild) {
|
||||
panel.removeChild(kid);
|
||||
}
|
||||
}
|
||||
|
||||
function fileLoader_onLoad(ev) {
|
||||
/* Handle the onload event for an ArrayBuffer FileReader */
|
||||
var buf = ev.target.result;
|
||||
var bytes = buf.byteLength;
|
||||
var data = new DataView(buf); // use DataView() to avoid problems with littleendians.
|
||||
var panel = document.getElementById("TextPanel");
|
||||
var text = "";
|
||||
var v;
|
||||
var x = 0;
|
||||
|
||||
clearPanel(panel);
|
||||
|
||||
window.webkitStorageInfo.requestQuota(PERSISTENT, 50e6, function(granted) {
|
||||
var rqfs = window.requestFileSystem || window.webkitRequestFileSystem;
|
||||
|
||||
rqfs(window.PERSISTENT, granted, function(fileSystem) {
|
||||
fs = fileSystem;
|
||||
alert("File system " + fileSystem.name + " obtained");
|
||||
|
||||
fs.root.getFile("test1.txt", {create:true, exclusive:false}, function(f) {
|
||||
alert(f.fullPath + " created");
|
||||
|
||||
f.createWriter(function(fileWriter) {
|
||||
writer = fileWriter;
|
||||
writer.write(new Blob(["This is the first line\n"], {type: "text/plain"}));
|
||||
|
||||
do {
|
||||
v = data.getUint8(x);
|
||||
if (v & 0x80) {
|
||||
appendLine(panel, text);
|
||||
panel.appendChild(document.createElement("hr"));
|
||||
if (v == 0x8F) {
|
||||
text = "\\\\\\\\\\ [EOF] /////";
|
||||
} else {
|
||||
text = BICtoANSI[v & 0x3F];
|
||||
}
|
||||
} else {
|
||||
if (text.length >= 80) {
|
||||
appendLine(panel, text);
|
||||
text = "";
|
||||
}
|
||||
text += BICtoANSI[v & 0x3F];
|
||||
}
|
||||
} while (++x < bytes);
|
||||
appendLine(panel, text);
|
||||
|
||||
});
|
||||
|
||||
}, function(e) {alert("Create Error:" + e)});
|
||||
|
||||
}, function(e) {alert("RQFS Error:" + e)});
|
||||
|
||||
}, function(e) {alert("Quota Error:" + e)});
|
||||
|
||||
//document.getElementById("RunBtn").disabled = false;
|
||||
}
|
||||
|
||||
function fileSelector_onChange(ev) {
|
||||
/* Handle the <input type=file> onchange event when a file is selected */
|
||||
var f = ev.target.files[0];
|
||||
var reader = new FileReader();
|
||||
|
||||
document.getElementById("GoBtn").disabled = true;
|
||||
|
||||
alert("File selected: " + f.name +
|
||||
"\nModified " + f.lastModifiedDate +
|
||||
"\nType=" + f.type + ", Size=" + f.size + " octets");
|
||||
|
||||
reader.onload = fileLoader_onLoad;
|
||||
reader.readAsArrayBuffer(f.slice(0,65536));
|
||||
}
|
||||
|
||||
function goBtn_onClick(ev) {
|
||||
/* Driver to process the data file */
|
||||
|
||||
}
|
||||
|
||||
function checkBrowser() {
|
||||
/* Checks whether this browser can support the necessary stuff */
|
||||
var missing = "";
|
||||
|
||||
if (!window.File) {missing += ", File"}
|
||||
if (!window.FileReader) {missing += ", FileReader"}
|
||||
if (!window.webkitRequestFileSystem) {missing += ", webkitRequestFileSystem"}
|
||||
if (!window.FileList) {missing += ", FileList"}
|
||||
if (!window.Blob) {missing += ", Blob"}
|
||||
if (!window.ArrayBuffer) {missing += ", ArrayBuffer"}
|
||||
if (!window.DataView) {missing += ", DataView"}
|
||||
|
||||
if (missing.length == 0) {
|
||||
return false;
|
||||
} else {
|
||||
alert("No can do... your browser does not support the following features:\n" + missing.substring(2));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/* Start of window.onload() */
|
||||
if (checkBrowser()) {
|
||||
return;
|
||||
}
|
||||
document.getElementById("FileSelector").addEventListener("change", fileSelector_onChange, false);
|
||||
document.getElementById("GoBtn").addEventListener("click", goBtn_onClick, false);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div style="position:relative; width:100%">
|
||||
<div style="position:absolute; left:0; top:0; width:auto">
|
||||
retro-B5500 LibMaint Tape Decoder
|
||||
</div>
|
||||
<div style="position:absolute; top:0; right:0; width:auto">
|
||||
<input id=FileSelector type=file size=60>
|
||||
|
||||
<input id=GoBtn type=button value=Go disabled>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<pre id=TextPanel>
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user