-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathgenerator.nomodule.js
More file actions
28 lines (28 loc) · 1.53 KB
/
generator.nomodule.js
File metadata and controls
28 lines (28 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/**
* Generate the footer & Copy URLs.
* @param {string[]} copyStrings The strings that should be copyable
* @param {string} githubURL The link to your markdown file on your GitHub Page (NOT your repository). Example for demo.md from this repository: https://lxhom.github.io/GitHubCopy/demo
* @param {boolean} shhh Add a message saying "Shhh, this is the secret JS Section!"
* @param {boolean} link Add a link to my GitHub page
* @param {string} footerText Add a text to the footer arrow
* @return {{markdown: string, urls: {code: string, url: string}[]}} The output markdown string, and an array with {code, url} objects (indices match with copyStrings)
*/
function generate(copyStrings, githubURL, shhh, link, footerText) {
if (shhh === void 0) { shhh = true; }
if (link === void 0) { link = true; }
if (footerText === void 0) { footerText = ""; }
var markdown = "<details><summary>" + footerText + "</summary>\n\n";
if (shhh)
markdown += "Shhh, this is the secret JS Section!\n\n";
if (link)
markdown += "Generated by [GitHubCopy](https://github.com/lxhom/GitHubCopy/)\n\n";
markdown += "<script>let i=location.search.split('?')[1];i.length?history.back(navigator.clipboard.writeText(unescape([";
var urls = [];
copyStrings.forEach(function (value, index) {
markdown += "'" + escape(value) + "',";
urls.push({ code: value, url: githubURL + "?" + index });
});
markdown.substr;
markdown += "][+i]))):i</script>\n\n</details>\n\n";
return { markdown: markdown, urls: urls };
}