PageSourceSearch

https://www.rafaela.gob.ar/Sitio/Scripts/clipboard.js

js rafaela.gob.ar collected 2026-10-01 14:31:42 UTC 6,348 bytes, 132 lines download raw bytes

vendor: 5,441 bytes, lines 1-102
1//  Import support https://stackoverflow.com/questions/13673346/supporting-both-commonjs-and-amd
2(function(name, definition) {
3    if (typeof module !== "undefined") { module.exports = definition(); }
4    else if (typeof define === "function" && typeof define.amd === "object") { define(definition); }
5    else { this[name] = definition(); }
6}("clipboard", function() {
7  if (!document.addEventListener) {
8    return null;
9  }
10
11  var clipboard = {};
12
13  clipboard.copy = (function() {
14    var _intercept = false;
15    var _data = null; // Map from data type (e.g. "text/html") to value.
16
17    function cleanup() {
18      _intercept = false;
19      _data = null;
20    }
21
22    document.addEventListener("copy", function(e) {
23      if (_intercept) {
24        for (var key in _data) {
25          e.clipboardData.setData(key, _data[key]);
26        }
27        e.preventDefault();
28      }
29    });
30
31    return function(data) {
32      return new Promise(function(resolve, reject) {
33        _intercept = true;
34        if (typeof data === "string") {
35          _data = {"text/plain": data};
36        } else if (data instanceof Node) {
37          _data = {"text/html": new XMLSerializer().serializeToString(data)};
38        } else {
39          _data = data;
40        }
41        try {
42          if (document.execCommand("copy")) {
43            // document.execCommand is synchronous: http://www.w3.org/TR/2015/WD-clipboard-apis-20150421/#integration-with-rich-text-editing-apis
44            // So we can call resolve() back here.
45            cleanup();
46            resolve();
47          }
48          else {
49            throw new Error("Unable to copy. Perhaps it's not available in your browser?");
50          }
51        } catch (e) {
52          cleanup();
53          reject(e);
54        }
55      });
56    };
57  })();
58
59  clipboard.paste = (function() {
60    var _intercept = false;
61    var _resolve;
62    var _dataType;
63
64    document.addEventListener("paste", function(e) {
65      if (_intercept) {
66        _intercept = false;
67        e.preventDefault();
68        var resolve = _resolve;
69        _resolve = null;
70        resolve(e.clipboardData.getData(_dataType));
71      }
72    });
73
74    return function(dataType) {
75      return new Promise(function(resolve, reject) {
76        _intercept = true;
77        _resolve = resolve;
78        _dataType = dataType || "text/plain";
79        try {
80          if (!document.execCommand("paste")) {
81            _intercept = false;
82            reject(new Error("Unable to paste. Pasting only works in Internet Explorer at the moment."));
83          }
84        } catch (e) {
85          _intercept = false;
86          reject(new Error(e));
87        }
88      });
89    };
90  })();
91
92  // Handle IE behaviour.
93  if (typeof ClipboardEvent === "undefined" &&
94      typeof window.clipboardData !== "undefined" &&
95      typeof window.clipboardData.setData !== "undefined") {
96
97    /*! promise-polyfill 2.0.1 */
98    (function(a){function b(a,b){return function(){a.apply(b,arguments)}}function c(a){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof a)throw new TypeError("not a function");this._state=null,this._value=null,this._deferreds=[],i(a,b(e,this),b(f,this))}function d(a){var b=this;return null===this._state?void this._deferreds.push(a):void j(function(){var c=b._state?a.onFulfilled:a.onRejected;if(null===c)return void(b._state?a.resolve:a.reject)(b._value);var d;try{d=c(b._value)}catch(e){return void a.reject(e)}a.resolve(d)})}function e(a){try{if(a===this)throw new TypeError("A promise cannot be resolved with itself.");if(a&&("object"==typeof a||"function"==typeof a)){var c=a.then;if("function"==typeof c)return void i(b(c,a),b(e,this),b(f,this))}this._state=!0,this._value=a,g.call(this)}catch(d){f.call(this,d)}}function f(a){this._state=!1,this._value=a,g.call(this)}function g(){for(var a=0,b=this._deferreds.length;b>a;a++)d.call(this,this._deferreds[a]);this._deferreds=null}function h(a,b,c,d){this.onFulfilled="function"==typeof a?a:null,this.onRejected="function"==typeof b?b:null,this.resolve=c,this.reject=d}function i(a,b,c){var d=!1;try{a(function(a){d||(d=!0,b(a))},function(a){d||(d=!0,c(a))})}catch(e){if(d)return;d=!0,c(e)}}var j=c.immediateFn||"function"==typeof setImmediate&&setImmediate||function(a){setTimeout(a,1)},k=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)};c.prototype["catch"]=function(a){return this.then(null,a)},c.prototype.then=function(a,b){var e=this;return new c(function(c,f){d.call(e,new h(a,b,c,f))})},c.all=function(){var a=Array.prototype.slice.call(1===arguments.length&&k(arguments[0])?arguments[0]:arguments);return new c(function(b,c){function d(f,g){try{if(g&&("object"==typeof g||"function"==typeof g)){var h=g.then;if("function"==typeof h)return void h.call(g,function(a){d(f,a)},c)}a[f]=g,0===--e&&b(a)}catch(i){c(i)}}if(0===a.length)return b([]);for(var e=a.length,f=0;f<a.length;f++)d(f,a[f])})},c.resolve=function(a){return a&&"object"==typeof a&&a.constructor===c?a:new c(function(b){b(a)})},c.reject=function(a){return new c(function(b,c){c(a)})},c.race=function(a){return new c(function(b,c){for(var d=0,e=a.length;e>d;d++)a[d].then(b,c)})},"undefined"!=typeof module&&module.exports?module.exports=c:a.Promise||(a.Promise=c)})(this);
99
100    clipboard.copy = function(data) {
101      return new Promise(function(resolve, reject) {
102        // IE supports string and URL types: https://msdn.microsoft.com/en-us
102/library/ms536744(v=vs.85).aspx
103        // We only support the string type for now.
104        if (typeof data !== "string" && !("text/plain" in data)) {
105          throw new Error("You must provide a text/plain type.");
106        }
107
108        var strData = (typeof data === "string" ? data : data["text/plain"]);
109        var copySucceeded = window.clipboardData.setData("Text", strData);
110        if (copySucceeded) {
111          resolve();
112        } else {
113          reject(new Error("Copying was rejected."));
114        }
115      });
116    };
117
118    clipboard.paste = function() {
119      return new Promise(function(resolve, reject) {
120        var strData = window.clipboardData.getData("Text");
121        if (strData) {
122          resolve(strData);
123        } else {
124          // The user rejected the paste request.
125          reject(new Error("Pasting was rejected."));
126        }
127      });
128    };
129  }
130
131  return clipboard;
132}));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.