Implemented Unflow for plaintext content
This commit is contained in:
@@ -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<l;i++) { // dynamically index all the links in the rendered content
|
||||
@@ -203,6 +209,8 @@ addEventListener('DOMContentLoaded', function() {
|
||||
break
|
||||
case '6': // toggle line wrapping
|
||||
contentZone.dataset.wrap = 1 - parseInt(contentZone.dataset.wrap)
|
||||
if(activeContent.wrap != activeContent.nowrap) // only update contentZone if they differ
|
||||
contentZone[activeContent.prop] = activeContent[parseInt(contentZone.dataset.wrap) ? 'wrap' : 'nowrap']
|
||||
break
|
||||
case 'Call': // refresh
|
||||
loadURL(currentUrl, true)
|
||||
|
||||
Reference in New Issue
Block a user