diff --git a/README.md b/README.md index c7d3926..a56b3c9 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Note that currently, Kopher and hi01379.js assume that the search request from a - Minimalistic but easy and quick WAP-like navigation (see "Controls") - The `gopher://` scheme is assumed by default (no need to enter it manually), same for the port 70 - One-key light/dark theme toggle -- One-key switching the line wrapping mode between off (default) and on (for comfortable reading) +- One-key switching the line wrapping mode between off (default) and on (for comfortable reading even the hard-wrapped documents) - Unlimited navigation history (doesn't persist between sessions) - Up to 10 numbered bookmarks plus customizable homepage - Binary blob downloads (see "Downloads") diff --git a/js/app.js b/js/app.js index 6023b31..9632682 100644 --- a/js/app.js +++ b/js/app.js @@ -99,6 +99,8 @@ addEventListener('DOMContentLoaded', function() { return bmArray[index] } + var activeContent={'prop': 'textContent', 'nowrap': '', 'wrap': ''} // placeholder to hold the wrapped and non-wrapped content + function loadURL(url, noNavUpdate) { // wrapper to openURL that actually updates all the UI and history logoStatus.textContent = logoLoadingChar statusBar.textContent = 'Loading ' + url @@ -108,14 +110,18 @@ addEventListener('DOMContentLoaded', function() { var updateHistory = !('updateAddr' in res && res.updateAddr === false), // true by default updateContent = !(res.content === null) // true by default if(updateContent) { // update the content zone + activeContent.nowrap = res.content + activeContent.wrap = res.contentWf || res.content contentZone.innerHTML = '' contentZone.textContent = '' contentZone.dataset.wrap = 0 // reset line wrapping if(res.contentType === 'text/plain') { + activeContent.prop = 'textContent' contentZone.dataset.format='plain' - contentZone.textContent = res.content + contentZone.textContent = activeContent.nowrap } else { contentZone.dataset.format='native' + activeContent.prop='innerHTML' contentZone.innerHTML = res.content var contentLinks = contentZone.querySelectorAll('a'), l = contentLinks.length, i for(i=0;i]/g, function(tag) {return tagsToReplace[tag] || tag}) } + function unphlow(str) { // Unphlow algorithm implementation + var lines=str.split('\n'), line, l = lines.length, i, buf = '', out = [] + for(i=0;i