diff --git a/js/2.0.2/evts.js b/js/2.0.2/evts.js index 024cc8c..4f955ca 100644 --- a/js/2.0.2/evts.js +++ b/js/2.0.2/evts.js @@ -267,6 +267,43 @@ function wrongPwAlert() { }); } +function copyToClipBoard(html) { + // Create an iframe (isolated container) for the HTML + var container = document.createElement("div"); + container.innerHTML = html; + + // Hide element + container.style.position = "fixed"; + container.style.pointerEvents = "none"; + container.style.opacity = 0; + + // Detect all style sheets of the page + var activeSheets = Array.prototype.slice + .call(document.styleSheets) + .filter(function (sheet) { + return !sheet.disabled; + }); + + // Mount the iframe to the DOM to make `contentWindow` available + document.body.appendChild(container); + + // Copy to clipboard + window.getSelection().removeAllRanges(); + + var range = document.createRange(); + range.selectNode(container); + window.getSelection().addRange(range); + + document.execCommand("copy"); + for (var i = 0; i < activeSheets.length; i++) activeSheets[i].disabled = true; + document.execCommand("copy"); + for (var i = 0; i < activeSheets.length; i++) + activeSheets[i].disabled = false; + + // Remove the iframe + document.body.removeChild(container); +} + export { hideMenus, showMenu, @@ -279,5 +316,6 @@ export { clickImportFiles, resetNavBar, printVersion, - wrongPwAlert + wrongPwAlert, + copyToClipBoard }; diff --git a/js/2.0.2/files.js b/js/2.0.2/files.js index 27c7330..621e052 100644 --- a/js/2.0.2/files.js +++ b/js/2.0.2/files.js @@ -5,7 +5,7 @@ import { } from "./storage.js"; import { loadTemplate } from "./web.js"; import parseFormOnSubmit from "./parseForm.js"; -import { modalNotifier, resetNavBar } from "./evts.js"; +import { copyToClipBoard, modalNotifier, resetNavBar } from "./evts.js"; import { passwordHash } from "./scripts.js"; function buildFile() { @@ -331,42 +331,6 @@ function copyFileToClipboard() { } } -function copyToClipBoard(html) { - // Create an iframe (isolated container) for the HTML - var container = document.createElement("div"); - container.innerHTML = html; - - // Hide element - container.style.position = "fixed"; - container.style.pointerEvents = "none"; - container.style.opacity = 0; - - // Detect all style sheets of the page - var activeSheets = Array.prototype.slice - .call(document.styleSheets) - .filter(function (sheet) { - return !sheet.disabled; - }); - - // Mount the iframe to the DOM to make `contentWindow` available - document.body.appendChild(container); - - // Copy to clipboard - window.getSelection().removeAllRanges(); - - var range = document.createRange(); - range.selectNode(container); - window.getSelection().addRange(range); - - document.execCommand("copy"); - for (var i = 0; i < activeSheets.length; i++) activeSheets[i].disabled = true; - document.execCommand("copy"); - for (var i = 0; i < activeSheets.length; i++) - activeSheets[i].disabled = false; - - // Remove the iframe - document.body.removeChild(container); -} function formEvts(storageName) { //add event listener to submitContainer diff --git a/js/2.0.2/parseForm.js b/js/2.0.2/parseForm.js index 5083874..c95547d 100644 --- a/js/2.0.2/parseForm.js +++ b/js/2.0.2/parseForm.js @@ -1,4 +1,6 @@ -import { storeData, clearData, retrieveData, setCurrentFileName } from "./storage.js"; +import { copyToClipBoard } from "./evts.js"; +import { storeData, clearData, retrieveData } from "./storage.js"; + function parseFormOnSubmit(returnJSON = false, parseOnly = false) { //event.preventDefault; @@ -385,43 +387,6 @@ function loadTextBlocks() { return textBlocksObject; } - function copyToClipBoard(html) { - // Create an iframe (isolated container) for the HTML - var container = document.createElement("div"); - container.innerHTML = html; - - // Hide element - container.style.position = "fixed"; - container.style.pointerEvents = "none"; - container.style.opacity = 0; - - // Detect all style sheets of the page - var activeSheets = Array.prototype.slice - .call(document.styleSheets) - .filter(function (sheet) { - return !sheet.disabled; - }); - - // Mount the iframe to the DOM to make `contentWindow` available - document.body.appendChild(container); - - // Copy to clipboard - window.getSelection().removeAllRanges(); - - var range = document.createRange(); - range.selectNode(container); - window.getSelection().addRange(range); - - document.execCommand("copy"); - for (var i = 0; i < activeSheets.length; i++) activeSheets[i].disabled = true; - document.execCommand("copy"); - for (var i = 0; i < activeSheets.length; i++) - activeSheets[i].disabled = false; - - // Remove the iframe - document.body.removeChild(container); - } - function mainFormPlaceholder(msg) { return "

" + msg + "












"; }