cleanup
merged copytoclipboard
This commit is contained in:
parent
aa6b528147
commit
11521adff7
@ -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 {
|
export {
|
||||||
hideMenus,
|
hideMenus,
|
||||||
showMenu,
|
showMenu,
|
||||||
@ -279,5 +316,6 @@ export {
|
|||||||
clickImportFiles,
|
clickImportFiles,
|
||||||
resetNavBar,
|
resetNavBar,
|
||||||
printVersion,
|
printVersion,
|
||||||
wrongPwAlert
|
wrongPwAlert,
|
||||||
|
copyToClipBoard
|
||||||
};
|
};
|
||||||
|
|||||||
@ -5,7 +5,7 @@ import {
|
|||||||
} from "./storage.js";
|
} from "./storage.js";
|
||||||
import { loadTemplate } from "./web.js";
|
import { loadTemplate } from "./web.js";
|
||||||
import parseFormOnSubmit from "./parseForm.js";
|
import parseFormOnSubmit from "./parseForm.js";
|
||||||
import { modalNotifier, resetNavBar } from "./evts.js";
|
import { copyToClipBoard, modalNotifier, resetNavBar } from "./evts.js";
|
||||||
import { passwordHash } from "./scripts.js";
|
import { passwordHash } from "./scripts.js";
|
||||||
|
|
||||||
function buildFile() {
|
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) {
|
function formEvts(storageName) {
|
||||||
//add event listener to submitContainer
|
//add event listener to submitContainer
|
||||||
|
|||||||
@ -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) {
|
function parseFormOnSubmit(returnJSON = false, parseOnly = false) {
|
||||||
//event.preventDefault;
|
//event.preventDefault;
|
||||||
@ -385,43 +387,6 @@ function loadTextBlocks() {
|
|||||||
return textBlocksObject;
|
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) {
|
function mainFormPlaceholder(msg) {
|
||||||
return "<div class='w3-row-padding w3-padding-24 w3-container w3-flat-clouds'><div class='w3-code notranslate w3-border-white' style='font-family: Arial, Helvetica, sans-serif;'><p>" + msg + "</p><br><br><br><br><br><br><br><br><br><br><br></div></div>";
|
return "<div class='w3-row-padding w3-padding-24 w3-container w3-flat-clouds'><div class='w3-code notranslate w3-border-white' style='font-family: Arial, Helvetica, sans-serif;'><p>" + msg + "</p><br><br><br><br><br><br><br><br><br><br><br></div></div>";
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user