aboutsummaryrefslogtreecommitdiffstats
path: root/lib/clipboard.js
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@redhat.com>2010-06-11 21:52:52 +0200
committerMatěj Cepl <mcepl@redhat.com>2010-06-11 21:52:52 +0200
commit54426f47a1149e5b833653660db3b208c78e67f1 (patch)
treeae28e0a5887e643e4a19045d8f3e07c45e12b744 /lib/clipboard.js
parente8d6c71ee96a96230aadd5504e3f312774896920 (diff)
downloadbugzilla-triage-54426f47a1149e5b833653660db3b208c78e67f1.tar.gz
Last unused files archived.
Diffstat (limited to 'lib/clipboard.js')
-rw-r--r--lib/clipboard.js125
1 files changed, 0 insertions, 125 deletions
diff --git a/lib/clipboard.js b/lib/clipboard.js
deleted file mode 100644
index 0051a55..0000000
--- a/lib/clipboard.js
+++ /dev/null
@@ -1,125 +0,0 @@
-// Released under the MIT/X11 license
-// http://www.opensource.org/licenses/mit-license.php
-
-/**
- * returns content of the system clipboard
- * @return string with the content of the clipboard or "" if empty.
- * originally from
- * https://developer.mozilla.org/en/Using_the_Clipboard
- * https://wiki.mozilla.org/Labs/Jetpack/JEP/10
- */
-
-function getClipboard() {
- var clip = Cc["@mozilla.org/widget/clipboard;1"].
- getService(Ci.nsIClipboard);
- if (!clip) {
- throw new Error("No access to the clipboard!");
- }
- return clip;
-}
-
-function createTransferable() {
- var trans = Cc["@mozilla.org/widget/transferable;1"].
- createInstance(Ci.nsITransferable);
- if (!trans) {
- throw new Error("No access to the transfer object during the set of clipboard!");
- }
- return trans;
-}
-
-var getMethod = exports.get = function getMethod( flavor ) {
- var pastetext = "", mimeType = "", stuff = {};
- var len = 0, clipId = 0, clip = {}, trans = {};
-
- // flavor argument is optional
- if (flavor === undefined) {
- flavor = "plain";
- }
-
- if (flavor === "plain") {
- mimeType = "text/unicode";
- } else if (favor === "html") {
- mimeType = "text/html";
- } else {
- throw new Error("Unsupported flavor '" + flavor + "'!");
- }
-
- clip = getClipboard();
-
- trans = createTransferable();
-
- trans.addDataFlavor(mimeType);
- clip.getData(trans, clip.kGlobalClipboard);
-
- var str = {};
- var strLength = {};
-
- trans.getTransferData(mimeType, str, strLength);
-
- if (str) {
- str = str.value.QueryInterface(Ci.nsISupportsString);
- pastetext = str.data.substring(0, strLength.value / 2);
- }
- return pastetext;
-};
-
-var setMethod = exports.set = function setMethod(content, flavor) {
- var mimeType = "", stuff = {};
- var len = 0, clipId = 0, clip = {}, trans = {};
-
- // flavor argument is optional
- if (flavor === undefined) {
- flavor = "plain";
- }
-
- if (flavor === "plain") {
- mimeType = "text/unicode";
- } else if (favor === "html") {
- mimeType = "text/html";
- } else {
- throw new Error("Unsupported flavor '" + flavor + "'!");
- }
-
- stuff = Cc["@mozilla.org/supports-string;1"].
- createInstance(Ci.nsISupportsString);
- if (!stuff) {
- return false;
- }
- stuff.data = content;
- len = content.length * 2;
-
- clip = getClipboard();
-
- trans = createTransferable();
-
- trans.addDataFlavor(mimeType);
- trans.setTransferData(mimeType, stuff, content.length * 2);
-
- clip.setData(trans, null, clip.kGlobalClipboard);
- return true;
-};
-
-var flavorsMethod = exports.getCurrentFlavors = function flavorsMethod(test) {
- // currently the only possible flavors in Jetpack-prototype are "plain" and
- // "html", i.e., "text/plain" (or text/unicode?) and "text/html" (or
- // application/xml+xhtml?)
- var possibleTypes = {
- "text/unicode": "plain",
- "text/plain": "plain",
- "text/html": "html"
- };
- var flavorArray = [];
- var clip = getClipboard();
-
- for (var flavor in possibleTypes) {
- var presentFlavor = clip.hasDataMatchingFlavors(
- [flavor],
- 1,
- clip.kGlobalClipboard
- );
- if (presentFlavor) {
- flavorArray.push(possibleTypes[flavor])
- }
- }
- return flavorArray;
-}; \ No newline at end of file