whisper.cat stuff
This commit is contained in:
1
weboasis/text/js/lib/difflib.js
Normal file
1
weboasis/text/js/lib/difflib.js
Normal file
@ -0,0 +1 @@
|
||||
__whitespace={" ":!0,"\t":!0,"\n":!0,"\f":!0,"\r":!0},difflib={defaultJunkFunction:function(t){return __whitespace.hasOwnProperty(t)},stripLinebreaks:function(t){return t.replace(/^[\n\r]*|[\n\r]*$/g,"")},stringAsLines:function(t){for(var i=t.indexOf("\n"),n=t.indexOf("\r"),e=i>-1&&n>-1||n<0?"\n":"\r",s=t.split(e),h=0;h<s.length;h++)s[h]=difflib.stripLinebreaks(s[h]);return s},__reduce:function(t,i,n){if(null!=n)var e=n,s=0;else{if(!i)return null;e=i[0],s=1}for(;s<i.length;s++)e=t(e,i[s]);return e},__ntuplecomp:function(t,i){for(var n=Math.max(t.length,i.length),e=0;e<n;e++){if(t[e]<i[e])return-1;if(t[e]>i[e])return 1}return t.length==i.length?0:t.length<i.length?-1:1},__calculate_ratio:function(t,i){return i?2*t/i:1},__isindict:function(t){return function(i){return t.hasOwnProperty(i)}},__dictget:function(t,i,n){return t.hasOwnProperty(i)?t[i]:n},SequenceMatcher:function(t,i,n){this.set_seqs=function(t,i){this.set_seq1(t),this.set_seq2(i)},this.set_seq1=function(t){t!=this.a&&(this.a=t,this.matching_blocks=this.opcodes=null)},this.set_seq2=function(t){t!=this.b&&(this.b=t,this.matching_blocks=this.opcodes=this.fullbcount=null,this.__chain_b())},this.__chain_b=function(){for(var t=this.b,i=t.length,n=this.b2j={},e={},s=0;s<t.length;s++){var h=t[s];if(n.hasOwnProperty(h)){var r=n[h];i>=200&&100*r.length>i?(e[h]=1,delete n[h]):r.push(s)}else n[h]=[s]}for(var h in e)e.hasOwnProperty(h)&&delete n[h];var l=this.isjunk,a={};if(l){for(var h in e)e.hasOwnProperty(h)&&l(h)&&(a[h]=1,delete e[h]);for(var h in n)n.hasOwnProperty(h)&&l(h)&&(a[h]=1,delete n[h])}this.isbjunk=difflib.__isindict(a),this.isbpopular=difflib.__isindict(e)},this.find_longest_match=function(t,i,n,e){for(var s=this.a,h=this.b,r=this.b2j,l=this.isbjunk,a=t,u=n,o=0,c=null,f={},_=[],b=t;b<i;b++){var g={},p=difflib.__dictget(r,s[b],_);for(var d in p)if(p.hasOwnProperty(d)){if((c=p[d])<n)continue;if(c>=e)break;g[c]=k=difflib.__dictget(f,c-1,0)+1,k>o&&(a=b-k+1,u=c-k+1,o=k)}f=g}for(;a>t&&u>n&&!l(h[u-1])&&s[a-1]==h[u-1];)a--,u--,o++;for(;a+o<i&&u+o<e&&!l(h[u+o])&&s[a+o]==h[u+o];)o++;for(;a>t&&u>n&&l(h[u-1])&&s[a-1]==h[u-1];)a--,u--,o++;for(;a+o<i&&u+o<e&&l(h[u+o])&&s[a+o]==h[u+o];)o++;return[a,u,o]},this.get_matching_blocks=function(){if(null!=this.matching_blocks)return this.matching_blocks;for(var t,i,n,e,s,h,r,l,a,u=this.a.length,o=this.b.length,c=[[0,u,0,o]],f=[];c.length;)t=(s=c.pop())[0],i=s[1],n=s[2],e=s[3],h=(a=this.find_longest_match(t,i,n,e))[0],r=a[1],(l=a[2])&&(f.push(a),t<h&&n<r&&c.push([t,h,n,r]),h+l<i&&r+l<e&&c.push([h+l,i,r+l,e]));f.sort(difflib.__ntuplecomp);var _=j1=k1=block=0,b=[];for(var g in f)f.hasOwnProperty(g)&&(block=f[g],i2=block[0],j2=block[1],k2=block[2],_+k1==i2&&j1+k1==j2?k1+=k2:(k1&&b.push([_,j1,k1]),_=i2,j1=j2,k1=k2));return k1&&b.push([_,j1,k1]),b.push([u,o,0]),this.matching_blocks=b,this.matching_blocks},this.get_opcodes=function(){if(null!=this.opcodes)return this.opcodes;var t,i,n,e,s,h=0,r=0,l=[];this.opcodes=l;var a=this.get_matching_blocks();for(var u in a)a.hasOwnProperty(u)&&(i=(t=a[u])[0],n=t[1],e=t[2],s="",h<i&&r<n?s="replace":h<i?s="delete":r<n&&(s="insert"),s&&l.push([s,h,i,r,n]),h=i+e,r=n+e,e&&l.push(["equal",i,h,n,r]));return l},this.get_grouped_opcodes=function(t){t||(t=3);var i,n,e,s,h,r,l=this.get_opcodes();l||(l=[["equal",0,1,0,1]]),"equal"==l[0][0]&&(n=(i=l[0])[0],e=i[1],s=i[2],h=i[3],r=i[4],l[0]=[n,Math.max(e,s-t),s,Math.max(h,r-t),r]),"equal"==l[l.length-1][0]&&(n=(i=l[l.length-1])[0],e=i[1],s=i[2],h=i[3],r=i[4],l[l.length-1]=[n,e,Math.min(s,e+t),h,Math.min(r,h+t)]);var a=t+t,u=[],o=[];for(var c in l)l.hasOwnProperty(c)&&(n=(i=l[c])[0],e=i[1],s=i[2],h=i[3],r=i[4],"equal"==n&&s-e>a&&(u.push([n,e,Math.min(s,e+t),h,Math.min(r,h+t)]),o.push(u),u=[],e=Math.max(e,s-t),h=Math.max(h,r-t)),u.push([n,e,s,h,r]));return!u||1==u.length&&"equal"==u[0][0]||o.push(u),o},this.ratio=function(){return matches=difflib.__reduce(function(t,i){return t+i[i.length-1]},this.get_matching_blocks(),0),difflib.__calculate_ratio(matches,this.a.length+this.b.length)},this.quick_ratio=function(){var t,i;if(null==this.fullbcount){this.fullbcount=t={};for(var n=0;n<this.b.length;n++)t[i=this.b[n]]=difflib.__dictget(t,i,0)+1}t=this.fullbcount;var e={},s=difflib.__isindict(e),h=numb=0;for(n=0;n<this.a.length;n++)s(i=this.a[n])?numb=e[i]:numb=difflib.__dictget(t,i,0),e[i]=numb-1,numb>0&&h++;return difflib.__calculate_ratio(h,this.a.length+this.b.length)},this.real_quick_ratio=function(){var t=this.a.length,i=this.b.length;return _calculate_ratio(Math.min(t,i),t+i)},this.isjunk=n||difflib.defaultJunkFunction,this.a=this.b=null,this.set_seqs(t,i)}};
|
1
weboasis/text/js/lib/diffview.css
Normal file
1
weboasis/text/js/lib/diffview.css
Normal file
@ -0,0 +1 @@
|
||||
table.diff tbody{font-size:.75rem}table.diff tbody th{width:34px;font-family:"Courier New",Courier,monospace;background:#f3f3f3;font-weight:400;text-align:center}table.diff thead{background:#f3f3f3}table.diff thead th{text-align:left;font-weight:500}table.diff .texttitle{text-align:center}table.diff .empty{background:#DDD}table.diff .skip{background:#EFEFEF}table.diff .insert{background:#b6d7a8}table.diff .replace{background:#ffe599}table.diff .delete{background:#ea9999}.dark table.diff td,.dark table.diff th{border-color:rgba(255,255,255,.05)}.dark table.diff thead{background:#444}.dark table.diff tbody th{background:#444}.dark table.diff .equal{background:#333}.dark table.diff .empty{background:#222}.dark table.diff .insert,.dark table.diff .replace,.dark table.diff .delete{color:#111}
|
1
weboasis/text/js/lib/diffview.js
Normal file
1
weboasis/text/js/lib/diffview.js
Normal file
@ -0,0 +1 @@
|
||||
diffview={buildView:function(e){var t=e.baseTextLines,n=e.newTextLines,d=e.opcodes,a=e.baseTextName?e.baseTextName:"Column A",i=e.newTextName?e.newTextName:"Column B",l=e.contextSize,p=0==e.viewType||1==e.viewType?e.viewType:0;if(null==t)throw"Cannot build diff view; baseTextLines is not defined.";if(null==n)throw"Cannot build diff view; newTextLines is not defined.";if(!d)throw"Canno build diff view; opcodes is not defined.";function h(e,t){var n=document.createElement(e);return n.className=t,n}function c(e,t){var n=document.createElement(e);return n.appendChild(document.createTextNode(t)),n}function r(e,t,n){var d=document.createElement(e);return d.className=t,d.appendChild(document.createTextNode(n)),d}var o=document.createElement("thead"),u=document.createElement("tr");o.appendChild(u),p?(u.appendChild(document.createElement("th")),u.appendChild(document.createElement("th")),u.appendChild(r("th","texttitle",a+" vs. "+i))):(u.appendChild(document.createElement("th")),u.appendChild(r("th","texttitle",a)),u.appendChild(document.createElement("th")),u.appendChild(r("th","texttitle",i))),o=[o];var m,f=[];function s(e,t,n,d,a){return t<n?(e.appendChild(c("th",(t+1).toString())),e.appendChild(r("td",a,d[t].replace(/\t/g," "))),t+1):(e.appendChild(document.createElement("th")),e.appendChild(h("td","empty")),t)}function C(e,t,n,d,a){e.appendChild(c("th",null==t?"":(t+1).toString())),e.appendChild(c("th",null==n?"":(n+1).toString())),e.appendChild(r("td",a,d[null!=t?t:n].replace(/\t/g," ")))}for(var g=0;g<d.length;g++){code=d[g],change=code[0];for(var v=code[1],w=code[2],x=code[3],E=code[4],T=Math.max(w-v,E-x),b=[],N=[],y=0;y<T;y++){if(l&&d.length>1&&(g>0&&y==l||0==g&&0==y)&&"equal"==change){var L=T-(0==g?1:2)*l;if(L>1){if(b.push(u=document.createElement("tr")),v+=L,x+=L,y+=L-1,u.appendChild(c("th","...")),p||u.appendChild(r("td","skip","")),u.appendChild(c("th","...")),u.appendChild(r("td","skip","")),g+1==d.length)break;continue}}b.push(u=document.createElement("tr")),p?"insert"==change?C(u,null,x++,n,change):"replace"==change?(N.push(m=document.createElement("tr")),v<w&&C(u,v++,null,t,"delete"),x<E&&C(m,null,x++,n,"insert")):"delete"==change?C(u,v++,null,t,change):C(u,v++,x++,t,change):(v=s(u,v,w,t,change),x=s(u,x,E,n,change))}for(y=0;y<b.length;y++)f.push(b[y]);for(y=0;y<N.length;y++)f.push(N[y])}for(var g in o.push(u=document.createElement("tbody")),f)f.hasOwnProperty(g)&&u.appendChild(f[g]);for(var g in u=h("table","diff"+(p?" inlinediff":"")),o)o.hasOwnProperty(g)&&u.appendChild(o[g]);return u}};
|
7
weboasis/text/js/lib/justified.js
Normal file
7
weboasis/text/js/lib/justified.js
Normal file
@ -0,0 +1,7 @@
|
||||
/*!
|
||||
* justified <https://github.com/jonschlinkert/justified>
|
||||
*
|
||||
* Copyright (c) 2014-2018, Jon Schlinkert.
|
||||
* Released under the MIT License.
|
||||
*/
|
||||
function repeat(n,e){if("string"!=typeof n)throw new TypeError("expected a string");if(1===e)return n;if(2===e)return n+n;var t=n.length*e;if(cache!==n||"undefined"==typeof cache)cache=n,res="";else if(res.length>=t)return res.substr(0,t);for(;t>res.length&&e>1;)1&e&&(res+=n),e>>=1,n+=n;return res+=n,res=res.substr(0,t),res}function longest(n){if(!Array.isArray(n))throw new TypeError("expected an array");var e=n.length;if(0!==e){var t=n[0];"number"==typeof t&&(t=String(t));for(var r=t.length,a=0;++a<e;){var i=n[a];if(null!=i){"number"==typeof i&&(i=String(i));var o=i.length;"number"==typeof o&&o>r&&(r=o,t=i)}}return t}}function wrap(n,e){if(null==n)return n;var t=(e=e||{}).width||50,r="string"==typeof e.indent?e.indent:" ",a=e.newline||"\n"+r,i="function"==typeof e.escape?e.escape:identity,o=".{1,"+t+"}";!0!==e.cut&&(o+="([\\s]+|$)|[^\\s]+?([\\s]+|$)");var s=new RegExp(o,"g"),f=r+(n.match(s)||[]).map(function(n){return"\n"===n.slice(-1)&&(n=n.slice(0,n.length-1)),i(n)}).join(a);return!0===e.trim&&(f=f.replace(/[ \t]*$/gm,"")),f}function identity(n){return n}var lastRandomIndex=0;function justify(n,e){var t=Object.assign({random:random,width:55},e);lastRandomIndex=0,n=wrap(n,t);for(var r=t.indent?repeat(" ",t.indent):"",a=n.split(/\r?\n/),i=longest(a).length,o=Math.min(t.width,i),s=a.length,f="",u=0;u<s;u++){var l=a[u].trim(),d=u!==s-1||!0===t.justifyLastLine;u===s-1&&"function"==typeof t.justifyLastLine&&(d=t.justifyLastLine(l,o)),d&&(l=toMaxLength(l,o,t)),f+=r+l+"\n"}return f}function toMaxLength(n,e,t){for(var r=e-n.length,a=n.split(" "),i=a.length;r-- >0;)a[t.random(i-2)]+=" ";return a.join(" ").trim()}function random(n){var e=[.14975434898516649,.48920102670502064,.5460856891554375,.843156677246687,.5339584048702419,.6557222579529927,.025277961886063904,.7906919328816282,.39547316726978843,.8046447313481258,.40539968121122616,.3240593946801942,.04700841115323562],t=e[lastRandomIndex%e.length];return lastRandomIndex>1e3?lastRandomIndex=0:lastRandomIndex++,Math.floor(t*(n+1))}
|
5
weboasis/text/js/lib/naturalSort.js
Normal file
5
weboasis/text/js/lib/naturalSort.js
Normal file
@ -0,0 +1,5 @@
|
||||
/*
|
||||
* Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license
|
||||
* Author: Jim Palmer (based on chunking idea from Dave Koelle)
|
||||
*/
|
||||
function naturalSort(e,a){"use strict";var r,t,n=/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,i=/(^[ ]*|[ ]*$)/g,l=/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,p=/^0x[0-9a-f]+$/i,c=/^0/,s=function(e){return naturalSort.insensitive&&(""+e).toLowerCase()||""+e},f=s(e).replace(i,"")||"",u=s(a).replace(i,"")||"",d=f.replace(n,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),o=u.replace(n,"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0"),h=parseInt(f.match(p),16)||1!==d.length&&f.match(l)&&Date.parse(f),w=parseInt(u.match(p),16)||h&&u.match(l)&&Date.parse(u)||null;if(w){if(h<w)return-1;if(h>w)return 1}for(var $=0,m=Math.max(d.length,o.length);$<m;$++){if(r=!(d[$]||"").match(c)&&parseFloat(d[$])||d[$]||0,t=!(o[$]||"").match(c)&&parseFloat(o[$])||o[$]||0,isNaN(r)!==isNaN(t))return isNaN(r)?1:-1;if(typeof r!=typeof t&&(r+="",t+=""),r<t)return-1;if(r>t)return 1}return 0}
|
Reference in New Issue
Block a user