summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/clipboard.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/js/clipboard.js b/js/clipboard.js
new file mode 100644
index 0000000..744901c
--- /dev/null
+++ b/js/clipboard.js
@@ -0,0 +1,22 @@
+var clipboard = (function () {
+
+ var disabled = false;
+ var contentType = 'text/plain;charset=utf-8'
+ document.body.addEventListener('copy', function (e) {
+ if (disabled) { return }
+ if (e.clipboardData) {
+ e.preventDefault();
+ e.clipboardData.setData(contentType, canvas.ascii());
+ }
+ if (window.clipboardData) {
+ e.returnValue = false;
+ window.clipboardData.setData(contentType, canvas.ascii());
+ }
+ }, false);
+
+ return {
+ enable: function(){ disabled = false },
+ disable: function(){ disabled = true }
+ }
+
+})() \ No newline at end of file