1
0
mirror of https://github.com/Tygs/0bin.git synced 2023-08-10 21:13:00 +03:00
0bin/zerobin/static/js/main.min.js

13 lines
274 KiB
JavaScript
Raw Normal View History

2012-05-17 13:13:40 +04:00
2020-08-14 19:18:17 +03:00
/* Vue */
(function(global,factory){typeof exports==="object"&&typeof module!=="undefined"?module.exports=factory():typeof define==="function"&&define.amd?define(factory):(global=global||self,global.Vue=factory())})(this,function(){"use strict";var emptyObject=Object.freeze({});function isUndef(v){return v===undefined||v===null}function isDef(v){return v!==undefined&&v!==null}function isTrue(v){return v===true}function isFalse(v){return v===false}function isPrimitive(value){return typeof value==="string"||typeof value==="number"||typeof value==="symbol"||typeof value==="boolean"}function isObject(obj){return obj!==null&&typeof obj==="object"}var _toString=Object.prototype.toString;function toRawType(value){return _toString.call(value).slice(8,-1)}function isPlainObject(obj){return _toString.call(obj)==="[object Object]"}function isRegExp(v){return _toString.call(v)==="[object RegExp]"}function isValidArrayIndex(val){var n=parseFloat(String(val));return n>=0&&Math.floor(n)===n&&isFinite(val)}function isPromise(val){return isDef(val)&&typeof val.then==="function"&&typeof val.catch==="function"}function toString(val){return val==null?"":Array.isArray(val)||isPlainObject(val)&&val.toString===_toString?JSON.stringify(val,null,2):String(val)}function toNumber(val){var n=parseFloat(val);return isNaN(n)?val:n}function makeMap(str,expectsLowerCase){var map=Object.create(null);var list=str.split(",");for(var i=0;i<list.length;i++){map[list[i]]=true}return expectsLowerCase?function(val){return map[val.toLowerCase()]}:function(val){return map[val]}}var isBuiltInTag=makeMap("slot,component",true);var isReservedAttribute=makeMap("key,ref,slot,slot-scope,is");function remove(arr,item){if(arr.length){var index=arr.indexOf(item);if(index>-1){return arr.splice(index,1)}}}var hasOwnProperty=Object.prototype.hasOwnProperty;function hasOwn(obj,key){return hasOwnProperty.call(obj,key)}function cached(fn){var cache=Object.create(null);return function cachedFn(str){var hit=cache[str];return hit||(cache[str]=fn(str))}}var camelizeRE=/-(\w)/g;var camelize=cached(function(str){return str.replace(camelizeRE,function(_,c){return c?c.toUpperCase():""})});var capitalize=cached(function(str){return str.charAt(0).toUpperCase()+str.slice(1)});var hyphenateRE=/\B([A-Z])/g;var hyphenate=cached(function(str){return str.replace(hyphenateRE,"-$1").toLowerCase()});function polyfillBind(fn,ctx){function boundFn(a){var l=arguments.length;return l?l>1?fn.apply(ctx,arguments):fn.call(ctx,a):fn.call(ctx)}boundFn._length=fn.length;return boundFn}function nativeBind(fn,ctx){return fn.bind(ctx)}var bind=Function.prototype.bind?nativeBind:polyfillBind;function toArray(list,start){start=start||0;var i=list.length-start;var ret=new Array(i);while(i--){ret[i]=list[i+start]}return ret}function extend(to,_from){for(var key in _from){to[key]=_from[key]}return to}function toObject(arr){var res={};for(var i=0;i<arr.length;i++){if(arr[i]){extend(res,arr[i])}}return res}function noop(a,b,c){}var no=function(a,b,c){return false};var identity=function(_){return _};function genStaticKeys(modules){return modules.reduce(function(keys,m){return keys.concat(m.staticKeys||[])},[]).join(",")}function looseEqual(a,b){if(a===b){return true}var isObjectA=isObject(a);var isObjectB=isObject(b);if(isObjectA&&isObjectB){try{var isArrayA=Array.isArray(a);var isArrayB=Array.isArray(b);if(isArrayA&&isArrayB){return a.length===b.length&&a.every(function(e,i){return looseEqual(e,b[i])})}else if(a instanceof Date&&b instanceof Date){return a.getTime()===b.getTime()}else if(!isArrayA&&!isArrayB){var keysA=Object.keys(a);var keysB=Object.keys(b);return keysA.length===keysB.length&&keysA.every(function(key){return looseEqual(a[key],b[key])})}else{return false}}catch(e){return false}}else if(!isObjectA&&!isObjectB){return String(a)===String(b)}else{return false}}function looseIndexOf(arr,val){for(var i=0;i<arr.length;i++){if(looseEqual(arr[i],val)){return i}}return-1}function once(fn){var called=false;return function(){if(!called){called=true;fn.apply(this,arguments)}}}var SSR_ATTR="data-server-rendered";var ASSE
2012-05-17 13:13:40 +04:00
/* SJCL */
2020-08-14 19:18:17 +03:00
var sjcl={cipher:{},hash:{},keyexchange:{},mode:{},misc:{},codec:{},exception:{corrupt:function(a){this.toString=function(){return"CORRUPT: "+this.message};this.message=a},invalid:function(a){this.toString=function(){return"INVALID: "+this.message};this.message=a},bug:function(a){this.toString=function(){return"BUG: "+this.message};this.message=a},notReady:function(a){this.toString=function(){return"NOT READY: "+this.message};this.message=a}}};if(typeof module!="undefined"&&module.exports)module.exports=sjcl;sjcl.cipher.aes=function(a){this.h[0][0][0]||this.w();var b,c,d,e,f=this.h[0][4],g=this.h[1];b=a.length;var h=1;if(b!==4&&b!==6&&b!==8)throw new sjcl.exception.invalid("invalid aes key size");this.a=[d=a.slice(0),e=[]];for(a=b;a<4*b+28;a++){c=d[a-1];if(a%b===0||b===8&&a%b===4){c=f[c>>>24]<<24^f[c>>16&255]<<16^f[c>>8&255]<<8^f[c&255];if(a%b===0){c=c<<8^c>>>24^h<<24;h=h<<1^(h>>7)*283}}d[a]=d[a-b]^c}for(b=0;a;b++,a--){c=d[b&3?a:a-4];e[b]=a<=4||b<4?c:g[0][f[c>>>24]]^g[1][f[c>>16&255]]^g[2][f[c>>8&255]]^g[3][f[c&255]]}};sjcl.cipher.aes.prototype={encrypt:function(a){return this.H(a,0)},decrypt:function(a){return this.H(a,1)},h:[[[],[],[],[],[]],[[],[],[],[],[]]],w:function(){var a=this.h[0],b=this.h[1],c=a[4],d=b[4],e,f,g,h=[],i=[],k,j,l,m;for(e=0;e<256;e++)i[(h[e]=e<<1^(e>>7)*283)^e]=e;for(f=g=0;!c[f];f^=k||1,g=i[g]||1){l=g^g<<1^g<<2^g<<3^g<<4;l=l>>8^l&255^99;c[f]=l;d[l]=f;j=h[e=h[k=h[f]]];m=j*16843009^e*65537^k*257^f*16843008;j=h[l]*257^l*16843008;for(e=0;e<4;e++){a[e][f]=j=j<<24^j>>>8;b[e][l]=m=m<<24^m>>>8}}for(e=0;e<5;e++){a[e]=a[e].slice(0);b[e]=b[e].slice(0)}},H:function(a,b){if(a.length!==4)throw new sjcl.exception.invalid("invalid aes block size");var c=this.a[b],d=a[0]^c[0],e=a[b?3:1]^c[1],f=a[2]^c[2];a=a[b?1:3]^c[3];var g,h,i,k=c.length/4-2,j,l=4,m=[0,0,0,0];g=this.h[b];var n=g[0],o=g[1],p=g[2],q=g[3],r=g[4];for(j=0;j<k;j++){g=n[d>>>24]^o[e>>16&255]^p[f>>8&255]^q[a&255]^c[l];h=n[e>>>24]^o[f>>16&255]^p[a>>8&255]^q[d&255]^c[l+1];i=n[f>>>24]^o[a>>16&255]^p[d>>8&255]^q[e&255]^c[l+2];a=n[a>>>24]^o[d>>16&255]^p[e>>8&255]^q[f&255]^c[l+3];l+=4;d=g;e=h;f=i}for(j=0;j<4;j++){m[b?3&-j:j]=r[d>>>24]<<24^r[e>>16&255]<<16^r[f>>8&255]<<8^r[a&255]^c[l++];g=d;d=e;e=f;f=a;a=g}return m}};sjcl.bitArray={bitSlice:function(a,b,c){a=sjcl.bitArray.P(a.slice(b/32),32-(b&31)).slice(1);return c===undefined?a:sjcl.bitArray.clamp(a,c-b)},extract:function(a,b,c){var d=Math.floor(-b-c&31);return((b+c-1^b)&-32?a[b/32|0]<<32-d^a[b/32+1|0]>>>d:a[b/32|0]>>>d)&(1<<c)-1},concat:function(a,b){if(a.length===0||b.length===0)return a.concat(b);var c=a[a.length-1],d=sjcl.bitArray.getPartial(c);return d===32?a.concat(b):sjcl.bitArray.P(b,d,c|0,a.slice(0,a.length-1))},bitLength:function(a){var b=a.length;if(b===0)return 0;return(b-1)*32+sjcl.bitArray.getPartial(a[b-1])},clamp:function(a,b){if(a.length*32<b)return a;a=a.slice(0,Math.ceil(b/32));var c=a.length;b&=31;if(c>0&&b)a[c-1]=sjcl.bitArray.partial(b,a[c-1]&2147483648>>b-1,1);return a},partial:function(a,b,c){if(a===32)return b;return(c?b|0:b<<32-a)+a*1099511627776},getPartial:function(a){return Math.round(a/1099511627776)||32},equal:function(a,b){if(sjcl.bitArray.bitLength(a)!==sjcl.bitArray.bitLength(b))return false;var c=0,d;for(d=0;d<a.length;d++)c|=a[d]^b[d];return c===0},P:function(a,b,c,d){var e;e=0;if(d===undefined)d=[];for(;b>=32;b-=32){d.push(c);c=0}if(b===0)return d.concat(a);for(e=0;e<a.length;e++){d.push(c|a[e]>>>b);c=a[e]<<32-b}e=a.length?a[a.length-1]:0;a=sjcl.bitArray.getPartial(e);d.push(sjcl.bitArray.partial(b+a&31,b+a>32?c:d.pop(),1));return d},k:function(a,b){return[a[0]^b[0],a[1]^b[1],a[2]^b[2],a[3]^b[3]]}};sjcl.codec.utf8String={fromBits:function(a){var b="",c=sjcl.bitArray.bitLength(a),d,e;for(d=0;d<c/8;d++){if((d&3)===0)e=a[d/4];b+=String.fromCharCode(e>>>24);e<<=8}return decodeURIComponent(escape(b))},toBits:function(a){a=unescape(encodeURIComponent(a));var b=[],c,d=0;for(c=0;c<a.length;c++){d=d<<8|a.charCodeAt(c);if((c&3)===3){b.push(d);d=0}}c&3&&b.push(sjcl.bitArray.partial(8*(c&3),d));return b}};sjcl.codec.hex={fromBits:function(a){var b="",c;for(c=0;c<a.length;c++)b+=((a[c]
/* Our own JS */
2020-08-15 12:09:34 +03:00
sjcl.random.startCollectors();Vue.options.delimiters=["{%","%}"];setTimeout(function(){document.getElementById("content").focus()},100);var app=new Vue({el:"#app",data:{previousPastes:[],displayBottomToolBar:false,openPreviousPastesMenu:false,readerMode:false,isUploading:false,btcCopied:false,currentPaste:{ownerKey:"",id:"",type:"",content:"",downloadLink:{},title:"",btcTipAddress:""},newPaste:{expiration:"1_day",content:"",title:"",btcTipAddress:""},messages:[],support:{clipboard:!!(isSecureContext&&navigator.clipboard&&navigator.clipboard.writeText),URLSearchParams:!!window.URLSearchParams,localStorage:function(){var val=!!localStorage;document.querySelector("html").classList.add((val?"":"no-")+"local-storage");return val}(),history:function(){var val=!!(window.history&&history.pushState);document.querySelector("html").classList.add((val?"":"no-")+"history");return val}(),fileUpload:function(){var w=window;var val=!!(w.File&&w.FileReader&&w.FileList&&w.Blob);document.querySelector("html").classList.add((val?"":"no-")+"file-upload");return val}()},isLoading:false},methods:{toggleReaderMode:function(){if(!this.readerMode){this.messages=[];if(this.support.URLSearchParams){var searchParams=new URLSearchParams(window.location.search);searchParams.set("readerMode",1);window.location.search=searchParams.toString()}}else{if(this.support.URLSearchParams){var searchParams=new URLSearchParams(window.location.search);searchParams.delete("readerMode");window.location.search=searchParams.toString()}}this.readerMode=!this.readerMode},increaseFontSize:function(amount){var readableModeContent=document.getElementById("readable-paste-content");var fontSize=window.getComputedStyle(readableModeContent,null).getPropertyValue("font-size");amount=amount||5;readableModeContent.style.fontSize=parseFloat(fontSize)+amount+"px"},decreaseFontSize:function(){this.increaseFontSize(-5)},formatEmail:function(email){return"mailto:"+email.replace("__AT__","@")},forceLoad:function(link){window.location=link;window.location.reload()},handleClone:function(){document.querySelector(".submit-form").style.display="inherit";document.querySelector(".paste-form").style.display="none";var title=document.querySelector("h1");if(title){title.style.display="none"}var content=document.getElementById("content");content.value=zerobin.getPasteContent();content.dispatchEvent(new Event("change"));this.newPaste.title=this.currentPaste.title;this.newPaste.btcTipAddress=this.currentPaste.btcTipAddress},handleCancelClone:function(){document.querySelector(".submit-form").style.display="none";document.querySelector(".paste-form").style.display="inherit";document.querySelector("h1").style.display="inherit"},handleUpload:function(files){try{app.isUploading=true;zerobin.upload(files)}catch(e){zerobin.message("danger","Could no upload the file","Error")}app.isUploading=false},handleForceColoration:function(e){var content=document.getElementById("paste-content");content.classList.add("linenums");e.target.innerHTML="Applying coloration";prettyPrint();e.target.parentNode.remove()},handleSendByEmail:function(e){window.location="mailto:friend@example.com?body="+window.location.toString()},handleDeletePaste:function(){if(window.confirm("Delete this paste?")){app.isLoading=true;bar.set("Deleting paste...","50%");fetch("/paste/"+app.currentPaste.id,{method:"DELETE",body:new URLSearchParams({owner_key:app.currentPaste.ownerKey})}).then(function(response){if(response.ok){window.location="/"}else{form.forEach(function(node){node.disabled=false});app.isLoading=false;zerobin.message("danger","Paste could not be deleted. Please try again later.","Error")}app.isLoading=false}).catch(function(error){zerobin.message("danger","Paste could not be delete. Please try again later.","Error");app.isLoading=false})}},copyToClipboard:function(){var pasteContent=zerobin.getPasteContent();var promise=navigator.clipboard.writeText(pasteContent);promise.then(function(){zerobin.message("primary","The paste is now in your clipboard","",true)},function(err){zerobin.message("danger","The paste could not be copied",""
2012-05-17 13:13:40 +04:00
2020-08-14 19:18:17 +03:00
/* Prettify */
var q=null;window.PR_SHOULD_USE_CONTINUATION=!0;(function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a=[],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c<i;++c){var j=f[c];if(/\\[bdsw]/i.test(j))a.push(j);else{var j=m(j),d;c+2<i&&"-"===f[c+1]?(d=m(f[c+2]),c+=2):d=j;b.push([j,d]);d<65||j>122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;c<b.length;++c)i=b[c],i[0]<=j[1]+1?j[1]=Math.max(j[1],i[1]):f.push(j=i);b=["["];o&&b.push("^");b.push.apply(b,a);for(c=0;c<f.length;++c)i=f[c],b.push(e(i[0])),i[1]>i[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c<b;++c){var j=f[c];j==="("?++i:"\\"===j.charAt(0)&&(j=+j.substring(1))&&j<=i&&(d[j]=-1)}for(c=1;c<d.length;++c)-1===d[c]&&(d[c]=++t);for(i=c=0;c<b;++c)j=f[c],j==="("?(++i,d[i]===void 0&&(f[c]="(?:")):"\\"===j.charAt(0)&&(j=+j.substring(1))&&j<=i&&(f[c]="\\"+d[i]);for(i=c=0;c<b;++c)"^"===f[c]&&"^"!==f[c+1]&&(f[c]="");if(a.ignoreCase&&s)for(c=0;c<b;++c)j=f[c],a=j.charAt(0),j.length>=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p<d;++p){var g=a[p];if(g.ignoreCase)l=!0;else if(/[a-z]/i.test(g.source.replace(/\\u[\da-f]{4}|\\x[\da-f]{2}|\\[^UXux]/gi,""))){s=!0;l=!1;break}}for(var r={b:8,t:9,n:10,v:11,f:12,r:13},n=[],p=0,d=a.length;p<d;++p){g=a[p];if(g.global||g.multiline)throw Error(""+g);n.push("(?:"+y(g)+")")}return RegExp(n.join("|"),l?"gi":"g")}function M(a){function m(a){switch(a.nodeType){case 1:if(e.test(a.className))break;for(var g=a.firstChild;g;g=g.nextSibling)m(g);g=a.nodeName;if("BR"===g||"LI"===g)h[s]="\n",t[s<<1]=y++,t[s++<<1|1]=a;break;case 3:case 4:g=a.nodeValue,g.length&&(g=p?g.replace(/\r\n?/g,"\n"):g.replace(/[\t\n\r ]+/g," "),h[s]=g,t[s<<1]=y,y+=g.length,t[s++<<1|1]=a)}}var e=/(?:^|\s)nocode(?:\s|$)/,h=[],y=0,t=[],s=0,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=document.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);m(a);return{a:h.join("").replace(/\n$/,""),c:t}}function B(a,m,e,h){m&&(a={a:m,d:a},e(a),h.push.apply(h,a.e))}function x(a,m){function e(a){for(var l=a.d,p=[l,"pln"],d=0,g=a.a.match(y)||[],r={},n=0,z=g.length;n<z;++n){var f=g[n],b=r[f],o=void 0,c;if(typeof b==="string")c=!1;else{var i=h[f.charAt(0)];if(i)o=f.match(i[1]),b=i[0];else{for(c=0;c<t;++c)if(i=m[c],o=f.match(i[1])){b=i[0];break}o||(b="pln")}if((c=b.length>=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m),l=[],p={},d=0,g=e.length;d<g;++d){var r=e[d],n=r[3];if(n)for(var k=n.length;--k>=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s]