From 94cddda6d0d88592364c2e3a8d69432411631e86 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Sun, 19 May 2019 11:22:00 +0100 Subject: [PATCH] Removed temp files --- lib/rnInjectedJs/webviewLib.js | 1 - 1 file changed, 1 deletion(-) delete mode 100644 lib/rnInjectedJs/webviewLib.js diff --git a/lib/rnInjectedJs/webviewLib.js b/lib/rnInjectedJs/webviewLib.js deleted file mode 100644 index 1645019fac..0000000000 --- a/lib/rnInjectedJs/webviewLib.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = "const webviewLib = {};\n\nlet manualDownloadResourceElements = [];\n\nwebviewLib.ipcProxySendToHost_ = null;\n\nwebviewLib.onUnloadedResourceClick = function(event) {\n\talert('test');\n\t// const resourceId = event.currentTarget.getAttribute('data-resource-id');\n\t// webviewLib.options_.postMessage('markForDownload', resourceId);\n}\n\nwebviewLib.setupResourceManualDownload = function() {\n\tfor (const element of manualDownloadResourceElements) {\n\t\telement.style.cursor = 'default';\n\t\telement.removeEventListener('click', webviewLib.onUnloadedResourceClick);\n\t}\n\n\tmanualDownloadResourceElements = [];\n\n\tconst elements = document.getElementsByClassName('resource-status-notDownloaded');\n\n\tfor (const element of elements) {\n\t\telement.style.cursor = 'pointer';\n\t\telement.addEventListener('click', webviewLib.onUnloadedResourceClick);\n\t\tmanualDownloadResourceElements.push(element);\n\t}\n}\n\nwebviewLib.handleInternalLink = function(event, anchorNode) {\n\tconst href = anchorNode.getAttribute('href');\n\tif (!href) return false;\n\n\tif (href.indexOf('#') === 0) {\n\t\tevent.preventDefault();\n\t\tlet old_hash = location.hash;\n\n\t\tlocation.hash = href;\n\n\t\t// HACK \n\t\t// For some reason anchors at the bottom cause the webview to move itself\n\t\t// so that the content is aligned with the top of the screen\n\t\t// This basically refreshes the scroll view so that is returns to a normal\n\t\t// position, the scroll positions stays correct though\n\t\t// Additionally an anchor could not be clicked twice because the location\n\t\t// would not change, this fixes that also\n\t\tsetTimeout(function() { location.hash = old_hash; }, 10);\n\t\treturn true;\n\t}\n\t\n\treturn false;\n}\n\nwebviewLib.getParentAnchorElement = function(element) {\n\tlet counter = 0;\n\twhile (true) {\n\n\t\tif (counter++ >= 10000) {\n\t\t\tconsole.warn('been looping for too long - exiting')\n\t\t\treturn null;\n\t\t}\n\n\t\tif (!element) return null;\n\t\tif (element.nodeName === 'A') return element;\n\t\telement = element.parentElement;\n\t}\n}\n\nwebviewLib.initialize = function(options) {\n\twebviewLib.options_ = options;\n\n\t// alert('iii');\n\n\tdocument.addEventListener('DOMContentLoaded', function(event) {\n\talert('loaded');\n\twebviewLib.setupResourceManualDownload();\n});\n}\n\ndocument.addEventListener('click', function(event) {\n\tconst anchor = webviewLib.getParentAnchorElement(event.target);\n\tif (!anchor) return;\n\n\t// Prevent URLs added via tags from being opened within the application itself\n\t// otherwise it would open the whole website within the WebView.\n\n\t// Note that we already handle some links in html_inline.js, however not all of them\n\t// go through this plugin, in particular links coming from third-party packages such\n\t// as Katex.\n\tif (!anchor.hasAttribute('data-from-md')) {\n\t\tif (webviewLib.handleInternalLink(event, anchor)) return;\n\n\t\tevent.preventDefault();\n\t\twebviewLib.options_.postMessage(anchor.getAttribute('href'));\n\t\treturn;\n\t}\n\n\t// If this is an internal link, jump to the anchor directly\n\tif (anchor.hasAttribute('data-from-md')) {\n\t\tif (webviewLib.handleInternalLink(event, anchor)) return;\n\t}\n});\n\n\n"; \ No newline at end of file