1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-12-01 22:50:35 +00:00

Add warning to manual when viewed from web

Added a warning to the index page that only appears when viewing it
over http/https.  The issue is that the manual on the web reflects the
tip-of-tree sources, which may be inaccurate for whatever version the
user has.

Also, provide an alternate path to opening the manual in-app when
under development.
This commit is contained in:
Andy McFadden 2021-10-08 11:01:03 -07:00
parent ed4cc84782
commit 1a00eb0cb7
2 changed files with 32 additions and 0 deletions

View File

@ -84,6 +84,17 @@ namespace SourceGen {
string helpFilePath = Path.Combine(RuntimeDataAccess.GetDirectory(),
HELP_DIR, fileName);
if (!File.Exists(helpFilePath)) {
// Alternate path, used during development. If it also doesn't exist, leave
// the original path intact so the error message is useful.
string altPath = Path.Combine(RuntimeDataAccess.GetDirectory() +
"\\..\\..\\docs\\sgmanual",
fileName);
altPath = Path.GetFullPath(altPath); // normalize
if (File.Exists(altPath)) {
helpFilePath = altPath;
}
}
string url = "file://" + helpFilePath;
//url = url.Replace("#", "%23");
Debug.WriteLine("Requesting help URL: " + url);

View File

@ -18,6 +18,16 @@ and 65816 code. The official web site is
<p>If you want to get up to speed quickly, start with the
<a href="https://6502bench.com/sgtutorial/">tutorials</a>.</p>
<div id="webwarn" style="display:none;">
<p style="color:red;">
NOTE: the version of the manual on the web may be older or newer
than the version of the program you're using. To ensure you're
reading the correct version, open the manual from within SourceGen,
using the <samp>Help &gt; Help</samp> menu item or by hitting
<kbd class="key">F1</kbd>.
</p>
</div>
<h2>Contents</h2>
<ul>
<li><a href="intro.html">Overview</a>
@ -210,5 +220,16 @@ and 65816 code. The official web site is
<hr/>
<p>Copyright 2020 faddenSoft</p>
</div>
<script>
// Show a warning when reading the manual on the web (rather than
// from a file in the SourceGen installation directory).
var proto = window.location.protocol;
console.log(proto);
if (proto == "http:" || proto == "https:") {
document.getElementById("webwarn").style.display = "block";
}
</script>
</body>
</html>