临时文件

This commit is contained in:
dell
2025-02-19 16:05:53 +08:00
parent b915c54c63
commit 4071d8f337
46 changed files with 69286 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,8 @@
/**
* Copyright (c) 2006-2024, JGraph Ltd
* Copyright (c) 2006-2024, draw.io AG
*/
// null'ing of global vars need to be after init.js
window.VSD_CONVERT_URL = null;
window.EMF_CONVERT_URL = null;
window.ICONSEARCH_PATH = null;

View File

@ -0,0 +1,14 @@
/**
* Copyright (c) 2006-2024, JGraph Ltd
* Copyright (c) 2006-2024, draw.io AG
*/
// Overrides of global vars need to be pre-loaded
window.DRAWIO_PUBLIC_BUILD = true;
window.EXPORT_URL = 'REPLACE_WITH_YOUR_IMAGE_SERVER';
window.PLANT_URL = 'REPLACE_WITH_YOUR_PLANTUML_SERVER';
window.DRAWIO_BASE_URL = null; // Replace with path to base of deployment, e.g. https://www.example.com/folder
window.DRAWIO_VIEWER_URL = null; // Replace your path to the viewer js, e.g. https://www.example.com/js/viewer.min.js
window.DRAWIO_LIGHTBOX_URL = null; // Replace with your lightbox URL, eg. https://www.example.com
window.DRAW_MATH_URL = 'math/es5';
window.DRAWIO_CONFIG = null; // Replace with your custom draw.io configurations. For more details, https://www.drawio.com/doc/faq/configure-diagram-editor
urlParams['sync'] = 'manual';

14640
HT.Cloud.Web/wwwroot/lib/drawio/app.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,67 @@
try
{
function write(text)
{
document.body.appendChild(document.createTextNode(text));
};
function writeln(text)
{
write(text);
document.body.appendChild(document.createElement('br'));
};
write('Clearing Cached version ' + EditorUi.VERSION + '...');
navigator.serviceWorker.getRegistrations().then(function(registrations)
{
if (registrations != null && registrations.length > 0)
{
for (var i = 0; i < registrations.length; i++)
{
registrations[i].unregister();
}
writeln('Done');
}
else
{
writeln('OK');
}
var link = document.createElement('a');
link.style.marginRight = '6px';
link.setAttribute('href', 'javascript:window.location.reload();');
link.appendChild(document.createTextNode('Reload'));
document.body.appendChild(link);
if ((/test\.draw\.io$/.test(window.location.hostname)) ||
(/preprod\.diagrams\.net$/.test(window.location.hostname)) ||
(/app\.diagrams\.net$/.test(window.location.hostname)))
{
link = link.cloneNode(false);
link.setAttribute('href', './');
link.appendChild(document.createTextNode('Start App'));
document.body.appendChild(link);
}
});
// Clears corresponding domain of current domain
var iframe = document.createElement('iframe');
iframe.style.display = 'none';
if (window.location.hostname == 'ac.draw.io')
{
iframe.src = 'https://clear.diagrams.net';
}
else
{
iframe.src = 'https://clear.draw.io';
}
document.body.appendChild(iframe);
}
catch (e)
{
write('Error: ' + e.message);
}

View File

@ -0,0 +1,6 @@
# aes.min.js
Source: rollups/aes.js from https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/crypto-js/CryptoJS%20v3.1.2.zip
See https://code.google.com/archive/p/crypto-js/downloads
Note: This is not affected by https://github.com/jgraph/drawio-dev/security/dependabot/148 as the code does not use Math.random().

View File

@ -0,0 +1,35 @@
/*
CryptoJS v3.1.2
code.google.com/p/crypto-js
(c) 2009-2013 by Jeff Mott. All rights reserved.
code.google.com/p/crypto-js/wiki/License
*/
var CryptoJS=CryptoJS||function(u,p){var d={},l=d.lib={},s=function(){},t=l.Base={extend:function(a){s.prototype=this;var c=new s;a&&c.mixIn(a);c.hasOwnProperty("init")||(c.init=function(){c.$super.init.apply(this,arguments)});c.init.prototype=c;c.$super=this;return c},create:function(){var a=this.extend();a.init.apply(a,arguments);return a},init:function(){},mixIn:function(a){for(var c in a)a.hasOwnProperty(c)&&(this[c]=a[c]);a.hasOwnProperty("toString")&&(this.toString=a.toString)},clone:function(){return this.init.prototype.extend(this)}},
r=l.WordArray=t.extend({init:function(a,c){a=this.words=a||[];this.sigBytes=c!=p?c:4*a.length},toString:function(a){return(a||v).stringify(this)},concat:function(a){var c=this.words,e=a.words,j=this.sigBytes;a=a.sigBytes;this.clamp();if(j%4)for(var k=0;k<a;k++)c[j+k>>>2]|=(e[k>>>2]>>>24-8*(k%4)&255)<<24-8*((j+k)%4);else if(65535<e.length)for(k=0;k<a;k+=4)c[j+k>>>2]=e[k>>>2];else c.push.apply(c,e);this.sigBytes+=a;return this},clamp:function(){var a=this.words,c=this.sigBytes;a[c>>>2]&=4294967295<<
32-8*(c%4);a.length=u.ceil(c/4)},clone:function(){var a=t.clone.call(this);a.words=this.words.slice(0);return a},random:function(a){for(var c=[],e=0;e<a;e+=4)c.push(4294967296*u.random()|0);return new r.init(c,a)}}),w=d.enc={},v=w.Hex={stringify:function(a){var c=a.words;a=a.sigBytes;for(var e=[],j=0;j<a;j++){var k=c[j>>>2]>>>24-8*(j%4)&255;e.push((k>>>4).toString(16));e.push((k&15).toString(16))}return e.join("")},parse:function(a){for(var c=a.length,e=[],j=0;j<c;j+=2)e[j>>>3]|=parseInt(a.substr(j,
2),16)<<24-4*(j%8);return new r.init(e,c/2)}},b=w.Latin1={stringify:function(a){var c=a.words;a=a.sigBytes;for(var e=[],j=0;j<a;j++)e.push(String.fromCharCode(c[j>>>2]>>>24-8*(j%4)&255));return e.join("")},parse:function(a){for(var c=a.length,e=[],j=0;j<c;j++)e[j>>>2]|=(a.charCodeAt(j)&255)<<24-8*(j%4);return new r.init(e,c)}},x=w.Utf8={stringify:function(a){try{return decodeURIComponent(escape(b.stringify(a)))}catch(c){throw Error("Malformed UTF-8 data");}},parse:function(a){return b.parse(unescape(encodeURIComponent(a)))}},
q=l.BufferedBlockAlgorithm=t.extend({reset:function(){this._data=new r.init;this._nDataBytes=0},_append:function(a){"string"==typeof a&&(a=x.parse(a));this._data.concat(a);this._nDataBytes+=a.sigBytes},_process:function(a){var c=this._data,e=c.words,j=c.sigBytes,k=this.blockSize,b=j/(4*k),b=a?u.ceil(b):u.max((b|0)-this._minBufferSize,0);a=b*k;j=u.min(4*a,j);if(a){for(var q=0;q<a;q+=k)this._doProcessBlock(e,q);q=e.splice(0,a);c.sigBytes-=j}return new r.init(q,j)},clone:function(){var a=t.clone.call(this);
a._data=this._data.clone();return a},_minBufferSize:0});l.Hasher=q.extend({cfg:t.extend(),init:function(a){this.cfg=this.cfg.extend(a);this.reset()},reset:function(){q.reset.call(this);this._doReset()},update:function(a){this._append(a);this._process();return this},finalize:function(a){a&&this._append(a);return this._doFinalize()},blockSize:16,_createHelper:function(a){return function(b,e){return(new a.init(e)).finalize(b)}},_createHmacHelper:function(a){return function(b,e){return(new n.HMAC.init(a,
e)).finalize(b)}}});var n=d.algo={};return d}(Math);
(function(){var u=CryptoJS,p=u.lib.WordArray;u.enc.Base64={stringify:function(d){var l=d.words,p=d.sigBytes,t=this._map;d.clamp();d=[];for(var r=0;r<p;r+=3)for(var w=(l[r>>>2]>>>24-8*(r%4)&255)<<16|(l[r+1>>>2]>>>24-8*((r+1)%4)&255)<<8|l[r+2>>>2]>>>24-8*((r+2)%4)&255,v=0;4>v&&r+0.75*v<p;v++)d.push(t.charAt(w>>>6*(3-v)&63));if(l=t.charAt(64))for(;d.length%4;)d.push(l);return d.join("")},parse:function(d){var l=d.length,s=this._map,t=s.charAt(64);t&&(t=d.indexOf(t),-1!=t&&(l=t));for(var t=[],r=0,w=0;w<
l;w++)if(w%4){var v=s.indexOf(d.charAt(w-1))<<2*(w%4),b=s.indexOf(d.charAt(w))>>>6-2*(w%4);t[r>>>2]|=(v|b)<<24-8*(r%4);r++}return p.create(t,r)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}})();
(function(u){function p(b,n,a,c,e,j,k){b=b+(n&a|~n&c)+e+k;return(b<<j|b>>>32-j)+n}function d(b,n,a,c,e,j,k){b=b+(n&c|a&~c)+e+k;return(b<<j|b>>>32-j)+n}function l(b,n,a,c,e,j,k){b=b+(n^a^c)+e+k;return(b<<j|b>>>32-j)+n}function s(b,n,a,c,e,j,k){b=b+(a^(n|~c))+e+k;return(b<<j|b>>>32-j)+n}for(var t=CryptoJS,r=t.lib,w=r.WordArray,v=r.Hasher,r=t.algo,b=[],x=0;64>x;x++)b[x]=4294967296*u.abs(u.sin(x+1))|0;r=r.MD5=v.extend({_doReset:function(){this._hash=new w.init([1732584193,4023233417,2562383102,271733878])},
_doProcessBlock:function(q,n){for(var a=0;16>a;a++){var c=n+a,e=q[c];q[c]=(e<<8|e>>>24)&16711935|(e<<24|e>>>8)&4278255360}var a=this._hash.words,c=q[n+0],e=q[n+1],j=q[n+2],k=q[n+3],z=q[n+4],r=q[n+5],t=q[n+6],w=q[n+7],v=q[n+8],A=q[n+9],B=q[n+10],C=q[n+11],u=q[n+12],D=q[n+13],E=q[n+14],x=q[n+15],f=a[0],m=a[1],g=a[2],h=a[3],f=p(f,m,g,h,c,7,b[0]),h=p(h,f,m,g,e,12,b[1]),g=p(g,h,f,m,j,17,b[2]),m=p(m,g,h,f,k,22,b[3]),f=p(f,m,g,h,z,7,b[4]),h=p(h,f,m,g,r,12,b[5]),g=p(g,h,f,m,t,17,b[6]),m=p(m,g,h,f,w,22,b[7]),
f=p(f,m,g,h,v,7,b[8]),h=p(h,f,m,g,A,12,b[9]),g=p(g,h,f,m,B,17,b[10]),m=p(m,g,h,f,C,22,b[11]),f=p(f,m,g,h,u,7,b[12]),h=p(h,f,m,g,D,12,b[13]),g=p(g,h,f,m,E,17,b[14]),m=p(m,g,h,f,x,22,b[15]),f=d(f,m,g,h,e,5,b[16]),h=d(h,f,m,g,t,9,b[17]),g=d(g,h,f,m,C,14,b[18]),m=d(m,g,h,f,c,20,b[19]),f=d(f,m,g,h,r,5,b[20]),h=d(h,f,m,g,B,9,b[21]),g=d(g,h,f,m,x,14,b[22]),m=d(m,g,h,f,z,20,b[23]),f=d(f,m,g,h,A,5,b[24]),h=d(h,f,m,g,E,9,b[25]),g=d(g,h,f,m,k,14,b[26]),m=d(m,g,h,f,v,20,b[27]),f=d(f,m,g,h,D,5,b[28]),h=d(h,f,
m,g,j,9,b[29]),g=d(g,h,f,m,w,14,b[30]),m=d(m,g,h,f,u,20,b[31]),f=l(f,m,g,h,r,4,b[32]),h=l(h,f,m,g,v,11,b[33]),g=l(g,h,f,m,C,16,b[34]),m=l(m,g,h,f,E,23,b[35]),f=l(f,m,g,h,e,4,b[36]),h=l(h,f,m,g,z,11,b[37]),g=l(g,h,f,m,w,16,b[38]),m=l(m,g,h,f,B,23,b[39]),f=l(f,m,g,h,D,4,b[40]),h=l(h,f,m,g,c,11,b[41]),g=l(g,h,f,m,k,16,b[42]),m=l(m,g,h,f,t,23,b[43]),f=l(f,m,g,h,A,4,b[44]),h=l(h,f,m,g,u,11,b[45]),g=l(g,h,f,m,x,16,b[46]),m=l(m,g,h,f,j,23,b[47]),f=s(f,m,g,h,c,6,b[48]),h=s(h,f,m,g,w,10,b[49]),g=s(g,h,f,m,
E,15,b[50]),m=s(m,g,h,f,r,21,b[51]),f=s(f,m,g,h,u,6,b[52]),h=s(h,f,m,g,k,10,b[53]),g=s(g,h,f,m,B,15,b[54]),m=s(m,g,h,f,e,21,b[55]),f=s(f,m,g,h,v,6,b[56]),h=s(h,f,m,g,x,10,b[57]),g=s(g,h,f,m,t,15,b[58]),m=s(m,g,h,f,D,21,b[59]),f=s(f,m,g,h,z,6,b[60]),h=s(h,f,m,g,C,10,b[61]),g=s(g,h,f,m,j,15,b[62]),m=s(m,g,h,f,A,21,b[63]);a[0]=a[0]+f|0;a[1]=a[1]+m|0;a[2]=a[2]+g|0;a[3]=a[3]+h|0},_doFinalize:function(){var b=this._data,n=b.words,a=8*this._nDataBytes,c=8*b.sigBytes;n[c>>>5]|=128<<24-c%32;var e=u.floor(a/
4294967296);n[(c+64>>>9<<4)+15]=(e<<8|e>>>24)&16711935|(e<<24|e>>>8)&4278255360;n[(c+64>>>9<<4)+14]=(a<<8|a>>>24)&16711935|(a<<24|a>>>8)&4278255360;b.sigBytes=4*(n.length+1);this._process();b=this._hash;n=b.words;for(a=0;4>a;a++)c=n[a],n[a]=(c<<8|c>>>24)&16711935|(c<<24|c>>>8)&4278255360;return b},clone:function(){var b=v.clone.call(this);b._hash=this._hash.clone();return b}});t.MD5=v._createHelper(r);t.HmacMD5=v._createHmacHelper(r)})(Math);
(function(){var u=CryptoJS,p=u.lib,d=p.Base,l=p.WordArray,p=u.algo,s=p.EvpKDF=d.extend({cfg:d.extend({keySize:4,hasher:p.MD5,iterations:1}),init:function(d){this.cfg=this.cfg.extend(d)},compute:function(d,r){for(var p=this.cfg,s=p.hasher.create(),b=l.create(),u=b.words,q=p.keySize,p=p.iterations;u.length<q;){n&&s.update(n);var n=s.update(d).finalize(r);s.reset();for(var a=1;a<p;a++)n=s.finalize(n),s.reset();b.concat(n)}b.sigBytes=4*q;return b}});u.EvpKDF=function(d,l,p){return s.create(p).compute(d,
l)}})();
CryptoJS.lib.Cipher||function(u){var p=CryptoJS,d=p.lib,l=d.Base,s=d.WordArray,t=d.BufferedBlockAlgorithm,r=p.enc.Base64,w=p.algo.EvpKDF,v=d.Cipher=t.extend({cfg:l.extend(),createEncryptor:function(e,a){return this.create(this._ENC_XFORM_MODE,e,a)},createDecryptor:function(e,a){return this.create(this._DEC_XFORM_MODE,e,a)},init:function(e,a,b){this.cfg=this.cfg.extend(b);this._xformMode=e;this._key=a;this.reset()},reset:function(){t.reset.call(this);this._doReset()},process:function(e){this._append(e);return this._process()},
finalize:function(e){e&&this._append(e);return this._doFinalize()},keySize:4,ivSize:4,_ENC_XFORM_MODE:1,_DEC_XFORM_MODE:2,_createHelper:function(e){return{encrypt:function(b,k,d){return("string"==typeof k?c:a).encrypt(e,b,k,d)},decrypt:function(b,k,d){return("string"==typeof k?c:a).decrypt(e,b,k,d)}}}});d.StreamCipher=v.extend({_doFinalize:function(){return this._process(!0)},blockSize:1});var b=p.mode={},x=function(e,a,b){var c=this._iv;c?this._iv=u:c=this._prevBlock;for(var d=0;d<b;d++)e[a+d]^=
c[d]},q=(d.BlockCipherMode=l.extend({createEncryptor:function(e,a){return this.Encryptor.create(e,a)},createDecryptor:function(e,a){return this.Decryptor.create(e,a)},init:function(e,a){this._cipher=e;this._iv=a}})).extend();q.Encryptor=q.extend({processBlock:function(e,a){var b=this._cipher,c=b.blockSize;x.call(this,e,a,c);b.encryptBlock(e,a);this._prevBlock=e.slice(a,a+c)}});q.Decryptor=q.extend({processBlock:function(e,a){var b=this._cipher,c=b.blockSize,d=e.slice(a,a+c);b.decryptBlock(e,a);x.call(this,
e,a,c);this._prevBlock=d}});b=b.CBC=q;q=(p.pad={}).Pkcs7={pad:function(a,b){for(var c=4*b,c=c-a.sigBytes%c,d=c<<24|c<<16|c<<8|c,l=[],n=0;n<c;n+=4)l.push(d);c=s.create(l,c);a.concat(c)},unpad:function(a){a.sigBytes-=a.words[a.sigBytes-1>>>2]&255}};d.BlockCipher=v.extend({cfg:v.cfg.extend({mode:b,padding:q}),reset:function(){v.reset.call(this);var a=this.cfg,b=a.iv,a=a.mode;if(this._xformMode==this._ENC_XFORM_MODE)var c=a.createEncryptor;else c=a.createDecryptor,this._minBufferSize=1;this._mode=c.call(a,
this,b&&b.words)},_doProcessBlock:function(a,b){this._mode.processBlock(a,b)},_doFinalize:function(){var a=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){a.pad(this._data,this.blockSize);var b=this._process(!0)}else b=this._process(!0),a.unpad(b);return b},blockSize:4});var n=d.CipherParams=l.extend({init:function(a){this.mixIn(a)},toString:function(a){return(a||this.formatter).stringify(this)}}),b=(p.format={}).OpenSSL={stringify:function(a){var b=a.ciphertext;a=a.salt;return(a?s.create([1398893684,
1701076831]).concat(a).concat(b):b).toString(r)},parse:function(a){a=r.parse(a);var b=a.words;if(1398893684==b[0]&&1701076831==b[1]){var c=s.create(b.slice(2,4));b.splice(0,4);a.sigBytes-=16}return n.create({ciphertext:a,salt:c})}},a=d.SerializableCipher=l.extend({cfg:l.extend({format:b}),encrypt:function(a,b,c,d){d=this.cfg.extend(d);var l=a.createEncryptor(c,d);b=l.finalize(b);l=l.cfg;return n.create({ciphertext:b,key:c,iv:l.iv,algorithm:a,mode:l.mode,padding:l.padding,blockSize:a.blockSize,formatter:d.format})},
decrypt:function(a,b,c,d){d=this.cfg.extend(d);b=this._parse(b,d.format);return a.createDecryptor(c,d).finalize(b.ciphertext)},_parse:function(a,b){return"string"==typeof a?b.parse(a,this):a}}),p=(p.kdf={}).OpenSSL={execute:function(a,b,c,d){d||(d=s.random(8));a=w.create({keySize:b+c}).compute(a,d);c=s.create(a.words.slice(b),4*c);a.sigBytes=4*b;return n.create({key:a,iv:c,salt:d})}},c=d.PasswordBasedCipher=a.extend({cfg:a.cfg.extend({kdf:p}),encrypt:function(b,c,d,l){l=this.cfg.extend(l);d=l.kdf.execute(d,
b.keySize,b.ivSize);l.iv=d.iv;b=a.encrypt.call(this,b,c,d.key,l);b.mixIn(d);return b},decrypt:function(b,c,d,l){l=this.cfg.extend(l);c=this._parse(c,l.format);d=l.kdf.execute(d,b.keySize,b.ivSize,c.salt);l.iv=d.iv;return a.decrypt.call(this,b,c,d.key,l)}})}();
(function(){for(var u=CryptoJS,p=u.lib.BlockCipher,d=u.algo,l=[],s=[],t=[],r=[],w=[],v=[],b=[],x=[],q=[],n=[],a=[],c=0;256>c;c++)a[c]=128>c?c<<1:c<<1^283;for(var e=0,j=0,c=0;256>c;c++){var k=j^j<<1^j<<2^j<<3^j<<4,k=k>>>8^k&255^99;l[e]=k;s[k]=e;var z=a[e],F=a[z],G=a[F],y=257*a[k]^16843008*k;t[e]=y<<24|y>>>8;r[e]=y<<16|y>>>16;w[e]=y<<8|y>>>24;v[e]=y;y=16843009*G^65537*F^257*z^16843008*e;b[k]=y<<24|y>>>8;x[k]=y<<16|y>>>16;q[k]=y<<8|y>>>24;n[k]=y;e?(e=z^a[a[a[G^z]]],j^=a[a[j]]):e=j=1}var H=[0,1,2,4,8,
16,32,64,128,27,54],d=d.AES=p.extend({_doReset:function(){for(var a=this._key,c=a.words,d=a.sigBytes/4,a=4*((this._nRounds=d+6)+1),e=this._keySchedule=[],j=0;j<a;j++)if(j<d)e[j]=c[j];else{var k=e[j-1];j%d?6<d&&4==j%d&&(k=l[k>>>24]<<24|l[k>>>16&255]<<16|l[k>>>8&255]<<8|l[k&255]):(k=k<<8|k>>>24,k=l[k>>>24]<<24|l[k>>>16&255]<<16|l[k>>>8&255]<<8|l[k&255],k^=H[j/d|0]<<24);e[j]=e[j-d]^k}c=this._invKeySchedule=[];for(d=0;d<a;d++)j=a-d,k=d%4?e[j]:e[j-4],c[d]=4>d||4>=j?k:b[l[k>>>24]]^x[l[k>>>16&255]]^q[l[k>>>
8&255]]^n[l[k&255]]},encryptBlock:function(a,b){this._doCryptBlock(a,b,this._keySchedule,t,r,w,v,l)},decryptBlock:function(a,c){var d=a[c+1];a[c+1]=a[c+3];a[c+3]=d;this._doCryptBlock(a,c,this._invKeySchedule,b,x,q,n,s);d=a[c+1];a[c+1]=a[c+3];a[c+3]=d},_doCryptBlock:function(a,b,c,d,e,j,l,f){for(var m=this._nRounds,g=a[b]^c[0],h=a[b+1]^c[1],k=a[b+2]^c[2],n=a[b+3]^c[3],p=4,r=1;r<m;r++)var q=d[g>>>24]^e[h>>>16&255]^j[k>>>8&255]^l[n&255]^c[p++],s=d[h>>>24]^e[k>>>16&255]^j[n>>>8&255]^l[g&255]^c[p++],t=
d[k>>>24]^e[n>>>16&255]^j[g>>>8&255]^l[h&255]^c[p++],n=d[n>>>24]^e[g>>>16&255]^j[h>>>8&255]^l[k&255]^c[p++],g=q,h=s,k=t;q=(f[g>>>24]<<24|f[h>>>16&255]<<16|f[k>>>8&255]<<8|f[n&255])^c[p++];s=(f[h>>>24]<<24|f[k>>>16&255]<<16|f[n>>>8&255]<<8|f[g&255])^c[p++];t=(f[k>>>24]<<24|f[n>>>16&255]<<16|f[g>>>8&255]<<8|f[h&255])^c[p++];n=(f[n>>>24]<<24|f[g>>>16&255]<<16|f[h>>>8&255]<<8|f[k&255])^c[p++];a[b]=q;a[b+1]=s;a[b+2]=t;a[b+3]=n},keySize:8});u.AES=p._createHelper(d)})();

View File

@ -0,0 +1,4 @@
# Updating (with IE 11 compatibility)
Copy https://github.com/nodeca/pako/blob/master/dist/pako.es5.min.js to
src/main/webapp/js/deflate/pako.min.js in this repository

View File

@ -0,0 +1,151 @@
/**
*
* Base64 encode / decode
* http://www.webtoolkit.info/
*
**/
var Base64 = {
// private property
_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
// public method for encoding
encode : function (input, binary) {
binary = (binary != null) ? binary : false;
var output = "";
var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
var i = 0;
if (!binary)
{
input = Base64._utf8_encode(input);
}
while (i < input.length) {
chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output +
this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);
}
return output;
},
// public method for decoding
decode : function (input, binary) {
binary = (binary != null) ? binary : false;
var output = "";
var chr1, chr2, chr3;
var enc1, enc2, enc3, enc4;
var i = 0;
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
while (i < input.length) {
enc1 = this._keyStr.indexOf(input.charAt(i++));
enc2 = this._keyStr.indexOf(input.charAt(i++));
enc3 = this._keyStr.indexOf(input.charAt(i++));
enc4 = this._keyStr.indexOf(input.charAt(i++));
chr1 = (enc1 << 2) | (enc2 >> 4);
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
chr3 = ((enc3 & 3) << 6) | enc4;
output = output + String.fromCharCode(chr1);
if (enc3 != 64) {
output = output + String.fromCharCode(chr2);
}
if (enc4 != 64) {
output = output + String.fromCharCode(chr3);
}
}
if (!binary)
{
output = Base64._utf8_decode(output);
}
return output;
},
// private method for UTF-8 encoding
_utf8_encode : function (string) {
string = string.replace(/\r\n/g,"\n");
var utftext = "";
for (var n = 0; n < string.length; n++) {
var c = string.charCodeAt(n);
if (c < 128) {
utftext += String.fromCharCode(c);
}
else if((c > 127) && (c < 2048)) {
utftext += String.fromCharCode((c >> 6) | 192);
utftext += String.fromCharCode((c & 63) | 128);
}
else {
utftext += String.fromCharCode((c >> 12) | 224);
utftext += String.fromCharCode(((c >> 6) & 63) | 128);
utftext += String.fromCharCode((c & 63) | 128);
}
}
return utftext;
},
// private method for UTF-8 decoding
_utf8_decode : function (utftext) {
var string = "";
var i = 0;
var c = c1 = c2 = 0;
while ( i < utftext.length ) {
c = utftext.charCodeAt(i);
if (c < 128) {
string += String.fromCharCode(c);
i++;
}
else if((c > 191) && (c < 224)) {
c2 = utftext.charCodeAt(i+1);
string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
i += 2;
}
else {
c2 = utftext.charCodeAt(i+1);
c3 = utftext.charCodeAt(i+2);
string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
i += 3;
}
}
return string;
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,28 @@
// Copyright (c) 2006-2020, JGraph Ltd
/**
*
*/
DesktopLibrary = function(ui, data, fileObj)
{
LocalLibrary.call(this, ui, data, fileObj.name);
this.fileObj = fileObj;
};
//Extends LocalLibrary
mxUtils.extend(DesktopLibrary, LocalLibrary);
/**
*
*/
DesktopLibrary.prototype.getHash = function()
{
return 'S' + encodeURIComponent(this.fileObj.path);
};
/**
*
*/
DesktopLibrary.prototype.save = function(revision, success, error)
{
LocalFile.prototype.saveFile.apply(this, arguments);
};

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,843 @@
(function(stylesheet, stencils)
{
// Callbacks:
// mxClientOnLoad is called after the script is loaded with the stylesheet and the function to create a
// graph (wich takes the container as an argument and returns the graph instance that was created).
// mxClientOnCreate is called when a graph has been created with the graph.
mxStencilRegistry.dynamicLoading = false;
// Adds CSS for tooltips
try
{
var style = document.createElement('style')
style.type = 'text/css'
style.innerHTML = ['div.mxTooltip {',
'-webkit-box-shadow: 3px 3px 12px #C0C0C0;',
'-moz-box-shadow: 3px 3px 12px #C0C0C0;',
'box-shadow: 3px 3px 12px #C0C0C0;',
'background: #FFFFCC;',
'border-style: solid;',
'border-width: 1px;',
'border-color: black;',
'font-family: Arial;',
'font-size: 8pt;',
'position: absolute;',
'cursor: default;',
'padding: 4px;',
'color: black;}'].join('\n');
document.getElementsByTagName('head')[0].appendChild(style)
}
catch (e)
{
// ignore
}
var mathJaxLoading = typeof MathJax !== 'undefined' && typeof MathJax.typeset === 'function';
var mathJaxQueue = [];
function renderMath(nodes)
{
try
{
MathJax.typesetClear(nodes);
MathJax.typeset(nodes);
}
catch (e)
{
MathJax.typesetClear(nodes);
if (e.retry != null)
{
e.retry.then(function()
{
MathJax.typesetPromise(nodes);
});
}
else if (window.console != null)
{
console.log('Error in MathJax: ' + e.toString());
}
}
};
function loadMathJax()
{
// Uses existing configuration if MathJax already in page
if (!mathJaxLoading)
{
mathJaxLoading = true;
window.MathJax =
{
options:
{
skipHtmlTags: {'[+]': ['text']}
},
loader:
{
load: [(urlParams['math-output'] == 'html') ?
'output/chtml' : 'output/svg', 'input/tex',
'input/asciimath', 'ui/safe']
},
startup:
{
pageReady: function()
{
renderMath(mathJaxQueue);
}
}
};
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = 'https://app.diagrams.net/math/es5/startup.js';
document.getElementsByTagName('head')[0].appendChild(script);
}
};
function addMathJaxGraph(graph)
{
// Initial rendering when MathJax finished loading
if (typeof MathJax !== 'undefined' && typeof MathJax.typeset === 'function')
{
renderMath([graph.container]);
}
else
{
mathJaxQueue.push(graph.container);
}
};
// Handles relative images
mxGraph.prototype.getImageFromBundles = function(key)
{
if (key != null)
{
if (key.substring(0, 7) != 'http://' && key.substring(0, 8) != 'https://' && key.substring(0, 10) != 'data:image')
{
if (key.charAt(0) == '/')
{
key = key.substring(1, key.length);
}
key = 'https://app.diagrams.net/' + key;
}
return key;
}
return null;
};
if (stencils != null)
{
for (var i = 0; i < stencils.length; i++)
{
var xmlDoc = mxUtils.parseXml(stencils[i]);
mxStencilRegistry.parseStencilSet(xmlDoc.documentElement);
}
}
// Panning for touch devices
if (mxClient.IS_TOUCH)
{
mxPanningHandler.prototype.isPanningTrigger = function(me)
{
return true;
};
}
(function()
{
function initGraph(container)
{
try
{
var child = container.firstChild;
while (child != null && child.nodeType != mxConstants.NODETYPE_ELEMENT)
{
child = child.nextSibling;
}
var xml = mxUtils.trim(child.innerHTML);
container.innerText = '';
// Instance needed for decompress helper function
var graph = new Graph(container);
if (xml.substring(0, 4) == '&lt;')
{
xml = xml.replace(/&lt;/g, '<').replace(/&gt;/g, '>').
replace(/&amp;gt;/g, '&gt;').replace(/&amp;lt;/g, '&lt;').
replace(/&amp;quot;/g, '&quot;').replace(/&#xa;/g, '\n');
}
else if (xml.substring(0, 3) == '%3C')
{
xml = decodeURIComponent(xml);
}
else
{
xml = Graph.decompress(xml);
}
var xmlDocument = mxUtils.parseXml(xml);
var configNode = null;
var diagrams = null;
if (xmlDocument.documentElement != null && xmlDocument.documentElement.nodeName == 'mxfile')
{
diagrams = xmlDocument.documentElement.getElementsByTagName('diagram');
configNode = xmlDocument.documentElement;
if (diagrams.length > 0)
{
xml = mxUtils.getTextContent(diagrams[0]);
xml = Graph.decompress(xml);
xmlDocument = mxUtils.parseXml(xml);
}
}
if (xmlDocument.documentElement != null && xmlDocument.documentElement.nodeName == 'mxGraphModel')
{
var decoder = new mxCodec(xmlDocument);
var node = xmlDocument.documentElement;
if (configNode == null)
{
configNode = node;
}
graph.resetViewOnRootChange = false;
graph.setEnabled(false);
if (diagrams != null && diagrams.length > 0)
{
/**
* Adds placeholder for %page% and %pagenumber%
*/
var graphGetGlobalVariable = graph.getGlobalVariable;
graph.getGlobalVariable = function(name)
{
if (name == 'page')
{
return diagrams[0].getAttribute('name') || 'Page-1';
}
else if (name == 'pagenumber')
{
return 1;
}
else if (name == 'pagecount')
{
return diagrams.length;
}
return graphGetGlobalVariable.apply(this, arguments);
};
}
graph.foldingEnabled = configNode.getAttribute('nav') == '1';
graph.cellRenderer.forceControlClickHandler = graph.foldingEnabled;
var tooltips = configNode.getAttribute('tooltips');
if (tooltips != '0')
{
graph.setTooltips(true);
}
else
{
graph.setTooltips(false);
}
// Loads the stylesheet
if (stylesheet != null)
{
var xmlDoc = mxUtils.parseXml(stylesheet);
var dec = new mxCodec(xmlDoc);
dec.decode(xmlDoc.documentElement, graph.getStylesheet());
}
var math = configNode.getAttribute('math');
if (math == '1')
{
loadMathJax();
}
// Enables panning with left mouse button
var pan = configNode.getAttribute('pan');
if (pan != '0')
{
graph.panningHandler.useLeftButtonForPanning = true;
graph.panningHandler.ignoreCell = true;
container.style.cursor = 'move';
graph.setPanning(true);
}
else
{
container.style.cursor = 'default';
}
var resize = configNode.getAttribute('resize');
var border = Number(configNode.getAttribute('border') || 0);
graph.border = border;
var fit = configNode.getAttribute('fit');
if ((container.style.width != '100%' && fit != '1' && resize != '0') ||
(container.style.width == '' && container.style.height == ''))
{
graph.resizeContainer = true;
graph.centerZoom = false;
}
else
{
// Updates the container height for autosize width
if (resize != '0' && container.style.width == '100%' && container.style.height == '')
{
graph.resizeContainer = true;
graph.centerZoom = false;
graph.doResizeContainer = function(width, height)
{
// Fixes container size for different box models
if (mxClient.IS_IE)
{
if (document.documentMode >= 9)
{
width += 3;
height += 5;
}
else
{
width += 1;
height += 1;
}
}
else
{
height += 1;
}
if (this.maximumContainerSize != null)
{
width = Math.min(this.maximumContainerSize.width, width);
height = Math.min(this.maximumContainerSize.height, height);
}
this.container.style.height = Math.ceil(height + 18) + 'px';
};
}
else
{
graph.centerZoom = true;
}
}
// Adds handling for hyperlinks, tooltips
var links = configNode.getAttribute('links');
var hl = configNode.getAttribute('highlight');
if (links != '0' || tooltips != '0')
{
var cursor = container.style.cursor;
var tol = graph.getTolerance();
graph.addMouseListener(
{
currentState: null,
currentLink: null,
highlight: (hl != null && hl != '' && hl != mxConstants.NONE) ?
new mxCellHighlight(graph, hl, 2) : null,
startX: 0,
startY: 0,
mouseDown: function(sender, me)
{
this.startX = me.getGraphX();
this.startY = me.getGraphY();
},
mouseMove: function(sender, me)
{
if (graph.isMouseDown)
{
if (this.currentLink != null)
{
var dx = Math.abs(this.startX - me.getGraphX());
var dy = Math.abs(this.startY - me.getGraphY());
if (dx > tol || dy > tol)
{
this.clear();
}
}
}
else
{
if (this.currentState != null && (me.getState() == this.currentState || me.getState() == null) &&
graph.intersects(this.currentState, me.getGraphX(), me.getGraphY()))
{
return;
}
var tmp = graph.view.getState(me.getCell());
if (tmp != this.currentState)
{
if (this.currentState != null)
{
this.clear();
}
this.currentState = tmp;
if (this.currentState != null)
{
this.activate(this.currentState);
}
}
}
},
mouseUp: function(sender, me)
{
var tmp = this.currentLink;
this.clear();
if (tmp != null)
{
if (tmp.charAt(0) == '#')
{
window.location.hash = tmp;
}
else
{
window.open(tmp);
}
}
},
activate: function(state)
{
this.currentLink = graph.getLinkForCell(state.cell);
if (this.currentLink != null)
{
container.style.cursor = 'pointer';
if (this.highlight != null)
{
this.highlight.highlight(state);
}
}
},
clear: function()
{
container.style.cursor = cursor;
this.currentState = null;
this.currentLink = null;
if (this.highlight != null)
{
this.highlight.hide();
}
}
});
}
var x0 = Number(configNode.getAttribute('x0') || 0);
var y0 = Number(configNode.getAttribute('y0') || 0);
graph.view.translate.x = -x0 + border;
graph.view.translate.y = -y0 + border;
function graphAdded(node)
{
var img = node.getAttribute('backgroundImage');
if (img != null)
{
img = JSON.parse(img);
graph.setBackgroundImage(new mxImage(img.src, img.width, img.height));
graph.view.validateBackgroundImage();
}
if (fit != '0')
{
graph.fit(border);
}
if (math == '1')
{
addMathJaxGraph(graph);
}
// Keeps hashtag links on same page
var links = graph.container.getElementsByTagName('a');
if (links != null)
{
for (var i = 0; i < links.length; i++)
{
var href = links[i].getAttribute('href');
if (href != null && href.charAt(0) == '#' &&
links[i].getAttribute('target') == '_blank')
{
links[i].removeAttribute('target');
}
}
}
};
// Load from URL via url attribute
var url = configNode.getAttribute('url');
if (url != null)
{
try
{
// Workaround for unsupported CORS in IE9 XHR
var xhr = (navigator.userAgent != null && navigator.userAgent.indexOf('MSIE 9') > 0) ?
new XDomainRequest() : new XMLHttpRequest();
xhr.open('GET', url);
xhr.onload = mxUtils.bind(this, function()
{
try
{
var data = (xhr.getText != null) ? xhr.getText() : xhr.responseText;
if (data != null)
{
var newDocument = mxUtils.parseXml(data);
// LATER: Add support for .png (with XML) files
// Adds support for HTML
if (newDocument != null && newDocument.documentElement.nodeName == 'html')
{
var divs = newDocument.documentElement.getElementsByTagName('div');
if (divs.length > 0 && divs[0].getAttribute('class') == 'mxgraph')
{
var divs2 = divs[0].getElementsByTagName('div');
if (divs2.length > 0)
{
var data = mxUtils.getTextContent(divs2[0]);
data = Graph.decompress(data);
if (data.length > 0)
{
newDocument = mxUtils.parseXml(data);
}
}
}
}
if (newDocument != null && newDocument.documentElement.nodeName == 'svg')
{
var tmp = newDocument.documentElement.getAttribute('content');
if (tmp != null && tmp.charAt(0) != '<' && tmp.charAt(0) != '%')
{
tmp = unescape((window.atob) ? atob(tmp) : Base64.decode(cont, tmp));
}
if (tmp != null && tmp.charAt(0) == '%')
{
tmp = decodeURIComponent(tmp);
}
if (tmp != null && tmp.length > 0)
{
newDocument = mxUtils.parseXml(tmp);
}
}
if (newDocument.documentElement.nodeName == 'mxfile')
{
var diagrams = newDocument.documentElement.getElementsByTagName('diagram');
if (diagrams.length > 0)
{
var text = mxUtils.trim(mxUtils.getTextContent(diagrams[0]));
if (text.length > 0)
{
var tmp = Graph.decompress(text);
if (tmp != null && tmp.length > 0)
{
newDocument = mxUtils.parseXml(tmp);
}
}
else
{
var temp = mxUtils.getChildNodes(diagrams[0]);
if (temp.length > 0)
{
// Creates new document for unique IDs within mxGraphModel
newDocument = mxUtils.createXmlDocument();
newDocument.appendChild(newDocument.importNode(temp[0], true));
}
}
}
}
decoder = new mxCodec(newDocument);
decoder.decode(newDocument.documentElement, graph.getModel());
graphAdded(newDocument.documentElement);
}
else
{
graph.container.innerText = 'Cannot load ' + url;
}
}
catch (e)
{
graph.container.innerText = 'Cannot load ' + url + ': ' + e.message;
}
});
xhr.onerror = function()
{
graph.container.innerText = 'Cannot load ' + url;
};
xhr.send();
}
catch (e)
{
graph.container.innerText = 'Cannot load ' + url + ': ' + e.message;
}
}
else
{
decoder.decode(node, graph.getModel());
graphAdded(node);
}
if (container.style.width != '100%' && fit != '0' && resize == '1')
{
graph.resizeContainer = true;
graph.centerZoom = false;
}
// Adds zoom, edit etc in top, left corner
var buttons = document.createElement('div');
buttons.style.position = 'absolute';
buttons.style.overflow = 'visible';
buttons.style.cursor = 'pointer';
var bs = graph.getBorderSizes();
var left = 0;
var fontSize = 10;
var bw = 16;
var bh = 16;
if (mxClient.IS_TOUCH)
{
bw = 24;
bh = 24;
var fontSize = 14;
}
function addButton(label, funct)
{
var btn = document.createElement('div');
btn.style.position = 'absolute';
btn.style.border = '1px solid gray';
btn.style.textAlign = 'center';
btn.style.cursor = 'hand';
btn.style.width = bw + 'px';
btn.style.height = bh + 'px';
btn.style.left = left + 'px';
btn.style.top = '0px';
btn.style.backgroundColor = 'white';
mxUtils.setOpacity(btn, 50);
var table = document.createElement('table');
table.style.borderWidth = '0px';
table.style.width = '100%';
table.style.height = '100%';
var tbody = document.createElement('tbody');
var tr = document.createElement('tr');
var td = document.createElement('td');
td.style.verticalAlign = 'middle';
td.style.textAlign = 'center';
td.style.fontSize = fontSize + 'px';
td.style.padding = '0px';
mxUtils.write(td, label);
tr.appendChild(td);
tbody.appendChild(tr);
table.appendChild(tbody);
btn.appendChild(table);
mxEvent.addListener(btn, (mxClient.IS_POINTER) ? 'pointerdown' : 'mousedown', function(evt)
{
mxEvent.consume(evt);
});
mxEvent.addListener(btn, (mxClient.IS_POINTER) ? 'pointerup' : 'mouseup', function(evt)
{
funct();
mxEvent.consume(evt);
});
if (!mxClient.IS_POINTER && mxClient.IS_TOUCH)
{
mxEvent.addListener(btn, 'touchstart', function(evt)
{
mxEvent.consume(evt);
});
mxEvent.addListener(btn, 'touchend', function(evt)
{
funct();
mxEvent.consume(evt);
});
}
left += bw;
buttons.appendChild(btn);
return btn;
};
var zoom = configNode.getAttribute('zoom');
if (zoom != '0')
{
addButton('+', function()
{
graph.zoomIn();
});
addButton('-', function()
{
graph.zoomOut();
});
}
var edit = configNode.getAttribute('edit');
if (edit != null)
{
var button = addButton('', function()
{
// _blank is a special value to open a new editor
// in client mode and send the XML as a message
if (edit == '_blank')
{
if (url != null)
{
window.open('https://app.diagrams.net/#U' + encodeURIComponent(url));
}
else
{
var wnd = null;
var receive = function(evt)
{
if (evt.data == 'ready' && evt.source == wnd)
{
wnd.postMessage(xml, '*');
window.removeEventListener('message', receive);
}
};
window.addEventListener('message', receive);
wnd = window.open('https://app.diagrams.net/?client=1');
}
}
else
{
window.open(edit);
}
});
// Do not use HTML entity to avoid problems with XHTML
button.innerText = '...';
}
function show()
{
buttons.style.top = (container.offsetTop + bs.y) + 'px';
buttons.style.left = (container.offsetLeft + bs.x) + 'px';
buttons.style.visibility = 'visible';
};
if (!mxClient.IS_POINTER && !mxClient.IS_TOUCH)
{
function hide()
{
buttons.style.visibility = 'hidden';
};
mxEvent.addListener(container, 'mouseover', show);
mxEvent.addListener(buttons, 'mouseover', show);
mxEvent.addListener(container, 'mouseout', hide);
mxEvent.addListener(buttons, 'mouseout', hide);
hide();
}
else
{
show();
}
if (buttons.firstChild != null)
{
if (container.nextSibling != null)
{
container.parentNode.insertBefore(buttons, container.nextSibling);
}
else
{
container.parentNode.appendChild(buttons);
}
}
if (typeof(window.mxClientOnCreate) == 'function')
{
window.mxClientOnCreate(graph);
}
}
}
catch (err)
{
if (window.console != null)
{
console.log('Error:', err);
}
}
return graph;
};
if (typeof(mxClientOnLoad) == 'function')
{
mxClientOnLoad(stylesheet, initGraph);
}
else if (mxClient.isBrowserSupported())
{
var tmp = document.getElementsByTagName('*');
var divs = [];
for (var i = 0; i < tmp.length; i++)
{
divs.push(tmp[i]);
}
for (var i = 0; i < divs.length; i++)
{
if (divs[i].className.toString().indexOf('mxgraph') >= 0)
{
initGraph(divs[i]);
}
}
}
})();
// Last line will be replaced by servlet for passing arguments.

View File

@ -0,0 +1,17 @@
var isLocalStorage = false;
var mxLoadStylesheets = false;
function getUrlParam(param)
{
var result = (new RegExp(param + '=([^&]*)')).exec(window.location.search);
if (result != null && result.length > 0)
{
return decodeURIComponent(result[1].replace(/\+/g, '%20'));
}
return null;
};
var remoteMath = getUrlParam('remoteMath') == '1';
var fallbackFont = getUrlParam('fallbackFont');

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
Use babeljs.io to convert for IE11, but disable it in IE11 as Math.hypot is missing.

View File

@ -0,0 +1 @@
(()=>{"use strict";var t={};function e(t,e,n,r=(t=>t)){return t*r(.5-e*(.5-n))}function n(t,e){return[t[0]+e[0],t[1]+e[1]]}function r(t,e){return[t[0]-e[0],t[1]-e[1]]}function i(t,e){return[t[0]*e,t[1]*e]}function u(t){return[t[1],-t[0]]}function o(t,e){return t[0]*e[0]+t[1]*e[1]}function l(t,e){return t[0]===e[0]&&t[1]===e[1]}function s(t,e){return function(t){return t[0]*t[0]+t[1]*t[1]}(r(t,e))}function c(t){return function(t,e){return[t[0]/e,t[1]/e]}(t,function(t){return Math.hypot(t[0],t[1])}(t))}function h(t,e){return Math.hypot(t[1]-e[1],t[0]-e[0])}function f(t,e,n){let r=Math.sin(n),i=Math.cos(n),u=t[0]-e[0],o=t[1]-e[1],l=u*r+o*i;return[u*i-o*r+e[0],l+e[1]]}function p(t,e,u){return n(t,i(r(e,t),u))}function a(t,e,r){return n(t,i(e,r))}t.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}();var{min:g,PI:v}=Math,d=v+1e-4;function M(t,v={}){return function(t,l={}){let{size:h=16,smoothing:v=.5,thinning:M=.5,simulatePressure:m=!0,easing:y=(t=>t),start:w={},end:P={},last:F=!1}=l,{cap:b=!0,easing:x=(t=>t*(2-t))}=w,{cap:L=!0,easing:j=(t=>--t*t*t+1)}=P;if(0===t.length||h<=0)return[];let S,k=t[t.length-1].runningLength,z=!1===w.taper?0:!0===w.taper?Math.max(h,k):w.taper,A=!1===P.taper?0:!0===P.taper?Math.max(h,k):P.taper,T=Math.pow(h*v,2),I=[],Q=[],Z=t.slice(0,10).reduce(((t,e)=>{let n=e.pressure;if(m){let r=g(1,e.distance/h),i=g(1,1-r);n=g(1,t+.275*r*(i-t))}return(t+n)/2}),t[0].pressure),q=e(h,M,t[t.length-1].pressure,y),B=t[0].vector,C=t[0].point,D=C,E=C,G=D;for(let l=0;l<t.length;l++){let{pressure:c}=t[l],{point:a,vector:v,distance:w,runningLength:P}=t[l];if(l<t.length-1&&k-P<3)continue;if(M){if(m){let t=g(1,w/h),e=g(1,1-t);c=g(1,Z+.275*t*(e-Z))}q=e(h,M,c,y)}else q=h/2;void 0===S&&(S=q);let F=P<z?x(P/z):1,b=k-P<A?j((k-P)/A):1;if(q=Math.max(.01,q*Math.min(F,b)),l===t.length-1){let t=i(u(v),q);I.push(r(a,t)),Q.push(n(a,t));continue}let L=t[l+1].vector,H=o(v,L);if(H<0){let t=i(u(B),q);for(let e=1/13,i=0;i<=1;i+=e)E=f(r(a,t),a,d*i),I.push(E),G=f(n(a,t),a,d*-i),Q.push(G);C=E,D=G;continue}let J=i(u(p(L,v,H)),q);E=r(a,J),(l<=1||s(C,E)>T)&&(I.push(E),C=E),G=n(a,J),(l<=1||s(D,G)>T)&&(Q.push(G),D=G),Z=c,B=v}let H=t[0].point.slice(0,2),J=t.length>1?t[t.length-1].point.slice(0,2):n(t[0].point,[1,1]),K=[],N=[];if(1===t.length){if(!z&&!A||F){let t=a(H,c(u(r(H,J))),-(S||q)),e=[];for(let n=1/13,r=n;r<=1;r+=n)e.push(f(t,H,2*d*r));return e}}else{if(!(z||A&&1===t.length))if(b)for(let t=1/13,e=t;e<=1;e+=t){let t=f(Q[0],H,d*e);K.push(t)}else{let t=r(I[0],Q[0]),e=i(t,.5),u=i(t,.51);K.push(r(H,e),r(H,u),n(H,u),n(H,e))}let e=u(function(t){return[-t[0],-t[1]]}(t[t.length-1].vector));if(A||z&&1===t.length)N.push(J);else if(L){let t=a(J,e,q);for(let e=1/29,n=e;n<1;n+=e)N.push(f(t,J,3*d*n))}else N.push(n(J,i(e,q)),n(J,i(e,.99*q)),r(J,i(e,.99*q)),r(J,i(e,q)))}return I.concat(N,Q.reverse(),K)}(function(t,e={}){var i;let{streamline:u=.5,size:o=16,last:s=!1}=e;if(0===t.length)return[];let f=.15+.85*(1-u),a=Array.isArray(t[0])?t:t.map((({x:t,y:e,pressure:n=.5})=>[t,e,n]));if(2===a.length){let t=a[1];a=a.slice(0,-1);for(let e=1;e<5;e++)a.push(p(a[0],t,e/4))}1===a.length&&(a=[...a,[...n(a[0],[1,1]),...a[0].slice(2)]]);let g=[{point:[a[0][0],a[0][1]],pressure:a[0][2]>=0?a[0][2]:.25,vector:[1,1],distance:0,runningLength:0}],v=!1,d=0,M=g[0],m=a.length-1;for(let t=1;t<a.length;t++){let e=s&&t===m?a[t].slice(0,2):p(M.point,a[t],f);if(l(M.point,e))continue;let n=h(e,M.point);if(d+=n,t<m&&!v){if(d<o)continue;v=!0}M={point:e,pressure:a[t][2]>=0?a[t][2]:.5,vector:c(r(M.point,e)),distance:n,runningLength:d},g.push(M)}return g[0].vector=(null==(i=g[1])?void 0:i.vector)||[0,0],g}(t,v),v)}t.g.PerfectFreehand={},PerfectFreehand.getStroke=function(t,e){return M(t,e)},PerfectFreehand.getSvgPathFromStroke=function(t,e){let n=M(t,e);const r=n.reduce(((t,[e,n],r,i)=>{const[u,o]=i[(r+1)%i.length];return t.push(e,n,(e+u)/2,(n+o)/2),t}),["M",...n[0],"Q"]);return r.push("Z"),r.join(" ")}})();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,905 @@
/**
* jscolor, JavaScript Color Picker (name changed to mxJSColor to avoid conflicts)
*
* @version 1.3.13
* @license GNU Lesser General Public License, http://www.gnu.org/copyleft/lesser.html
* @author Jan Odvarko, http://odvarko.cz
* @created 2008-06-15
* @updated 2012-01-19
* @link http://jscolor.com
*/
var mxJSColor = {
bindClass : 'color', // class name
binding : true, // automatic binding via <input class="...">
preloading : true, // use image preloading?
install : function() {
//mxJSColor.addEvent(window, 'load', mxJSColor.init);
},
init : function() {
if(mxJSColor.preloading) {
mxJSColor.preload();
}
},
getDir : function() {
return IMAGE_PATH + '/';
},
detectDir : function() {
var base = location.href;
var e = document.getElementsByTagName('base');
for(var i=0; i<e.length; i+=1) {
if(e[i].href) { base = e[i].href; }
}
var e = document.getElementsByTagName('script');
for(var i=0; i<e.length; i+=1) {
if(e[i].src && /(^|\/)jscolor\.js([?#].*)?$/i.test(e[i].src)) {
var src = new mxJSColor.URI(e[i].src);
var srcAbs = src.toAbsolute(base);
srcAbs.path = srcAbs.path.replace(/[^\/]+$/, ''); // remove filename
srcAbs.query = null;
srcAbs.fragment = null;
return srcAbs.toString();
}
}
return false;
},
preload : function() {
for(var fn in mxJSColor.imgRequire) {
if(mxJSColor.imgRequire.hasOwnProperty(fn)) {
mxJSColor.loadImage(fn);
}
}
},
images : {
pad : [ 181, 101 ],
sld : [ 16, 101 ],
cross : [ 15, 15 ],
arrow : [ 7, 11 ]
},
imgRequire : {},
imgLoaded : {},
requireImage : function(filename) {
mxJSColor.imgRequire[filename] = true;
},
loadImage : function(filename) {
if(!mxJSColor.imgLoaded[filename]) {
mxJSColor.imgLoaded[filename] = new Image();
mxJSColor.imgLoaded[filename].src = mxJSColor.getDir()+filename;
}
},
fetchElement : function(mixed) {
return typeof mixed === 'string' ? document.getElementById(mixed) : mixed;
},
addEvent : function(el, evnt, func) {
if(el.addEventListener) {
el.addEventListener(evnt, func, false);
} else if(el.attachEvent) {
el.attachEvent('on'+evnt, func);
}
},
fireEvent : function(el, evnt) {
if(!el) {
return;
}
if(document.createEvent) {
var ev = document.createEvent('HTMLEvents');
ev.initEvent(evnt, true, true);
el.dispatchEvent(ev);
} else if(document.createEventObject) {
var ev = document.createEventObject();
el.fireEvent('on'+evnt, ev);
} else if(el['on'+evnt]) { // alternatively use the traditional event model (IE5)
el['on'+evnt]();
}
},
getElementPos : function(e) {
var e1=e, e2=e;
var x=0, y=0;
if(e1.offsetParent) {
do {
x += e1.offsetLeft;
y += e1.offsetTop;
} while(e1 = e1.offsetParent);
}
while((e2 = e2.parentNode) && e2.nodeName.toUpperCase() !== 'BODY') {
x -= e2.scrollLeft;
y -= e2.scrollTop;
}
return [x, y];
},
getElementSize : function(e) {
return [e.offsetWidth, e.offsetHeight];
},
getRelMousePos : function(e) {
var x = 0, y = 0;
if (!e) { e = window.event; }
if (typeof e.offsetX === 'number') {
x = e.offsetX;
y = e.offsetY;
} else if (typeof e.layerX === 'number') {
x = e.layerX;
y = e.layerY;
}
return { x: x, y: y };
},
getViewPos : function() {
if(typeof window.pageYOffset === 'number') {
return [window.pageXOffset, window.pageYOffset];
} else if(document.body && (document.body.scrollLeft || document.body.scrollTop)) {
return [document.body.scrollLeft, document.body.scrollTop];
} else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
return [document.documentElement.scrollLeft, document.documentElement.scrollTop];
} else {
return [0, 0];
}
},
getViewSize : function() {
if(typeof window.innerWidth === 'number') {
return [window.innerWidth, window.innerHeight];
} else if(document.body && (document.body.clientWidth || document.body.clientHeight)) {
return [document.body.clientWidth, document.body.clientHeight];
} else if(document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
return [document.documentElement.clientWidth, document.documentElement.clientHeight];
} else {
return [0, 0];
}
},
URI : function(uri) { // See RFC3986
this.scheme = null;
this.authority = null;
this.path = '';
this.query = null;
this.fragment = null;
this.parse = function(uri) {
var m = uri.match(/^(([A-Za-z][0-9A-Za-z+.-]*)(:))?((\/\/)([^\/?#]*))?([^?#]*)((\?)([^#]*))?((#)(.*))?/);
this.scheme = m[3] ? m[2] : null;
this.authority = m[5] ? m[6] : null;
this.path = m[7];
this.query = m[9] ? m[10] : null;
this.fragment = m[12] ? m[13] : null;
return this;
};
this.toString = function() {
var result = '';
if(this.scheme !== null) { result = result + this.scheme + ':'; }
if(this.authority !== null) { result = result + '//' + this.authority; }
if(this.path !== null) { result = result + this.path; }
if(this.query !== null) { result = result + '?' + this.query; }
if(this.fragment !== null) { result = result + '#' + this.fragment; }
return result;
};
this.toAbsolute = function(base) {
var base = new mxJSColor.URI(base);
var r = this;
var t = new mxJSColor.URI;
if(base.scheme === null) { return false; }
if(r.scheme !== null && r.scheme.toLowerCase() === base.scheme.toLowerCase()) {
r.scheme = null;
}
if(r.scheme !== null) {
t.scheme = r.scheme;
t.authority = r.authority;
t.path = removeDotSegments(r.path);
t.query = r.query;
} else {
if(r.authority !== null) {
t.authority = r.authority;
t.path = removeDotSegments(r.path);
t.query = r.query;
} else {
if(r.path === '') { // TODO: == or === ?
t.path = base.path;
if(r.query !== null) {
t.query = r.query;
} else {
t.query = base.query;
}
} else {
if(r.path.substr(0,1) === '/') {
t.path = removeDotSegments(r.path);
} else {
if(base.authority !== null && base.path === '') { // TODO: == or === ?
t.path = '/'+r.path;
} else {
t.path = base.path.replace(/[^\/]+$/,'')+r.path;
}
t.path = removeDotSegments(t.path);
}
t.query = r.query;
}
t.authority = base.authority;
}
t.scheme = base.scheme;
}
t.fragment = r.fragment;
return t;
};
function removeDotSegments(path) {
var out = '';
while(path) {
if(path.substr(0,3)==='../' || path.substr(0,2)==='./') {
path = path.replace(/^\.+/,'').substr(1);
} else if(path.substr(0,3)==='/./' || path==='/.') {
path = '/'+path.substr(3);
} else if(path.substr(0,4)==='/../' || path==='/..') {
path = '/'+path.substr(4);
out = out.replace(/\/?[^\/]*$/, '');
} else if(path==='.' || path==='..') {
path = '';
} else {
var rm = path.match(/^\/?[^\/]*/)[0];
path = path.substr(rm.length);
out = out + rm;
}
}
return out;
}
if(uri) {
this.parse(uri);
}
},
/*
* Usage example:
* var myColor = new mxJSColor.color(myInputElement)
*/
color : function(target, prop) {
this.required = true; // refuse empty values?
this.adjust = true; // adjust value to uniform notation?
this.hash = false; // prefix color with # symbol?
this.caps = true; // uppercase?
this.slider = true; // show the value/saturation slider?
this.valueElement = target; // value holder
this.styleElement = target; // where to reflect current color
this.onImmediateChange = null; // onchange callback (can be either string or function)
this.hsv = [0, 0, 1]; // read-only 0-6, 0-1, 0-1
this.rgb = [1, 1, 1]; // read-only 0-1, 0-1, 0-1
this.pickerOnfocus = true; // display picker on focus?
this.pickerMode = 'HSV'; // HSV | HVS
this.pickerPosition = 'bottom'; // left | right | top | bottom
this.pickerSmartPosition = true; // automatically adjust picker position when necessary
this.pickerButtonHeight = 20; // px
this.pickerClosable = false;
this.pickerCloseText = 'Close';
this.pickerButtonColor = 'ButtonText'; // px
this.pickerFace = 0; // px
this.pickerFaceColor = 'ThreeDFace'; // CSS color
this.pickerBorder = 1; // px
this.pickerBorderColor = 'ThreeDHighlight ThreeDShadow ThreeDShadow ThreeDHighlight'; // CSS color
this.pickerInset = 1; // px
this.pickerInsetColor = 'ThreeDShadow ThreeDHighlight ThreeDHighlight ThreeDShadow'; // CSS color
this.pickerZIndex = 10000;
for(var p in prop) {
if(prop.hasOwnProperty(p)) {
this[p] = prop[p];
}
}
this.hidePicker = function() {
if(isPickerOwner()) {
removePicker();
}
};
this.showPicker = function() {
if(!isPickerOwner()) {
var tp = mxJSColor.getElementPos(target); // target pos
var ts = mxJSColor.getElementSize(target); // target size
var vp = mxJSColor.getViewPos(); // view pos
var vs = mxJSColor.getViewSize(); // view size
var ps = getPickerDims(this); // picker size
var a, b, c;
switch(this.pickerPosition.toLowerCase()) {
case 'left': a=1; b=0; c=-1; break;
case 'right':a=1; b=0; c=1; break;
case 'top': a=0; b=1; c=-1; break;
default: a=0; b=1; c=1; break;
}
var l = (ts[b]+ps[b])/2;
// picker pos
if (!this.pickerSmartPosition) {
var pp = [
tp[a],
tp[b]+ts[b]-l+l*c
];
} else {
var pp = [
-vp[a]+tp[a]+ps[a] > vs[a] ?
(-vp[a]+tp[a]+ts[a]/2 > vs[a]/2 && tp[a]+ts[a]-ps[a] >= 0 ? tp[a]+ts[a]-ps[a] : tp[a]) :
tp[a],
-vp[b]+tp[b]+ts[b]+ps[b]-l+l*c > vs[b] ?
(-vp[b]+tp[b]+ts[b]/2 > vs[b]/2 && tp[b]+ts[b]-l-l*c >= 0 ? tp[b]+ts[b]-l-l*c : tp[b]+ts[b]-l+l*c) :
(tp[b]+ts[b]-l+l*c >= 0 ? tp[b]+ts[b]-l+l*c : tp[b]+ts[b]-l-l*c)
];
}
drawPicker(0, 0);
}
};
this.importColor = function() {
if(!valueElement) {
this.exportColor();
} else {
if(!this.adjust) {
if(!this.fromString(valueElement.value, leaveValue)) {
styleElement.style.backgroundImage = styleElement.jscStyle.backgroundImage;
styleElement.style.backgroundColor = styleElement.jscStyle.backgroundColor;
styleElement.style.color = styleElement.jscStyle.color;
this.exportColor(leaveValue | leaveStyle);
}
} else if(!this.required && /^\s*$/.test(valueElement.value)) {
valueElement.value = '';
styleElement.style.backgroundImage = styleElement.jscStyle.backgroundImage;
styleElement.style.backgroundColor = styleElement.jscStyle.backgroundColor;
styleElement.style.color = styleElement.jscStyle.color;
this.exportColor(leaveValue | leaveStyle);
} else if(this.fromString(valueElement.value)) {
// OK
} else {
this.exportColor();
}
}
};
this.exportColor = function(flags) {
if(!(flags & leaveValue) && valueElement) {
var value = this.toString();
if(this.caps) { value = value.toUpperCase(); }
if(this.hash) { value = '#'+value; }
valueElement.value = value;
}
if(!(flags & leaveStyle) && styleElement) {
styleElement.style.backgroundImage = "none";
styleElement.style.backgroundColor =
'#'+this.toString();
styleElement.style.color =
0.213 * this.rgb[0] +
0.715 * this.rgb[1] +
0.072 * this.rgb[2]
< 0.5 ? '#FFF' : '#000';
}
if(!(flags & leavePad) && isPickerOwner()) {
redrawPad();
}
if(!(flags & leaveSld) && isPickerOwner()) {
redrawSld();
}
};
this.fromHSV = function(h, s, v, flags) { // null = don't change
h<0 && (h=0) || h>6 && (h=6);
s<0 && (s=0) || s>1 && (s=1);
v<0 && (v=0) || v>1 && (v=1);
this.rgb = HSV_RGB(
h===null ? this.hsv[0] : (this.hsv[0]=h),
s===null ? this.hsv[1] : (this.hsv[1]=s),
v===null ? this.hsv[2] : (this.hsv[2]=v)
);
this.exportColor(flags);
};
this.fromRGB = function(r, g, b, flags) { // null = don't change
r<0 && (r=0) || r>1 && (r=1);
g<0 && (g=0) || g>1 && (g=1);
b<0 && (b=0) || b>1 && (b=1);
var hsv = RGB_HSV(
r===null ? this.rgb[0] : (this.rgb[0]=r),
g===null ? this.rgb[1] : (this.rgb[1]=g),
b===null ? this.rgb[2] : (this.rgb[2]=b)
);
if(hsv[0] !== null) {
this.hsv[0] = hsv[0];
}
if(hsv[2] !== 0) {
this.hsv[1] = hsv[1];
}
this.hsv[2] = hsv[2];
this.exportColor(flags);
};
this.fromString = function(hex, flags) {
var m = hex.match(/^\W*([0-9A-F]{3}([0-9A-F]{3})?)\W*$/i);
if(!m) {
return false;
} else {
if(m[1].length === 6) { // 6-char notation
this.fromRGB(
parseInt(m[1].substr(0,2),16) / 255,
parseInt(m[1].substr(2,2),16) / 255,
parseInt(m[1].substr(4,2),16) / 255,
flags
);
} else { // 3-char notation
this.fromRGB(
parseInt(m[1].charAt(0)+m[1].charAt(0),16) / 255,
parseInt(m[1].charAt(1)+m[1].charAt(1),16) / 255,
parseInt(m[1].charAt(2)+m[1].charAt(2),16) / 255,
flags
);
}
return true;
}
};
this.toString = function() {
return (
(0x100 | Math.round(255*this.rgb[0])).toString(16).substr(1) +
(0x100 | Math.round(255*this.rgb[1])).toString(16).substr(1) +
(0x100 | Math.round(255*this.rgb[2])).toString(16).substr(1)
);
};
function RGB_HSV(r, g, b) {
var n = Math.min(Math.min(r,g),b);
var v = Math.max(Math.max(r,g),b);
var m = v - n;
if(m === 0) { return [ null, 0, v ]; }
var h = r===n ? 3+(b-g)/m : (g===n ? 5+(r-b)/m : 1+(g-r)/m);
return [ h===6?0:h, m/v, v ];
}
function HSV_RGB(h, s, v) {
if(h === null) { return [ v, v, v ]; }
var i = Math.floor(h);
var f = i%2 ? h-i : 1-(h-i);
var m = v * (1 - s);
var n = v * (1 - s*f);
switch(i) {
case 6:
case 0: return [v,n,m];
case 1: return [n,v,m];
case 2: return [m,v,n];
case 3: return [m,n,v];
case 4: return [n,m,v];
case 5: return [v,m,n];
}
}
function removePicker() {
delete mxJSColor.picker.owner;
document.getElementsByTagName('body')[0].removeChild(mxJSColor.picker.boxB);
}
function drawPicker(x, y) {
if(!mxJSColor.picker) {
mxJSColor.picker = {
box : document.createElement('div'),
boxB : document.createElement('div'),
pad : document.createElement('div'),
padB : document.createElement('div'),
padM : document.createElement('div'),
sld : document.createElement('div'),
sldB : document.createElement('div'),
sldM : document.createElement('div'),
btn : document.createElement('div'),
btnS : document.createElement('span'),
btnT : document.createTextNode(THIS.pickerCloseText)
};
for(var i=0,segSize=4; i<mxJSColor.images.sld[1]; i+=segSize) {
var seg = document.createElement('div');
seg.style.height = segSize+'px';
seg.style.fontSize = '1px';
seg.style.lineHeight = '0';
mxJSColor.picker.sld.appendChild(seg);
}
mxJSColor.picker.sldB.appendChild(mxJSColor.picker.sld);
mxJSColor.picker.box.appendChild(mxJSColor.picker.sldB);
mxJSColor.picker.box.appendChild(mxJSColor.picker.sldM);
mxJSColor.picker.padB.appendChild(mxJSColor.picker.pad);
mxJSColor.picker.box.appendChild(mxJSColor.picker.padB);
mxJSColor.picker.box.appendChild(mxJSColor.picker.padM);
mxJSColor.picker.btnS.appendChild(mxJSColor.picker.btnT);
mxJSColor.picker.btn.appendChild(mxJSColor.picker.btnS);
mxJSColor.picker.box.appendChild(mxJSColor.picker.btn);
mxJSColor.picker.boxB.appendChild(mxJSColor.picker.box);
}
var p = mxJSColor.picker;
// controls interaction
p.box.onmouseup =
p.box.onmouseout = function() { if (!mxClient.IS_TOUCH) { target.focus(); } };
p.box.onmousedown = function() { abortBlur=true; };
p.box.onmousemove = function(e) {
if (holdPad || holdSld) {
holdPad && setPad(e);
holdSld && setSld(e);
if (document.selection) {
document.selection.empty();
} else if (window.getSelection) {
window.getSelection().removeAllRanges();
}
dispatchImmediateChange();
}
};
p.padM.onmouseup =
p.padM.onmouseout = function() { if(holdPad) { holdPad=false; mxJSColor.fireEvent(valueElement,'change'); } };
p.padM.onmousedown = function(e) {
// if the slider is at the bottom, move it up
switch(modeID) {
case 0: if (THIS.hsv[2] === 0) { THIS.fromHSV(null, null, 1.0); }; break;
case 1: if (THIS.hsv[1] === 0) { THIS.fromHSV(null, 1.0, null); }; break;
}
holdPad=true;
setPad(e);
dispatchImmediateChange();
};
p.sldM.onmouseup =
p.sldM.onmouseout = function() { if(holdSld) { holdSld=false; mxJSColor.fireEvent(valueElement,'change'); } };
p.sldM.onmousedown = function(e) {
holdSld=true;
setSld(e);
dispatchImmediateChange();
};
// picker
var dims = getPickerDims(THIS);
p.box.style.width = dims[0] + 'px';
p.box.style.height = dims[1] + 'px';
// picker border
p.boxB.style.position = 'absolute';
p.boxB.style.clear = 'both';
p.boxB.style.left = x+'px';
p.boxB.style.top = y+'px';
p.boxB.style.zIndex = THIS.pickerZIndex;
p.boxB.style.border = THIS.pickerBorder+'px solid';
p.boxB.style.borderColor = THIS.pickerBorderColor;
p.boxB.style.background = THIS.pickerFaceColor;
// pad image
p.pad.style.width = mxJSColor.images.pad[0]+'px';
p.pad.style.height = mxJSColor.images.pad[1]+'px';
// pad border
p.padB.style.position = 'absolute';
p.padB.style.left = THIS.pickerFace+'px';
p.padB.style.top = THIS.pickerFace+'px';
p.padB.style.border = THIS.pickerInset+'px solid';
p.padB.style.borderColor = THIS.pickerInsetColor;
// pad mouse area
p.padM.style.position = 'absolute';
p.padM.style.left = '0';
p.padM.style.top = '0';
p.padM.style.width = THIS.pickerFace + 2*THIS.pickerInset + mxJSColor.images.pad[0] + mxJSColor.images.arrow[0] + 'px';
p.padM.style.height = p.box.style.height;
p.padM.style.cursor = 'crosshair';
// slider image
p.sld.style.overflow = 'hidden';
p.sld.style.width = mxJSColor.images.sld[0]+'px';
p.sld.style.height = mxJSColor.images.sld[1]+'px';
// slider border
p.sldB.style.display = THIS.slider ? 'block' : 'none';
p.sldB.style.position = 'absolute';
p.sldB.style.right = THIS.pickerFace+'px';
p.sldB.style.top = THIS.pickerFace+'px';
p.sldB.style.border = THIS.pickerInset+'px solid';
p.sldB.style.borderColor = THIS.pickerInsetColor;
// slider mouse area
p.sldM.style.display = THIS.slider ? 'block' : 'none';
p.sldM.style.position = 'absolute';
p.sldM.style.right = '0';
p.sldM.style.top = '0';
p.sldM.style.width = mxJSColor.images.sld[0] + mxJSColor.images.arrow[0] + THIS.pickerFace + 2*THIS.pickerInset + 'px';
p.sldM.style.height = p.box.style.height;
try {
p.sldM.style.cursor = 'pointer';
} catch(eOldIE) {
p.sldM.style.cursor = 'hand';
}
// "close" button
function setBtnBorder() {
var insetColors = THIS.pickerInsetColor.split(/\s+/);
var pickerOutsetColor = insetColors.length < 2 ? insetColors[0] : insetColors[1] + ' ' + insetColors[0] + ' ' + insetColors[0] + ' ' + insetColors[1];
p.btn.style.borderColor = pickerOutsetColor;
}
p.btn.style.display = THIS.pickerClosable ? 'block' : 'none';
p.btn.style.position = 'absolute';
p.btn.style.left = THIS.pickerFace + 'px';
p.btn.style.bottom = THIS.pickerFace + 'px';
p.btn.style.padding = '0 15px';
p.btn.style.height = '18px';
p.btn.style.border = THIS.pickerInset + 'px solid';
setBtnBorder();
p.btn.style.color = THIS.pickerButtonColor;
p.btn.style.font = '12px sans-serif';
p.btn.style.textAlign = 'center';
try {
p.btn.style.cursor = 'pointer';
} catch(eOldIE) {
p.btn.style.cursor = 'hand';
}
p.btn.onmousedown = function () {
THIS.hidePicker();
};
p.btnS.style.lineHeight = p.btn.style.height;
// load images in optimal order
switch(modeID) {
case 0: var padImg = 'hs.png'; break;
case 1: var padImg = 'hv.png'; break;
}
p.padM.style.backgroundImage = "url(data:image/gif;base64,R0lGODlhDwAPAKEBAAAAAP///////////yH5BAEKAAIALAAAAAAPAA8AAAIklB8Qx53b4otSUWcvyiz4/4AeQJbmKY4p1HHapBlwPL/uVRsFADs=)";
p.padM.style.backgroundRepeat = "no-repeat";
p.sldM.style.backgroundImage = "url(data:image/gif;base64,R0lGODlhBwALAKECAAAAAP///6g8eKg8eCH5BAEKAAIALAAAAAAHAAsAAAITTIQYcLnsgGxvijrxqdQq6DRJAQA7)";
p.sldM.style.backgroundRepeat = "no-repeat";
p.pad.style.backgroundImage = "url('"+mxJSColor.getDir()+padImg+"')";
p.pad.style.backgroundRepeat = "no-repeat";
p.pad.style.backgroundPosition = "0 0";
// place pointers
redrawPad();
redrawSld();
mxJSColor.picker.owner = THIS;
document.getElementsByTagName('body')[0].appendChild(p.boxB);
}
function getPickerDims(o) {
var dims = [
2*o.pickerInset + 2*o.pickerFace + mxJSColor.images.pad[0] +
(o.slider ? 2*o.pickerInset + 2*mxJSColor.images.arrow[0] + mxJSColor.images.sld[0] : 0),
o.pickerClosable ?
4*o.pickerInset + 3*o.pickerFace + mxJSColor.images.pad[1] + o.pickerButtonHeight :
2*o.pickerInset + 2*o.pickerFace + mxJSColor.images.pad[1]
];
return dims;
}
function redrawPad() {
// redraw the pad pointer
switch(modeID) {
case 0: var yComponent = 1; break;
case 1: var yComponent = 2; break;
}
var x = Math.round((THIS.hsv[0]/6) * (mxJSColor.images.pad[0]-1));
var y = Math.round((1-THIS.hsv[yComponent]) * (mxJSColor.images.pad[1]-1));
mxJSColor.picker.padM.style.backgroundPosition =
(THIS.pickerFace+THIS.pickerInset+x - Math.floor(mxJSColor.images.cross[0]/2)) + 'px ' +
(THIS.pickerFace+THIS.pickerInset+y - Math.floor(mxJSColor.images.cross[1]/2)) + 'px';
// redraw the slider image
var seg = mxJSColor.picker.sld.childNodes;
switch(modeID) {
case 0:
var rgb = HSV_RGB(THIS.hsv[0], THIS.hsv[1], 1);
for(var i=0; i<seg.length; i+=1) {
seg[i].style.backgroundColor = 'rgb('+
(rgb[0]*(1-i/seg.length)*100)+'%,'+
(rgb[1]*(1-i/seg.length)*100)+'%,'+
(rgb[2]*(1-i/seg.length)*100)+'%)';
}
break;
case 1:
var rgb, s, c = [ THIS.hsv[2], 0, 0 ];
var i = Math.floor(THIS.hsv[0]);
var f = i%2 ? THIS.hsv[0]-i : 1-(THIS.hsv[0]-i);
switch(i) {
case 6:
case 0: rgb=[0,1,2]; break;
case 1: rgb=[1,0,2]; break;
case 2: rgb=[2,0,1]; break;
case 3: rgb=[2,1,0]; break;
case 4: rgb=[1,2,0]; break;
case 5: rgb=[0,2,1]; break;
}
for(var i=0; i<seg.length; i+=1) {
s = 1 - 1/(seg.length-1)*i;
c[1] = c[0] * (1 - s*f);
c[2] = c[0] * (1 - s);
seg[i].style.backgroundColor = 'rgb('+
(c[rgb[0]]*100)+'%,'+
(c[rgb[1]]*100)+'%,'+
(c[rgb[2]]*100)+'%)';
}
break;
}
}
function redrawSld() {
// redraw the slider pointer
switch(modeID) {
case 0: var yComponent = 2; break;
case 1: var yComponent = 1; break;
}
var y = Math.round((1-THIS.hsv[yComponent]) * (mxJSColor.images.sld[1]-1));
mxJSColor.picker.sldM.style.backgroundPosition =
'0 ' + (THIS.pickerFace+THIS.pickerInset+y - Math.floor(mxJSColor.images.arrow[1]/2)) + 'px';
}
function isPickerOwner() {
return mxJSColor.picker && mxJSColor.picker.owner === THIS;
}
function blurTarget() {
if(valueElement === target) {
THIS.importColor();
}
if(THIS.pickerOnfocus) {
THIS.hidePicker();
}
}
function blurValue() {
if(valueElement !== target) {
THIS.importColor();
}
}
function setPad(e) {
var mpos = mxJSColor.getRelMousePos(e);
var x = mpos.x - THIS.pickerFace - THIS.pickerInset;
var y = mpos.y - THIS.pickerFace - THIS.pickerInset;
switch(modeID) {
case 0: THIS.fromHSV(x*(6/(mxJSColor.images.pad[0]-1)), 1 - y/(mxJSColor.images.pad[1]-1), null, leaveSld); break;
case 1: THIS.fromHSV(x*(6/(mxJSColor.images.pad[0]-1)), null, 1 - y/(mxJSColor.images.pad[1]-1), leaveSld); break;
}
}
function setSld(e) {
var mpos = mxJSColor.getRelMousePos(e);
var y = mpos.y - THIS.pickerFace - THIS.pickerInset;
switch(modeID) {
case 0: THIS.fromHSV(null, null, 1 - y/(mxJSColor.images.sld[1]-1), leavePad); break;
case 1: THIS.fromHSV(null, 1 - y/(mxJSColor.images.sld[1]-1), null, leavePad); break;
}
}
function dispatchImmediateChange() {
if (THIS.onImmediateChange) {
if (typeof THIS.onImmediateChange === 'string') {
// eval(THIS.onImmediateChange); // Blocked by CSP
} else {
THIS.onImmediateChange(THIS);
}
}
}
var THIS = this;
var modeID = this.pickerMode.toLowerCase()==='hvs' ? 1 : 0;
var abortBlur = false;
var
valueElement = mxJSColor.fetchElement(this.valueElement),
styleElement = mxJSColor.fetchElement(this.styleElement);
var
holdPad = false,
holdSld = false;
var
leaveValue = 1<<0,
leaveStyle = 1<<1,
leavePad = 1<<2,
leaveSld = 1<<3;
// target
/*mxJSColor.addEvent(target, 'focus', function() {
if(THIS.pickerOnfocus) { THIS.showPicker(); }
});
mxJSColor.addEvent(target, 'blur', function() {
if(!abortBlur) {
window.setTimeout(function(){ abortBlur || blurTarget(); abortBlur=false; }, 0);
} else {
abortBlur = false;
}
});*/
// valueElement
if(valueElement) {
var updateField = function() {
THIS.fromString(valueElement.value, leaveValue);
dispatchImmediateChange();
};
mxJSColor.addEvent(valueElement, 'keyup', updateField);
mxJSColor.addEvent(valueElement, 'input', updateField);
mxJSColor.addEvent(valueElement, 'blur', blurValue);
valueElement.setAttribute('autocomplete', 'off');
}
// styleElement
if(styleElement) {
styleElement.jscStyle = {
backgroundImage : styleElement.style.backgroundImage,
backgroundColor : styleElement.style.backgroundColor,
color : styleElement.style.color
};
}
// require images
switch(modeID) {
case 0: mxJSColor.requireImage('hs.png'); break;
case 1: mxJSColor.requireImage('hv.png'); break;
}
this.importColor();
}
};
mxJSColor.install();

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,42 @@
(function() {
window.MathJax =
{
options:
{
skipHtmlTags: {'[+]': ['text']},
ignoreHtmlClass: 'geDisableMathJax'
},
loader:
{
load: [(window.opener.urlParams['math-output'] == 'html') ?
'output/chtml' : 'output/svg', 'input/tex',
'input/asciimath', 'ui/safe']
},
startup:
{
ready: function()
{
MathJax.startup.defaultReady();
MathJax.startup.promise.then(function()
{
if (window.IMMEDIATE_PRINT)
{
window.print();
}
});
}
}
};
var s = document.createElement('script');
s.setAttribute('type', 'text/javascript');
s.setAttribute('src', window.opener.DRAW_MATH_URL + '/startup.js');
var t = document.getElementsByTagName('script')[0];
if (t != null)
{
t.parentNode.insertBefore(s, t);
}
})();

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,946 @@
function mxODPicker(container, previewFn, getODFilesList, getODFileInfo, getRecentList, addToRecent, pickedFileCallback,
errorFn, foldersOnly, backFn, withSubmitBtn, withThumbnail, initFolderPath, acceptAllFiles)
{
var previewHtml = '';
if (previewFn == null)
{
previewFn = renderFile;
previewHtml = '<div style="text-align: center;" class="odPreview"></div>';
}
if (getRecentList == null)
{
getRecentList = function()
{
var list = null;
try
{
list = JSON.parse(localStorage.getItem('mxODPickerRecentList'));
}
catch(e){}
return list;
}
}
if (addToRecent == null)
{
addToRecent = function(file)
{
if (file == null)
{
return;
}
var recentList = getRecentList() || {};
delete file['@microsoft.graph.downloadUrl'];
recentList[file.id] = file;
localStorage.setItem('mxODPickerRecentList', JSON.stringify(recentList));
}
}
function _$(selector, elem)
{
elem = elem || document;
return elem.querySelector(selector);
};
function _$$(selector, elem)
{
elem = elem || document;
return elem.querySelectorAll(selector);
};
var html =
'<div class="odCatsList">' +
'<div class="odCatsListLbl">OneDrive</div>' +
'<div id="odFiles" class="odCatListTitle odCatSelected">' + mxUtils.htmlEntities(mxResources.get('files')) + '</div>' +
'<div id="odRecent" class="odCatListTitle">' + mxUtils.htmlEntities(mxResources.get('recent')) + '</div>' +
'<div id="odShared" class="odCatListTitle">' + mxUtils.htmlEntities(mxResources.get('shared')) + '</div>' +
'<div id="odSharepoint" class="odCatListTitle">' + mxUtils.htmlEntities(mxResources.get('sharepoint')) + '</div>' +
'</div>' +
'<div class="odFilesSec">' +
'<div class="searchBar" style="display:none"><input type="search" id="odSearchBox" placeholder="' + mxUtils.htmlEntities(mxResources.get('search')) + '"></div>' +
'<div class="odFilesBreadcrumb"></div>' +
'<div id="refreshOD" class="odRefreshButton">' +
'<img class="geAdaptiveAsset" src="/images/update32.png" width="16" height="16" title="' + mxUtils.htmlEntities(mxResources.get('refresh')) + 'Refresh" border="0"/>' +
'</div>' +
'<div class="odFilesList"></div>' +
'</div>' +
previewHtml +
(backFn? '<div id="odBackBtn" class="odLinkBtn">&lt; ' + mxUtils.htmlEntities(mxResources.get('back')) + '</div>' : '') +
(withSubmitBtn? '<button id="odSubmitBtn" class="odSubmitBtn">' + mxUtils.htmlEntities(mxResources.get(foldersOnly? 'select' : 'open')) + '</button>' : '');
var isDarkMode = window.Editor != null && Editor.isDarkMode != null && Editor.isDarkMode();
var css =
'.odCatsList *, .odFilesSec * { user-select: none; }' +
'.odCatsList {' +
' box-sizing: border-box;' +
' position:absolute;' +
' top:0px;' +
' bottom:50%;' +
' width:30%;' +
' border: 1px solid #CCCCCC;' +
' border-bottom:none;' +
' display: inline-block;' +
' overflow-x: hidden;' +
' overflow-y: auto;' +
'}' +
'.odCatsListLbl {' +
' height: 17px;' +
' color: #6D6D6D;' +
' font-size: 14px;' +
' font-weight: bold;' +
' line-height: 17px;' +
' margin: 10px 0 3px 5px;' +
'}' +
'.odFilesSec {' +
' box-sizing: border-box;' +
' position:absolute;' +
' left:30%;' +
' top:0px;' +
' bottom:50%;' +
' width: 70%;' +
' border: 1px solid #CCCCCC;' +
' border-left:none;' +
' border-bottom:none;' +
' display: inline-block;' +
' overflow: hidden;' +
'}' +
'.odFilesBreadcrumb {' +
' box-sizing: border-box;' +
' position:absolute;' +
' min-height: 32px;' +
' left:0px;' +
' right:20px;' +
' text-overflow:ellipsis;' +
' overflow:hidden;' +
' font-size: 13px;' +
' color: #6D6D6D;' +
' padding: 5px;' +
'}' +
'.odRefreshButton {' +
' box-sizing: border-box;' +
' position:absolute;' +
' right:0px;' +
' top:0px;' +
' padding: 4px;' +
' margin: 1px;' +
' height:24px;' +
' cursor:default;' +
'}' +
'.odRefreshButton>img {' +
' opacity:0.5;' +
'}' +
'.odRefreshButton:hover {' +
' background-color:#ddd;' +
' border-radius:50%;' +
'}' +
// '.odRefreshButton:hover {' +
// ' background-color:#ddd;' +
// ' border-radius:50%;' +
// '}' +
'.odRefreshButton:active {' +
' opacity:0.7;' +
'}' +
'.odFilesList {' +
' box-sizing: border-box;' +
' position:absolute;' +
' top:32px;' +
' bottom:0px;' +
' width: 100%;' +
' overflow-x: hidden;' +
' overflow-y: auto;' +
'}' +
'.odFileImg {' +
' width: 24px;' +
' padding-left: 5px;' +
' padding-right: 5px;' +
'}' +
'.odFileTitle {' +
' cursor: default;' +
' font-weight: normal;' +
' color: #666666 !important;' +
' width: calc(100% - 20px);' +
' white-space: nowrap;' +
' overflow: hidden;' +
' text-overflow: ellipsis;' +
'}' +
'.odFileListGrid {' +
' width: 100%;' +
' white-space: nowrap;' +
' font-size: 13px;' +
' box-sizing: border-box;' +
' border-spacing: 0;' +
'}' +
'.odOddRow {' +
(isDarkMode ? '' : ' background-color: #eeeeee;') +
'}' +
'.odEvenRow {' +
(isDarkMode ? '' : ' background-color: #FFFFFF;') +
'}' +
'.odRowSelected {' +
' background-color: #cadfff;' +
'}' +
'.odCatListTitle {' +
' box-sizing: border-box;' +
' height: 17px;' +
' cursor: default;' +
' color: #666666;' +
' font-size: 14px;' +
' line-height: 17px;' +
' margin: 5px 0 5px 0px;' +
' padding-left: 10px;' +
'}' +
'.odCatSelected {' +
' font-weight: bold;' +
' background-color: #cadfff;' +
'}' +
'.odEmptyFolder {' +
' height: 17px;' +
' color: #6D6D6D;' +
' font-size: 14px;' +
' font-weight: bold;' +
' line-height: 17px;' +
' margin: 10px 0 3px 5px;' +
' width: 100%;' +
' text-align: center;' +
'}' +
'.odBCFolder {' +
' cursor: pointer;' +
' color: #0432ff;' +
'}' +
'.odPreviewStatus {' +
' position:absolute;' +
' text-align:center;' +
' width:100%;' +
' top:50%;' +
' transform: translateY(-50%);' +
' font-size:13px;' +
' opacity:0.5;' +
'}' +
'.odPreview {' +
' position:absolute;' +
' overflow:hidden;' +
' border: 1px solid #CCCCCC;' +
' bottom:0px;' +
' top: 50%;' +
' left:0px;' +
' right:0px;' +
'}' +
'.odLinkBtn {' +
' position: absolute;' +
' font-size: 12px;' +
' cursor: pointer;' +
' color: #6D6D6D;' +
' left: 5px;' +
' bottom: 3px;' +
'}' +
'.odSubmitBtn {' +
' position: absolute;' +
' color: #333;' +
' right: 5px;' +
' bottom: 5px;' +
'}';
var opts =
{
left: '50%',
lines: 12, // The number of lines to draw
length: 8, // The length of each line
width: 3, // The line thickness
radius: 5, // The radius of the inner circle
rotate: 0, // The rotation offset
color: '#000', // #rgb or #rrggbb
speed: 1, // Rounds per second
trail: 60, // Afterglow percentage
shadow: false, // Whether to render a shadow
hwaccel: false, // Whether to use hardware acceleration
className: 'spinner', // The CSS class to assign to the spinner
zIndex: 2e9 // The z-index (defaults to 2000000000)
};
var spinner = new Spinner(opts);
var editor = new Editor();
var curViewer = null;
var selectedFile = null;
var selectedDriveId = null;
var selectedSiteId = null;
var requestInProgress = false;
var breadcrumb = [];
var lastFolderArgs = null;
var loadingPreviewFile = null;
function getDrawioFileDoc(file, success, error)
{
if (file['@microsoft.graph.downloadUrl'] == null)
{
if (file.parentReference == null)
{
error();
}
else
{
getODFileInfo(file.id, file.parentReference.driveId, function(completeFile)
{
getDrawioFileDoc(completeFile, success, error);
}, error);
return;
}
}
var req = new XMLHttpRequest();
//TODO find another way to disable caching (adding a parameter breaks the url)
req.open('GET', file['@microsoft.graph.downloadUrl']);
var isPng = file.file? (file.file.mimeType == 'image/png') : false;
req.onreadystatechange = function()
{
if (this.readyState == 4)
{
if (this.status >= 200 && this.status <= 299)
{
try
{
var cnt = req.responseText;
if (isPng)
{
cnt = 'data:image/png;base64,' + Editor.base64Encode(cnt);
cnt = Editor.extractGraphModelFromPng(cnt);
}
else if (/\.pdf$/.test(file.name))
{
cnt = 'data:application/pdf;base64,' + Editor.base64Encode(cnt);
cnt = Editor.extractGraphModelFromPdf(cnt);
}
var doc = mxUtils.parseXml(cnt);
var node = (doc.documentElement.nodeName == 'mxlibrary') ?
doc.documentElement : Editor.extractGraphModel(doc.documentElement);
if (node != null)
{
success(node.ownerDocument);
return;
}
}
catch(e) {} //on error and if the doc is null, the following line will call the error
}
error();
}
};
if ((isPng || /\.pdf$/.test(file.name)) && req.overrideMimeType)
{
req.overrideMimeType('text/plain; charset=x-user-defined');
}
req.send();
};
function doSubmit()
{
function submit(img)
{
pickedFileCallback(selectedFile, img);
addToRecent(selectedFile);
}
if (withThumbnail && curViewer != null)
{
editor.exportToCanvas(function(canvas)
{
submit(EditorUi.prototype.createImageDataUri(canvas, null, 'png'));
}, 400, null, null, function(err)
{
//TODO handle errors
console.log(err);
}, 600, null, null, null, null, null, curViewer);
}
else
{
submit();
}
};
function renderFile(file)
{
if (prevDiv == null)
{
return;
}
prevDiv.style.background = 'transparent';
prevDiv.innerText = '';
function showRenderMsg(msg)
{
prevDiv.style.background = 'transparent';
prevDiv.innerText = '';
var status = document.createElement('div');
status.className = 'odPreviewStatus';
mxUtils.write(status, msg);
prevDiv.appendChild(status);
spinner.stop();
};
if (file == null || file.folder || /\.drawiolib$/.test(file.name))
{
showRenderMsg(mxResources.get('noPreview'));
return;
}
try
{
// Workaround for parentReference access
if (file.remoteItem != null)
{
file = file.remoteItem;
}
loadingPreviewFile = file;
spinner.spin(prevDiv);
getDrawioFileDoc(file, function(doc)
{
spinner.stop();
if (loadingPreviewFile != file)
{
return;
}
else if (doc.documentElement.nodeName == 'mxlibrary')
{
showRenderMsg(mxResources.get('noPreview'));
}
else
{
var diagrams = doc.getElementsByTagName('diagram');
curViewer = AspectDialog.prototype.createViewer(prevDiv,
diagrams.length == 0? doc.documentElement : diagrams[0],
null, 'transparent');
}
},
function() //If the file is not a draw.io diagram
{
selectedFile = null;
showRenderMsg(mxResources.get('notADiagramFile'));
});
}
catch (e)
{
selectedFile = null;
showRenderMsg(mxResources.get('notADiagramFile'));
}
};
function renderBreadcrumb()
{
var bcDiv = _$('.odFilesBreadcrumb');
if (bcDiv == null) return;
bcDiv.innerText = '';
for (var i = 0; i < breadcrumb.length - 1; i++)
{
var folder = document.createElement('span');
folder.className = 'odBCFolder';
folder.innerHTML = mxUtils.htmlEntities(breadcrumb[i].name || mxResources.get('home'));
bcDiv.appendChild(folder);
(function(bcItem, index)
{
folder.addEventListener('click', function()
{
previewFn(null);
breadcrumb = breadcrumb.slice(0, index);
fillFolderFiles(bcItem.driveId, bcItem.folderId, bcItem.siteId, bcItem.name);
});
})(breadcrumb[i], i);
var sep = document.createElement('span');
sep.innerHTML = ' &gt; ';
bcDiv.appendChild(sep);
}
if (breadcrumb[breadcrumb.length - 1] != null)
{
var curr = document.createElement('span');
curr.innerHTML = mxUtils.htmlEntities((breadcrumb.length == 1) ?
mxResources.get(foldersOnly ? 'selectFolder' : 'officeSelDiag') :
(breadcrumb[breadcrumb.length - 1].name || mxResources.get('home')));
bcDiv.appendChild(curr);
}
};
function openFile()
{
if (selectedFile == null || requestInProgress) return;
if (selectedDriveId == 'sharepoint')
{
fillFolderFiles('site', null, selectedFile.id, selectedFile.displayName);
}
else if (selectedDriveId == 'site')
{
fillFolderFiles('subsite', null, selectedFile.id, selectedFile.name);
}
else
{
var isFolder = selectedFile.folder;
selectedFile = selectedFile.remoteItem? selectedFile.remoteItem : selectedFile; //handle remote items which is accessed indirectly
var folderDI = (selectedFile.parentReference? selectedFile.parentReference.driveId : null) || selectedDriveId;
var id = selectedFile.id;
if (isFolder)
{
fillFolderFiles(folderDI, id, null, selectedFile.name);
}
else
{
doSubmit();
}
}
};
function fillFolderFiles(driveId, folderId, siteId, folderName, searchTxt)
{
if (requestInProgress) return;
_$('.odCatsList').style.display = 'block';
_$('.odFilesSec').style.display = 'block';
// _$('#signOutLnk').style.display = '';
if (prevDiv != null)
{
prevDiv.innerText = '';
prevDiv.style.top = '50%';
}
requestInProgress = true;
var acceptRequest = true;
var isSharepointSites = 0;
lastFolderArgs = arguments;
function renderList(potentialDrawioFiles)
{
spinner.stop();
var grid = document.createElement('table');
grid.className = 'odFileListGrid';
var currentItem = null;
var count = 0;
//TODO support paging
for (var i = 0; potentialDrawioFiles!= null && i < potentialDrawioFiles.length; i++)
{
var item = potentialDrawioFiles[i];
if (isSharepointSites == 1 && item.webUrl && !(item.webUrl.indexOf('sharepoint.com/sites/') > 0 || item.webUrl.indexOf('sharepoint.com/') < 0))
{
continue;
}
var title = item.displayName || item.name;
var tooltip = mxUtils.htmlEntities(item.description || title);
if (isSharepointSites)
{
item.folder = isSharepointSites == 2? {isRoot: true} : true;
}
var isFolder = item.folder != null;
if (foldersOnly && !isFolder)
{
continue;
}
var row = document.createElement('tr');
row.className = (count++) % 2? 'odOddRow' : 'odEvenRow';
var td = document.createElement('td');
td.style.width = '36px';
var typeImg = document.createElement('img');
typeImg.src = '/images/' + (isFolder? 'folder.png' : 'file.png');
typeImg.className = 'odFileImg';
td.appendChild(typeImg);
row.appendChild(td);
td = document.createElement('td');
var titleDiv = document.createElement('div');
titleDiv.className = "odFileTitle";
titleDiv.innerHTML = mxUtils.htmlEntities(title);
titleDiv.setAttribute('title', tooltip);
td.appendChild(titleDiv);
row.appendChild(td);
grid.appendChild(row);
if (currentItem == null)
{
currentItem = row;
currentItem.className += ' odRowSelected';
selectedFile = item;
selectedDriveId = driveId;
if (!acceptAllFiles)
{
previewFn(selectedFile);
}
}
(function(item2, row2)
{
row.addEventListener('dblclick', openFile);
row.addEventListener('click', function()
{
if (currentItem != row2)
{
currentItem.className = currentItem.className.replace('odRowSelected', '');
currentItem = row2;
currentItem.className += ' odRowSelected';
selectedFile = item2;
selectedDriveId = driveId;
if (!acceptAllFiles)
{
previewFn(selectedFile);
}
}
});
})(item, row);
}
if (count == 0)
{
var emptyMsg = document.createElement('div');
emptyMsg.className = 'odEmptyFolder';
emptyMsg.innerHTML = mxUtils.htmlEntities(mxResources.get('folderEmpty', null, 'Folder is empty!'));
filesList.appendChild(emptyMsg);
}
else
{
filesList.appendChild(grid);
}
renderBreadcrumb();
requestInProgress = false;
};
var timeoutThread = setTimeout(function()
{
acceptRequest = false;
requestInProgress = false;
spinner.stop();
errorFn(mxResources.get('timeout'));
}, 20000); //20 sec timeout
var filesList = _$('.odFilesList');
filesList.innerText = '';
spinner.spin(filesList);
var url;
switch(driveId)
{
case 'recent':
breadcrumb = [{name: mxResources.get('recent', null, 'Recent'), driveId: driveId}];
var recentList = getRecentList() || {};
var list = [];
for (var id in recentList)
{
list.push(recentList[id]);
}
clearTimeout(timeoutThread);
renderList(list);
return;
case 'shared':
url = '/me/drive/sharedWithMe';
breadcrumb = [{name: mxResources.get('sharedWithMe', null, 'Shared With Me'), driveId: driveId}];
break;
case 'sharepoint':
url = '/sites?search=';
breadcrumb = [{name: mxResources.get('sharepointSites', null, 'Sharepoint Sites'), driveId: driveId}];
isSharepointSites = 1;
break;
case 'site':
breadcrumb.push({name: folderName, driveId: driveId, folderId: folderId, siteId: siteId});
url = '/sites/' + siteId + '/drives';
isSharepointSites = 2;
break;
case 'subsite':
breadcrumb.push({name: folderName, driveId: driveId, folderId: folderId, siteId: siteId});
url = '/drives/' + siteId + (folderId? '/items/' + folderId : '/root') + '/children';
break;
case 'search': //TODO search doesn't return any results, find out why then remove display: none from the searchBox
driveId = selectedDriveId;
breadcrumb = [{driveId: driveId, name: mxResources.get('back', null, 'Back')}];
searchTxt = encodeURIComponent(searchTxt.replace(/\'/g, '\\\''));
url = selectedSiteId? '/sites/' + selectedSiteId + '/drive/root/search(q=\'' + searchTxt + '\')' : (driveId? '/drives/' + driveId + '/root/search(q=\'' + searchTxt + '\')' : '/me/drive/root/search(q=\'' + searchTxt + '\')');
break;
default:
if (folderId == null)
{
breadcrumb = [{driveId: driveId}];
}
else
{
breadcrumb.push({name: folderName, driveId: driveId, folderId: folderId});
}
url = (driveId? '/drives/' + driveId : '/me/drive') + (folderId? '/items/' + folderId : '/root') + '/children';
}
if (!isSharepointSites)
{
url += (url.indexOf('?') > 0 ? '&' : '?') + 'select=id,name,description,parentReference,file,createdBy,lastModifiedBy,lastModifiedDateTime,size,folder,remoteItem,@microsoft.graph.downloadUrl';
}
var potentialDrawioFiles = [];
function getChunk(nextUrl)
{
getODFilesList(nextUrl? nextUrl : url, function(resp)
{
if (!acceptRequest) return;
var list = resp.value || [];
if (acceptAllFiles || isSharepointSites)
{
Array.prototype.push.apply(potentialDrawioFiles, list);
}
else
{
for (var i = 0; i < list.length; i++)
{
var file = list[i];
var mimeType = file.file? file.file.mimeType : null;
if (file.folder || mimeType == 'text/html' || mimeType == 'text/xml' || mimeType == 'application/xml' || mimeType == 'image/png'
|| /\.svg$/.test(file.name) || /\.html$/.test(file.name) || /\.xml$/.test(file.name) || /\.png$/.test(file.name)
|| /\.drawio$/.test(file.name) || /\.drawiolib$/.test(file.name) || /\.pdf$/.test(file.name))
{
potentialDrawioFiles.push(file);
}
}
// Sorts entries by type and name
potentialDrawioFiles.sort(function(a, b)
{
var nameA = a.name.toLowerCase();
var nameB = b.name.toLowerCase();
if (a.folder && !b.folder)
{
return -1;
}
else if (!a.folder && b.folder)
{
return 1;
}
else
{
if (nameA < nameB)
{
return -1;
}
else if (nameA > nameB)
{
return 1;
}
else
{
return 0;
}
}
});
}
if (resp['@odata.nextLink'] && potentialDrawioFiles.length < 1000) // TODO Support dynamic paging instead of 1000 limit
{
getChunk(resp['@odata.nextLink']);
}
else
{
clearTimeout(timeoutThread);
renderList(potentialDrawioFiles);
}
},
function(err)
{
if (!acceptRequest) return;
clearTimeout(timeoutThread);
var errMsg = null;
try
{
errMsg = JSON.parse(err.responseText).error.message;
}
catch(e){} //ignore errors
errorFn(mxResources.get('errorFetchingFolder', null, 'Error fetching folder items') +
(errMsg != null? ' (' + errMsg + ')' : ''));
requestInProgress = false;
spinner.stop();
}, nextUrl != null);
};
getChunk();
};
this.getSelectedItem = function()
{
if (selectedFile != null)
{
addToRecent(selectedFile);
}
return selectedFile;
}
//Code execution starts here
if (_$('#mxODPickerCss') == null)
{
var head = document.head || document.getElementsByTagName('head')[0],
style = document.createElement('style');
head.appendChild(style);
style.type = 'text/css';
style.id = 'mxODPickerCss';
style.appendChild(document.createTextNode(css));
}
container.innerHTML = html;
var prevDiv = _$('.odPreview');
var selectedCat = _$('#odFiles');
var cats = _$$('.odCatListTitle');
function setSelectedCat(cat)
{
selectedCat.className = selectedCat.className.replace('odCatSelected', '');
selectedCat = cat;
selectedCat.className += ' odCatSelected';
};
for (var i = 0; i < cats.length; i++)
{
cats[i].addEventListener('click', function()
{
loadingPreviewFile = null;
selectedFile = null;
if (requestInProgress) return;
setSelectedCat(this);
switch(this.id)
{
case 'odFiles':
fillFolderFiles();
break;
case 'odRecent':
fillFolderFiles('recent');
break;
case 'odShared':
fillFolderFiles('shared');
break;
case 'odSharepoint':
fillFolderFiles('sharepoint');
break;
}
});
}
//Search (Currently API doesn't work)
var delayTimer = null;
function doSearch(searchStr)
{
if (requestInProgress) return;
delayTimer = null;
fillFolderFiles('search', null, null, null, searchStr)
};
//Use keyup to detect delete and backspace
_$('#odSearchBox').addEventListener('keyup', function(evt)
{
var searchInput = this;
if (delayTimer != null)
{
clearTimeout(delayTimer);
}
if (evt.keyCode == 13)
{
doSearch(searchInput.value);
}
else
{
delayTimer = setTimeout(function()
{
doSearch(searchInput.value);
}, 500);
}
});
function refreshFolder()
{
if (lastFolderArgs != null)
{
previewFn(null);
var temp = breadcrumb.slice();
fillFolderFiles.apply(this, lastFolderArgs);
breadcrumb = temp;
}
};
_$('#refreshOD').addEventListener('click', refreshFolder);
if (backFn)
{
_$('#odBackBtn').addEventListener('click', backFn);
}
if (withSubmitBtn)
{
_$('#odSubmitBtn').addEventListener('click', doSubmit);
}
if (initFolderPath != null)
{
var folderInfo = initFolderPath.pop();
if (initFolderPath[0].driveId == 'sharepoint')
{
setSelectedCat(_$('#odSharepoint'));
}
breadcrumb = initFolderPath;
fillFolderFiles(folderInfo.driveId, folderInfo.folderId, folderInfo.siteId, folderInfo.name);
}
else
{
fillFolderFiles();
}
};

View File

@ -0,0 +1,939 @@
function mxODPicker(container, previewFn, getODFilesList, getODFileInfo, getRecentList, addToRecent, pickedFileCallback,
errorFn, foldersOnly, backFn, withSubmitBtn, withThumbnail, initFolderPath, acceptAllFiles, isMobile)
{
var previewHtml = '';
if (previewFn == null)
{
previewFn = renderFile;
previewHtml = '<div style="text-align: center;" class="odPreview"></div>';
}
if (getRecentList == null)
{
getRecentList = function()
{
var list = null;
try
{
list = JSON.parse(localStorage.getItem('mxODPickerRecentList'));
}
catch(e){}
return list;
}
}
if (addToRecent == null)
{
addToRecent = function(file)
{
if (file == null)
{
return;
}
var recentList = getRecentList() || {};
delete file['@microsoft.graph.downloadUrl'];
recentList[file.id] = file;
localStorage.setItem('mxODPickerRecentList', JSON.stringify(recentList));
}
}
function _$(selector, elem)
{
elem = elem || document;
return elem.querySelector(selector);
};
function _$$(selector, elem)
{
elem = elem || document;
return elem.querySelectorAll(selector);
};
var html =
'<div style="display: flex; height: 50%;">' +
'<div class="odCatsList">' +
'<div class="odCatsListLbl">OneDrive</div>' +
'<div id="odFiles" class="odCatListTitle odCatSelected">' + mxUtils.htmlEntities(mxResources.get('files')) + '</div>' +
'<div id="odRecent" class="odCatListTitle">' + mxUtils.htmlEntities(mxResources.get('recent')) + '</div>' +
'<div id="odShared" class="odCatListTitle">' + mxUtils.htmlEntities(mxResources.get('shared')) + '</div>' +
'<div id="odSharepoint" class="odCatListTitle">' + mxUtils.htmlEntities(mxResources.get('sharepoint')) + '</div>' +
'</div>' +
'<div class="odFilesSec">' +
'<div class="searchBar" style="display:none"><input type="search" id="odSearchBox" placeholder="' + mxUtils.htmlEntities(mxResources.get('search')) + '"></div>' +
'<div class="odFilesBreadcrumb"></div>' +
'<div id="refreshOD" class="odRefreshButton">' +
'<img class="geAdaptiveAsset" src="/images/update32.png" width="16" height="16" title="' + mxUtils.htmlEntities(mxResources.get('refresh')) + 'Refresh" border="0"/>' +
'</div>' +
'<div class="odFilesList"></div>' +
'</div>' +
'</div>' +
previewHtml +
(backFn? '<div id="odBackBtn" class="odLinkBtn">&lt; ' + mxUtils.htmlEntities(mxResources.get('back')) + '</div>' : '') +
(withSubmitBtn? '<button id="odSubmitBtn" class="odSubmitBtn">' + mxUtils.htmlEntities(mxResources.get(foldersOnly? 'select' : 'open')) + '</button>' : '');
var isDarkMode = window.Editor != null && Editor.isDarkMode != null && Editor.isDarkMode();
var css =
'.odCatsList *, .odFilesSec * { user-select: none; }' +
'.odCatsList {' +
' box-sizing: border-box;' +
' border: 1px solid #CCCCCC;' +
' border-bottom:none;' +
' overflow-x: hidden;' +
' overflow-y: auto;' +
' flex: 2;' +
'}' +
'.odCatsListLbl {' +
' height: 17px;' +
' color: #6D6D6D;' +
' font-size: 14px;' +
' font-weight: bold;' +
' line-height: 17px;' +
' margin: 10px 0 3px 5px;' +
'}' +
'.odFilesSec {' +
' box-sizing: border-box;' +
' border: 1px solid #CCCCCC;' +
' border-left:none;' +
' border-bottom:none;' +
' overflow: hidden;' +
' flex: 5;' +
'}' +
'.odFilesBreadcrumb {' +
' box-sizing: border-box;' +
' min-height: 32px;' +
' text-overflow:ellipsis;' +
' overflow:hidden;' +
' font-size: 13px;' +
' color: #6D6D6D;' +
' padding: 5px;' +
'}' +
'.odRefreshButton {' +
' box-sizing: border-box;' +
' position:absolute;' +
' right:20px;' +
' top:20px;' +
' padding: 4px;' +
' margin: 1px;' +
' height:24px;' +
' cursor:default;' +
'}' +
'.odRefreshButton>img {' +
' opacity:0.5;' +
'}' +
'.odRefreshButton:hover {' +
' background-color:#ddd;' +
' border-radius:50%;' +
'}' +
// '.odRefreshButton:hover {' +
// ' background-color:#ddd;' +
// ' border-radius:50%;' +
// '}' +
'.odRefreshButton:active {' +
' opacity:0.7;' +
'}' +
'.odFilesList {' +
' box-sizing: border-box;' +
' height: calc(100% - 32px);' +
' overflow-x: hidden;' +
' overflow-y: auto;' +
'}' +
'.odFileImg {' +
' width: 24px;' +
' padding-left: 5px;' +
' padding-right: 5px;' +
'}' +
'.odFileTitle {' +
' cursor: default;' +
' font-weight: normal;' +
' color: #666666 !important;' +
' width: calc(100% - 20px);' +
' white-space: nowrap;' +
' overflow: hidden;' +
' text-overflow: ellipsis;' +
'}' +
'.odFileListGrid {' +
' width: 100%;' +
' white-space: nowrap;' +
' font-size: 13px;' +
' box-sizing: border-box;' +
' border-spacing: 0;' +
'}' +
'.odOddRow {' +
(isDarkMode ? '' : ' background-color: #eeeeee;') +
'}' +
'.odEvenRow {' +
(isDarkMode ? '' : ' background-color: #FFFFFF;') +
'}' +
'.odRowSelected {' +
' background-color: #cadfff;' +
'}' +
'.odCatListTitle {' +
' box-sizing: border-box;' +
' height: 17px;' +
' cursor: default;' +
' color: #666666;' +
' font-size: 14px;' +
' line-height: 17px;' +
' margin: 5px 0 5px 0px;' +
' padding-left: 10px;' +
'}' +
'.odCatSelected {' +
' font-weight: bold;' +
' background-color: #cadfff;' +
'}' +
'.odEmptyFolder {' +
' height: 17px;' +
' color: #6D6D6D;' +
' font-size: 14px;' +
' font-weight: bold;' +
' line-height: 17px;' +
' margin: 10px 0 3px 5px;' +
' width: 100%;' +
' text-align: center;' +
'}' +
'.odBCFolder {' +
' cursor: pointer;' +
' color: #0432ff;' +
'}' +
'.odPreviewStatus {' +
' position:absolute;' +
' text-align:center;' +
' width:100%;' +
' top:50%;' +
' transform: translateY(-50%);' +
' font-size:13px;' +
' opacity:0.5;' +
' color: #6D6D6D;' +
'}' +
'.odPreview {' +
' overflow:hidden;' +
' border: 1px solid #CCCCCC;' +
' height: 50%;' +
'}' +
'.odLinkBtn {' +
' font-size: 12px;' +
' cursor: pointer;' +
' color: #6D6D6D;' +
' position: relative;' +
' bottom: 20px;' +
' left: 8px;' +
' width: 50px;' +
' white-space: nowrap;' +
'}' +
'.odSubmitBtn {' +
' position: relative;' +
' color: #333;' +
' right: 5px;' +
' bottom: 40px;' +
' float: right;' +
'}';
var opts =
{
left: '50%',
lines: 12, // The number of lines to draw
length: 8, // The length of each line
width: 3, // The line thickness
radius: 5, // The radius of the inner circle
rotate: 0, // The rotation offset
color: '#000', // #rgb or #rrggbb
speed: 1, // Rounds per second
trail: 60, // Afterglow percentage
shadow: false, // Whether to render a shadow
hwaccel: false, // Whether to use hardware acceleration
className: 'spinner', // The CSS class to assign to the spinner
zIndex: 2e9 // The z-index (defaults to 2000000000)
};
var spinner = new Spinner(opts);
var editor = new Editor();
var curViewer = null;
var selectedFile = null;
var selectedDriveId = null;
var selectedSiteId = null;
var requestInProgress = false;
var breadcrumb = [];
var lastFolderArgs = null;
var loadingPreviewFile = null;
function getDrawioFileDoc(file, success, error)
{
if (file['@microsoft.graph.downloadUrl'] == null)
{
if (file.parentReference == null)
{
error();
}
else
{
getODFileInfo(file.id, file.parentReference.driveId, function(completeFile)
{
getDrawioFileDoc(completeFile, success, error);
}, error);
return;
}
}
var req = new XMLHttpRequest();
//TODO find another way to disable caching (adding a parameter breaks the url)
req.open('GET', file['@microsoft.graph.downloadUrl']);
var isPng = file.file? (file.file.mimeType == 'image/png') : false;
req.onreadystatechange = function()
{
if (this.readyState == 4)
{
if (this.status >= 200 && this.status <= 299)
{
try
{
var cnt = req.responseText;
if (isPng)
{
cnt = 'data:image/png;base64,' + Editor.base64Encode(cnt);
cnt = Editor.extractGraphModelFromPng(cnt);
}
else if (/\.pdf$/.test(file.name))
{
cnt = 'data:application/pdf;base64,' + Editor.base64Encode(cnt);
cnt = Editor.extractGraphModelFromPdf(cnt);
}
var doc = mxUtils.parseXml(cnt);
var node = (doc.documentElement.nodeName == 'mxlibrary') ?
doc.documentElement : Editor.extractGraphModel(doc.documentElement);
if (node != null)
{
success(node.ownerDocument);
return;
}
}
catch(e) {} //on error and if the doc is null, the following line will call the error
}
error();
}
};
if ((isPng || /\.pdf$/.test(file.name)) && req.overrideMimeType)
{
req.overrideMimeType('text/plain; charset=x-user-defined');
}
req.send();
};
function doSubmit()
{
function submit(img)
{
pickedFileCallback(selectedFile, img);
addToRecent(selectedFile);
}
if (withThumbnail && curViewer != null)
{
editor.exportToCanvas(function(canvas)
{
submit(EditorUi.prototype.createImageDataUri(canvas, null, 'png'));
}, 400, null, null, function(err)
{
//TODO handle errors
console.log(err);
}, 600, null, null, null, null, null, curViewer);
}
else
{
submit();
}
};
function renderFile(file)
{
if (prevDiv == null)
{
return;
}
prevDiv.style.background = 'transparent';
prevDiv.innerText = '';
function showRenderMsg(msg)
{
prevDiv.style.background = 'transparent';
prevDiv.innerText = '';
var status = document.createElement('div');
status.className = 'odPreviewStatus';
mxUtils.write(status, msg);
prevDiv.appendChild(status);
spinner.stop();
};
if (file == null || file.folder || /\.drawiolib$/.test(file.name))
{
showRenderMsg(mxResources.get('noPreview'));
return;
}
try
{
// Workaround for parentReference access
if (file.remoteItem != null)
{
file = file.remoteItem;
}
loadingPreviewFile = file;
spinner.spin(prevDiv);
getDrawioFileDoc(file, function(doc)
{
spinner.stop();
if (loadingPreviewFile != file)
{
return;
}
else if (doc.documentElement.nodeName == 'mxlibrary')
{
showRenderMsg(mxResources.get('noPreview'));
}
else
{
var diagrams = doc.getElementsByTagName('diagram');
curViewer = AspectDialog.prototype.createViewer(prevDiv,
diagrams.length == 0? doc.documentElement : diagrams[0],
null, 'transparent');
prevDiv.style.position = 'unset';
}
},
function() //If the file is not a draw.io diagram
{
selectedFile = null;
showRenderMsg(mxResources.get('notADiagramFile'));
});
}
catch (e)
{
selectedFile = null;
showRenderMsg(mxResources.get('notADiagramFile'));
}
};
function renderBreadcrumb()
{
var bcDiv = _$('.odFilesBreadcrumb');
if (bcDiv == null) return;
bcDiv.innerText = '';
for (var i = 0; i < breadcrumb.length - 1; i++)
{
var folder = document.createElement('span');
folder.className = 'odBCFolder';
folder.innerHTML = mxUtils.htmlEntities(breadcrumb[i].name || mxResources.get('home'));
bcDiv.appendChild(folder);
(function(bcItem, index)
{
folder.addEventListener('click', function()
{
previewFn(null);
breadcrumb = breadcrumb.slice(0, index);
fillFolderFiles(bcItem.driveId, bcItem.folderId, bcItem.siteId, bcItem.name);
});
})(breadcrumb[i], i);
var sep = document.createElement('span');
sep.innerHTML = ' &gt; ';
bcDiv.appendChild(sep);
}
if (breadcrumb[breadcrumb.length - 1] != null)
{
var curr = document.createElement('span');
curr.innerHTML = mxUtils.htmlEntities((breadcrumb.length == 1) ?
mxResources.get(foldersOnly ? 'selectFolder' : 'officeSelDiag') :
(breadcrumb[breadcrumb.length - 1].name || mxResources.get('home')));
bcDiv.appendChild(curr);
}
};
function openFile()
{
if (selectedFile == null || requestInProgress) return;
if (selectedDriveId == 'sharepoint')
{
fillFolderFiles('site', null, selectedFile.id, selectedFile.displayName);
}
else if (selectedDriveId == 'site')
{
fillFolderFiles('subsite', null, selectedFile.id, selectedFile.name);
}
else
{
var isFolder = selectedFile.folder;
selectedFile = selectedFile.remoteItem? selectedFile.remoteItem : selectedFile; //handle remote items which is accessed indirectly
var folderDI = (selectedFile.parentReference? selectedFile.parentReference.driveId : null) || selectedDriveId;
var id = selectedFile.id;
if (isFolder)
{
fillFolderFiles(folderDI, id, null, selectedFile.name);
}
else
{
doSubmit();
}
}
};
function fillFolderFiles(driveId, folderId, siteId, folderName, searchTxt)
{
if (requestInProgress) return;
_$('.odCatsList').style.display = 'block';
_$('.odFilesSec').style.display = 'block';
// _$('#signOutLnk').style.display = '';
if (prevDiv != null)
{
prevDiv.innerText = '';
}
requestInProgress = true;
var acceptRequest = true;
var isSharepointSites = 0;
lastFolderArgs = arguments;
function renderList(potentialDrawioFiles)
{
spinner.stop();
var grid = document.createElement('table');
grid.className = 'odFileListGrid';
var currentItem = null;
var count = 0;
//TODO support paging
for (var i = 0; potentialDrawioFiles!= null && i < potentialDrawioFiles.length; i++)
{
var item = potentialDrawioFiles[i];
if (isSharepointSites == 1 && item.webUrl && !(item.webUrl.indexOf('sharepoint.com/sites/') > 0 || item.webUrl.indexOf('sharepoint.com/') < 0))
{
continue;
}
var title = item.displayName || item.name;
var tooltip = mxUtils.htmlEntities(item.description || title);
if (isSharepointSites)
{
item.folder = isSharepointSites == 2? {isRoot: true} : true;
}
var isFolder = item.folder != null;
if (foldersOnly && !isFolder)
{
continue;
}
var row = document.createElement('tr');
row.className = (count++) % 2? 'odOddRow' : 'odEvenRow';
var td = document.createElement('td');
td.style.width = '36px';
var typeImg = document.createElement('img');
typeImg.src = '/images/' + (isFolder? 'folder.png' : 'file.png');
typeImg.className = 'odFileImg';
td.appendChild(typeImg);
row.appendChild(td);
td = document.createElement('td');
var titleDiv = document.createElement('div');
titleDiv.className = "odFileTitle";
titleDiv.innerHTML = mxUtils.htmlEntities(title);
titleDiv.setAttribute('title', tooltip);
td.appendChild(titleDiv);
row.appendChild(td);
grid.appendChild(row);
if (currentItem == null)
{
currentItem = row;
currentItem.className += ' odRowSelected';
selectedFile = item;
selectedDriveId = driveId;
if (!acceptAllFiles)
{
previewFn(selectedFile);
}
}
(function(item2, row2)
{
row.addEventListener('dblclick', openFile);
row.addEventListener('click', function()
{
if (currentItem != row2)
{
currentItem.className = currentItem.className.replace('odRowSelected', '');
currentItem = row2;
currentItem.className += ' odRowSelected';
selectedFile = item2;
selectedDriveId = driveId;
if (!acceptAllFiles)
{
previewFn(selectedFile);
}
}
// Double click doesn't work on touch devices
if (isMobile && item2.folder)
{
openFile();
}
});
})(item, row);
}
if (count == 0)
{
var emptyMsg = document.createElement('div');
emptyMsg.className = 'odEmptyFolder';
emptyMsg.innerHTML = mxUtils.htmlEntities(mxResources.get('folderEmpty', null, 'Folder is empty!'));
filesList.appendChild(emptyMsg);
}
else
{
filesList.appendChild(grid);
}
renderBreadcrumb();
requestInProgress = false;
};
var timeoutThread = setTimeout(function()
{
acceptRequest = false;
requestInProgress = false;
spinner.stop();
errorFn(mxResources.get('timeout'));
}, 20000); //20 sec timeout
var filesList = _$('.odFilesList');
filesList.innerText = '';
spinner.spin(filesList);
var url;
switch(driveId)
{
case 'recent':
breadcrumb = [{name: mxResources.get('recent', null, 'Recent'), driveId: driveId}];
var recentList = getRecentList() || {};
var list = [];
for (var id in recentList)
{
list.push(recentList[id]);
}
clearTimeout(timeoutThread);
renderList(list);
return;
case 'shared':
url = '/me/drive/sharedWithMe';
breadcrumb = [{name: mxResources.get('sharedWithMe', null, 'Shared With Me'), driveId: driveId}];
break;
case 'sharepoint':
url = '/sites?search=';
breadcrumb = [{name: mxResources.get('sharepointSites', null, 'Sharepoint Sites'), driveId: driveId}];
isSharepointSites = 1;
break;
case 'site':
breadcrumb.push({name: folderName, driveId: driveId, folderId: folderId, siteId: siteId});
url = '/sites/' + siteId + '/drives';
isSharepointSites = 2;
break;
case 'subsite':
breadcrumb.push({name: folderName, driveId: driveId, folderId: folderId, siteId: siteId});
url = '/drives/' + siteId + (folderId? '/items/' + folderId : '/root') + '/children';
break;
case 'search': //TODO search doesn't return any results, find out why then remove display: none from the searchBox
driveId = selectedDriveId;
breadcrumb = [{driveId: driveId, name: mxResources.get('back', null, 'Back')}];
searchTxt = encodeURIComponent(searchTxt.replace(/\'/g, '\\\''));
url = selectedSiteId? '/sites/' + selectedSiteId + '/drive/root/search(q=\'' + searchTxt + '\')' : (driveId? '/drives/' + driveId + '/root/search(q=\'' + searchTxt + '\')' : '/me/drive/root/search(q=\'' + searchTxt + '\')');
break;
default:
if (folderId == null)
{
breadcrumb = [{driveId: driveId}];
}
else
{
breadcrumb.push({name: folderName, driveId: driveId, folderId: folderId});
}
url = (driveId? '/drives/' + driveId : '/me/drive') + (folderId? '/items/' + folderId : '/root') + '/children';
}
if (!isSharepointSites)
{
url += (url.indexOf('?') > 0 ? '&' : '?') + 'select=id,name,description,parentReference,file,createdBy,lastModifiedBy,lastModifiedDateTime,size,folder,remoteItem,@microsoft.graph.downloadUrl';
}
var potentialDrawioFiles = [];
function getChunk(nextUrl)
{
getODFilesList(nextUrl? nextUrl : url, function(resp)
{
if (!acceptRequest) return;
var list = resp.value || [];
if (acceptAllFiles || isSharepointSites)
{
Array.prototype.push.apply(potentialDrawioFiles, list);
}
else
{
for (var i = 0; i < list.length; i++)
{
var file = list[i];
var mimeType = file.file? file.file.mimeType : null;
if (file.folder || mimeType == 'text/html' || mimeType == 'text/xml' || mimeType == 'application/xml' || mimeType == 'image/png'
|| /\.svg$/.test(file.name) || /\.html$/.test(file.name) || /\.xml$/.test(file.name) || /\.png$/.test(file.name)
|| /\.drawio$/.test(file.name) || /\.drawiolib$/.test(file.name) || /\.pdf$/.test(file.name))
{
potentialDrawioFiles.push(file);
}
}
// Sorts entries by type and name
potentialDrawioFiles.sort(function(a, b)
{
var nameA = a.name.toLowerCase();
var nameB = b.name.toLowerCase();
if (a.folder && !b.folder)
{
return -1;
}
else if (!a.folder && b.folder)
{
return 1;
}
else
{
if (nameA < nameB)
{
return -1;
}
else if (nameA > nameB)
{
return 1;
}
else
{
return 0;
}
}
});
}
if (resp['@odata.nextLink'] && potentialDrawioFiles.length < 1000) // TODO Support dynamic paging instead of 1000 limit
{
getChunk(resp['@odata.nextLink']);
}
else
{
clearTimeout(timeoutThread);
renderList(potentialDrawioFiles);
}
},
function(err)
{
if (!acceptRequest) return;
clearTimeout(timeoutThread);
var errMsg = null;
try
{
errMsg = JSON.parse(err.responseText).error.message;
}
catch(e){} //ignore errors
errorFn(mxResources.get('errorFetchingFolder', null, 'Error fetching folder items') +
(errMsg != null? ' (' + errMsg + ')' : ''));
requestInProgress = false;
spinner.stop();
}, nextUrl != null);
};
getChunk();
};
this.getSelectedItem = function()
{
if (selectedFile != null)
{
addToRecent(selectedFile);
}
return selectedFile;
}
//Code execution starts here
if (_$('#mxODPickerCss') == null)
{
var head = document.head || document.getElementsByTagName('head')[0],
style = document.createElement('style');
head.appendChild(style);
style.type = 'text/css';
style.id = 'mxODPickerCss';
style.appendChild(document.createTextNode(css));
}
container.innerHTML = html;
var prevDiv = _$('.odPreview');
var selectedCat = _$('#odFiles');
var cats = _$$('.odCatListTitle');
function setSelectedCat(cat)
{
selectedCat.className = selectedCat.className.replace('odCatSelected', '');
selectedCat = cat;
selectedCat.className += ' odCatSelected';
};
for (var i = 0; i < cats.length; i++)
{
cats[i].addEventListener('click', function()
{
loadingPreviewFile = null;
selectedFile = null;
if (requestInProgress) return;
setSelectedCat(this);
switch(this.id)
{
case 'odFiles':
fillFolderFiles();
break;
case 'odRecent':
fillFolderFiles('recent');
break;
case 'odShared':
fillFolderFiles('shared');
break;
case 'odSharepoint':
fillFolderFiles('sharepoint');
break;
}
});
}
//Search (Currently API doesn't work)
var delayTimer = null;
function doSearch(searchStr)
{
if (requestInProgress) return;
delayTimer = null;
fillFolderFiles('search', null, null, null, searchStr)
};
//Use keyup to detect delete and backspace
_$('#odSearchBox').addEventListener('keyup', function(evt)
{
var searchInput = this;
if (delayTimer != null)
{
clearTimeout(delayTimer);
}
if (evt.keyCode == 13)
{
doSearch(searchInput.value);
}
else
{
delayTimer = setTimeout(function()
{
doSearch(searchInput.value);
}, 500);
}
});
function refreshFolder()
{
if (lastFolderArgs != null)
{
previewFn(null);
var temp = breadcrumb.slice();
fillFolderFiles.apply(this, lastFolderArgs);
breadcrumb = temp;
}
};
_$('#refreshOD').addEventListener('click', refreshFolder);
if (backFn)
{
_$('#odBackBtn').addEventListener('click', backFn);
}
if (withSubmitBtn)
{
_$('#odSubmitBtn').addEventListener('click', doSubmit);
}
if (initFolderPath != null)
{
var folderInfo = initFolderPath.pop();
if (initFolderPath[0].driveId == 'sharepoint')
{
setSelectedCat(_$('#odSharepoint'));
}
breadcrumb = initFolderPath;
fillFolderFiles(folderInfo.driveId, folderInfo.folderId, folderInfo.siteId, folderInfo.name);
}
else
{
fillFolderFiles();
}
};

View File

@ -0,0 +1,225 @@
// Handles form-submit by preparing to process response
function handleSubmit()
{
if (window.parent.openNew && window.parent.baseUrl != null)
{
window.parent.openFile.setConsumer(null);
window.parent.open(window.parent.baseUrl);
}
// NOTE: File is loaded via JS injection into the iframe, which in turn sets the
// file contents in the parent window. The new window asks its opener if any file
// contents are available or waits for the contents to become available.
return true;
};
// Hides this dialog
function hideWindow(cancel)
{
if (window.parent.openFile != null)
{
window.parent.openFile.cancel(cancel);
}
};
function fileChanged()
{
var form = window.openForm || document.getElementById('openForm');
var openButton = document.getElementById('openButton');
if (form.upfile.value.length > 0)
{
openButton.removeAttribute('disabled');
}
else
{
openButton.setAttribute('disabled', 'disabled');
}
};
function main()
{
if (window.parent != null && window.parent.Editor != null)
{
document.body.innerText = '';
var div = document.createElement('div');
div.style.fontFamily = 'Arial';
var darkMode = window.parent.Editor.cssDarkMode ||
(typeof window.parent.Editor.isDarkMode === 'function' &&
window.parent.Editor.isDarkMode());
window.parent.listBrowserFiles(function(filesInfo)
{
if (window.parent != null)
{
if (filesInfo.length == 0)
{
window.parent.mxUtils.write(div, window.parent.mxResources.get('noFiles'));
div.style.color = (darkMode) ? '#cccccc' : '';
window.parent.mxUtils.br(div);
}
else
{
// Sorts the array by filename (titles)
filesInfo.sort(function (a, b)
{
return a.title.toLowerCase().localeCompare(b.title.toLowerCase());
});
var table = document.createElement('table');
var hrow = document.createElement('tr');
hrow.style.backgroundColor = (darkMode) ? '#000' : '#D6D6D6';
hrow.style.color = (darkMode) ? '#cccccc' : '';
hrow.style.height = '25px';
hrow.style.textAlign = 'left';
table.appendChild(hrow);
var hName = document.createElement('th');
window.parent.mxUtils.write(hName, window.parent.mxResources.get('name'));
hrow.appendChild(hName);
var hModified = document.createElement('th');
hModified.style.width = '180px';
window.parent.mxUtils.write(hModified, window.parent.mxResources.get('lastModified'));
hrow.appendChild(hModified);
var hSize = document.createElement('th');
window.parent.mxUtils.write(hSize, window.parent.mxResources.get('size'));
hSize.style.width = '70px';
hrow.appendChild(hSize);
var hCtrl = document.createElement('th');
hCtrl.style.width = '23px';
hrow.appendChild(hCtrl);
table.style.fontSize = '12pt';
table.style.width = '100%';
for (var i = 0; i < filesInfo.length; i++)
{
var fileInfo = filesInfo[i];
if (fileInfo.title.length > 0)
{
var row = document.createElement('tr');
row.style.color = (darkMode) ? '#cccccc' : '';
table.appendChild(row);
if (i & 1 == 1)
{
row.style.backgroundColor = (darkMode) ? '#000' : '#E6E6E6';
}
var nameTd = document.createElement('td');
row.appendChild(nameTd);
var link = document.createElement('a');
link.style.fontDecoration = 'none';
window.parent.mxUtils.write(link, fileInfo.title);
link.style.cursor = 'pointer';
nameTd.appendChild(link);
var modifiedTd = document.createElement('td');
row.appendChild(modifiedTd);
var str = window.parent.EditorUi.prototype.timeSince(new Date(fileInfo.lastModified));
if (str == null)
{
str = window.parent.mxResources.get('lessThanAMinute');
}
window.parent.mxUtils.write(modifiedTd, window.parent.mxResources.get('timeAgo', [str]));
var sizeTd = document.createElement('td');
row.appendChild(sizeTd);
window.parent.mxUtils.write(sizeTd, window.parent.EditorUi.prototype.formatFileSize(fileInfo.size));
var ctrlTd = document.createElement('td');
row.appendChild(ctrlTd);
ctrlTd.style.textAlign = 'center';
var img = document.createElement('span');
img.className = 'geSprite geSprite-delete';
img.style.cursor = 'pointer';
img.style.display = 'inline-block';
ctrlTd.appendChild(img);
if (darkMode)
{
img.style.filter = 'invert(100%)';
}
window.parent.mxEvent.addListener(img, 'click', (function(k)
{
return function()
{
if (window.parent.mxUtils.confirm(window.parent.mxResources.get('delete') + ' "' + k + '"?'))
{
window.parent.deleteBrowserFile(k, function()
{
window.location.reload();
});
}
};
})(fileInfo.title));
window.parent.mxEvent.addListener(link, 'click', (function(k)
{
return function()
{
if (window.parent.openNew && window.parent.baseUrl != null)
{
var of = window.parent.openFile;
window.parent.openBrowserFile(k, function(data)
{
if (window.parent != null)
{
window.parent.geOpenWindow(window.parent.baseUrl + '#L' + encodeURIComponent(k), function()
{
of.cancel(false);
}, function()
{
of.setData(data, k);
});
}
}, function()
{
//TODO add error
});
}
else
{
window.parent.openBrowserFile(k, function(data)
{
if (window.parent != null)
{
window.parent.openFile.setData(data, k);
}
}, function()
{
//TODO add error
});
}
};
})(fileInfo.title));
}
}
div.appendChild(table);
}
var closeButton = window.parent.mxUtils.button(window.parent.mxResources.get('close'), function()
{
hideWindow(true);
});
closeButton.className = 'geBtn';
closeButton.style.position = 'fixed';
closeButton.style.bottom = '0px';
closeButton.style.right = '0px';
div.appendChild(closeButton);
document.body.appendChild(div);
}
});
}
else
{
document.body.innerHTML = 'Missing parent window';
}
};
window.addEventListener('load', main);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,705 @@
/**
* Copyright (c) 2019-2020, JGraph Ltd
*/
/**
* Class: mxOrgChartLayout
*
* Extends <mxGraphLayout> to implement organization chart layout algorithm.
* The vertices need to be connected for this layout to work, vertices
* with no connections are ignored.
*
* Example:
*
* (code)
* var layout = new mxOrgChartLayout(graph);
* layout.execute(graph.getDefaultParent());
* (end)
*
*/
function mxOrgChartLayout(graph, branchOptimizer, parentChildSpacing, siblingSpacing)
{
mxGraphLayout.call(this, graph);
this.correctY = false;
switch(parseInt(branchOptimizer))
{
case 0:
this.branchOptimizer = mxOrgChartLayout.prototype.BRANCH_OPT_LINEAR;
this.correctY = true;
break;
case 1:
this.branchOptimizer = mxOrgChartLayout.prototype.BRANCH_OPT_HANGER2;
this.correctY = true;
break;
case 3:
this.branchOptimizer = mxOrgChartLayout.prototype.BRANCH_OPT_FISHBONE1;
break;
case 4:
this.branchOptimizer = mxOrgChartLayout.prototype.BRANCH_OPT_FISHBONE2;
break;
case 5:
this.branchOptimizer = mxOrgChartLayout.prototype.BRANCH_OPT_1COLUMN_L;
break;
case 6:
this.branchOptimizer = mxOrgChartLayout.prototype.BRANCH_OPT_1COLUMN_R;
break;
case 7:
this.branchOptimizer = mxOrgChartLayout.prototype.BRANCH_OPT_SMART;
break;
default: //and case 2
this.branchOptimizer = mxOrgChartLayout.prototype.BRANCH_OPT_HANGER4;
this.correctY = true;
}
this.parentChildSpacing = parentChildSpacing > 0 ? parentChildSpacing : 20;
this.siblingSpacing = siblingSpacing > 0 ? siblingSpacing : 20;
};
/**
* Extends mxGraphLayout.
*/
mxOrgChartLayout.prototype = new mxGraphLayout();
mxOrgChartLayout.prototype.constructor = mxOrgChartLayout;
//Branch Optimizers
mxOrgChartLayout.prototype.BRANCH_OPT_LINEAR = 'branchOptimizerAllLinear';
mxOrgChartLayout.prototype.BRANCH_OPT_HANGER2 = 'branchOptimizerAllHanger2';
mxOrgChartLayout.prototype.BRANCH_OPT_HANGER4 = 'branchOptimizerAllHanger4';
mxOrgChartLayout.prototype.BRANCH_OPT_FISHBONE1 = 'branchOptimizerAllFishbone1';
mxOrgChartLayout.prototype.BRANCH_OPT_FISHBONE2 = 'branchOptimizerAllFishbone2';
mxOrgChartLayout.prototype.BRANCH_OPT_1COLUMN_L = 'branchOptimizerAllSingleColumnLeft';
mxOrgChartLayout.prototype.BRANCH_OPT_1COLUMN_R = 'branchOptimizerAllSingleColumnRight';
mxOrgChartLayout.prototype.BRANCH_OPT_SMART = 'branchOptimizerSmart';
/**
* Function: execute
*
* Implements <mxGraphLayout.execute>. This operates on all children of the
* given parent.
*/
mxOrgChartLayout.prototype.execute = function(parent)
{
this.graph.model.beginUpdate();
try
{
RPOrgChart.main(this.graph, parent, this.branchOptimizer, this.parentChildSpacing, this.siblingSpacing, this.correctY);
}
finally
{
this.graph.model.endUpdate();
}
}
Bridge.define('RPOrgChart',
{
statics: {
config: {
init: function() {
}
},
main: function (graph, parent, branchOptimizer, parentChildSpacing, siblingSpacing, correctY) {
Bridge.Console.log = console.log;
Bridge.Console.error = console.error;
Bridge.Console.debug = console.debug;
RPOrgChart.graph = graph;
RPOrgChart.parent = parent;
RPOrgChart.dx = 0;
RPOrgChart.dy = 0;
if (parent.style == 'group' && parent.geometry)
{
RPOrgChart.dx = parent.geometry.x;
RPOrgChart.dy = parent.geometry.y;
}
RPOrgChart.branchOptimizer = branchOptimizer;
RPOrgChart.correctY = correctY;
RPOrgChart.parentChildSpacing = parseInt(parentChildSpacing);
RPOrgChart.siblingSpacing = parseInt(siblingSpacing);
RPOrgChart.buildChart(true);
},
diagram: {},
dataSource: {},
buildChart: function (initData) {
if (initData) {
RPOrgChart.initDiagram();
}
RPOrgChart.positionBoxes();
},
collapseAllBoxes: function(boxContainer, isCollapsed) {
var en = boxContainer.getBoxesById().getValues().getEnumerator();
while (en.moveNext()) {
var box = en.getCurrent();
if (!box.IsSpecial) {
box.IsCollapsed = isCollapsed;
}
}
},
generateData: function ()
{
var dataSource = new OrgChart.Test.TestDataSource();
var graph = RPOrgChart.graph;
var cells = graph.getChildVertices(RPOrgChart.parent);
for (var i = 0; i < cells.length; i++)
{
var cell = cells[i];
if (cell.geometry != null && cell.vertex && cell.parent == RPOrgChart.parent) //Vertices and first level children only
{
// Find cell parent. If it has more than one parent, take first parent (should be an error?)
var parentId = null;
var incomingEdge = graph.getIncomingEdges(cell)[0];
if (incomingEdge != null && incomingEdge.source != null)
{
parentId = incomingEdge.source.id;
}
var item = new OrgChart.Test.TestDataItem();
item.Id = cell.id;
item.ParentId = parentId;
dataSource.Items.add(item.getId(), item);
}
}
return dataSource;
},
initDiagram: function () {
var dataSource = RPOrgChart.generateData();
RPOrgChart.dataSource = dataSource;
var boxContainer = new OrgChart.Layout.BoxContainer.$ctor1(dataSource);
RPOrgChart.diagram = new OrgChart.Layout.Diagram();
var diagram = RPOrgChart.diagram;
diagram.setBoxes(boxContainer);
var linearLayoutStrategy = new OrgChart.Layout.LinearLayoutStrategy();
linearLayoutStrategy.ParentAlignment = OrgChart.Layout.BranchParentAlignment.Center;
linearLayoutStrategy.ParentChildSpacing = RPOrgChart.parentChildSpacing;
linearLayoutStrategy.SiblingSpacing = RPOrgChart.siblingSpacing;
diagram.LayoutSettings.LayoutStrategies.add("linear", linearLayoutStrategy);
var multiLineHangerLayoutStrategy = new OrgChart.Layout.MultiLineHangerLayoutStrategy();
multiLineHangerLayoutStrategy.ParentAlignment = OrgChart.Layout.BranchParentAlignment.Center;
multiLineHangerLayoutStrategy.MaxSiblingsPerRow = 2;
multiLineHangerLayoutStrategy.ParentChildSpacing = RPOrgChart.parentChildSpacing;
multiLineHangerLayoutStrategy.SiblingSpacing = RPOrgChart.siblingSpacing;
diagram.LayoutSettings.LayoutStrategies.add("hanger2", multiLineHangerLayoutStrategy);
multiLineHangerLayoutStrategy = new OrgChart.Layout.MultiLineHangerLayoutStrategy();
multiLineHangerLayoutStrategy.ParentAlignment = OrgChart.Layout.BranchParentAlignment.Center;
multiLineHangerLayoutStrategy.MaxSiblingsPerRow = 4;
multiLineHangerLayoutStrategy.ParentChildSpacing = RPOrgChart.parentChildSpacing;
multiLineHangerLayoutStrategy.SiblingSpacing = RPOrgChart.siblingSpacing;
diagram.LayoutSettings.LayoutStrategies.add("hanger4", multiLineHangerLayoutStrategy);
var singleColumnLayoutStrategy = new OrgChart.Layout.SingleColumnLayoutStrategy();
singleColumnLayoutStrategy.ParentAlignment = OrgChart.Layout.BranchParentAlignment.Right;
singleColumnLayoutStrategy.ParentChildSpacing = RPOrgChart.parentChildSpacing;
singleColumnLayoutStrategy.SiblingSpacing = RPOrgChart.siblingSpacing;
diagram.LayoutSettings.LayoutStrategies.add("singleColumnRight", singleColumnLayoutStrategy);
singleColumnLayoutStrategy = new OrgChart.Layout.SingleColumnLayoutStrategy();
singleColumnLayoutStrategy.ParentAlignment = OrgChart.Layout.BranchParentAlignment.Left;
singleColumnLayoutStrategy.ParentChildSpacing = RPOrgChart.parentChildSpacing;
singleColumnLayoutStrategy.SiblingSpacing = RPOrgChart.siblingSpacing;
diagram.LayoutSettings.LayoutStrategies.add("singleColumnLeft", singleColumnLayoutStrategy);
var fishboneLayoutStrategy = new OrgChart.Layout.MultiLineFishboneLayoutStrategy();
fishboneLayoutStrategy.ParentAlignment = OrgChart.Layout.BranchParentAlignment.Center;
fishboneLayoutStrategy.MaxGroups = 1;
fishboneLayoutStrategy.ParentChildSpacing = RPOrgChart.parentChildSpacing;
fishboneLayoutStrategy.SiblingSpacing = RPOrgChart.siblingSpacing;
diagram.LayoutSettings.LayoutStrategies.add("fishbone1", fishboneLayoutStrategy);
fishboneLayoutStrategy = new OrgChart.Layout.MultiLineFishboneLayoutStrategy();
fishboneLayoutStrategy.ParentAlignment = OrgChart.Layout.BranchParentAlignment.Center;
fishboneLayoutStrategy.MaxGroups = 2;
fishboneLayoutStrategy.ParentChildSpacing = RPOrgChart.parentChildSpacing;
fishboneLayoutStrategy.SiblingSpacing = RPOrgChart.siblingSpacing;
diagram.LayoutSettings.LayoutStrategies.add("fishbone2", fishboneLayoutStrategy);
var hstackLayoutStrategy = new OrgChart.Layout.StackingLayoutStrategy();
hstackLayoutStrategy.ParentAlignment = OrgChart.Layout.BranchParentAlignment.InvalidValue;
hstackLayoutStrategy.Orientation = OrgChart.Layout.StackOrientation.SingleRowHorizontal;
hstackLayoutStrategy.ParentChildSpacing = RPOrgChart.parentChildSpacing;
hstackLayoutStrategy.SiblingSpacing = RPOrgChart.siblingSpacing;
diagram.LayoutSettings.LayoutStrategies.add("hstack", hstackLayoutStrategy);
var vstackLayoutStrategy = new OrgChart.Layout.StackingLayoutStrategy();
vstackLayoutStrategy.ParentAlignment = OrgChart.Layout.BranchParentAlignment.InvalidValue;
vstackLayoutStrategy.Orientation = OrgChart.Layout.StackOrientation.SingleColumnVertical;
vstackLayoutStrategy.ParentChildSpacing = RPOrgChart.parentChildSpacing;
vstackLayoutStrategy.SiblingSpacing = RPOrgChart.siblingSpacing;
diagram.LayoutSettings.LayoutStrategies.add("vstack", vstackLayoutStrategy);
vstackLayoutStrategy = new OrgChart.Layout.StackingLayoutStrategy();
vstackLayoutStrategy.ParentAlignment = OrgChart.Layout.BranchParentAlignment.InvalidValue;
vstackLayoutStrategy.Orientation = OrgChart.Layout.StackOrientation.SingleColumnVertical;
vstackLayoutStrategy.ParentChildSpacing = RPOrgChart.parentChildSpacing;
vstackLayoutStrategy.SiblingSpacing = RPOrgChart.siblingSpacing;
diagram.LayoutSettings.LayoutStrategies.add("vstackMiddle", vstackLayoutStrategy);
vstackLayoutStrategy = new OrgChart.Layout.StackingLayoutStrategy();
vstackLayoutStrategy.ParentAlignment = OrgChart.Layout.BranchParentAlignment.InvalidValue;
vstackLayoutStrategy.Orientation = OrgChart.Layout.StackOrientation.SingleColumnVertical;
vstackLayoutStrategy.ParentChildSpacing = RPOrgChart.parentChildSpacing;
vstackLayoutStrategy.SiblingSpacing = RPOrgChart.siblingSpacing;
diagram.LayoutSettings.LayoutStrategies.add("vstackTop", vstackLayoutStrategy);
var assistantsLayoutStrategy = new OrgChart.Layout.FishboneAssistantsLayoutStrategy();
assistantsLayoutStrategy.ParentAlignment = OrgChart.Layout.BranchParentAlignment.Center;
assistantsLayoutStrategy.ParentChildSpacing = RPOrgChart.parentChildSpacing;
assistantsLayoutStrategy.SiblingSpacing = RPOrgChart.siblingSpacing;
diagram.LayoutSettings.LayoutStrategies.add("assistants", assistantsLayoutStrategy);
diagram.LayoutSettings.DefaultLayoutStrategyId = "vstack";
diagram.LayoutSettings.DefaultAssistantLayoutStrategyId = "assistants";
//diagram.LayoutSettings.setBranchSpacing(5);
},
getBoxLevel: function(boxContainer, box) {
var level = 0;
var obj = {};
while (box.ParentId > 0) {
if (!boxContainer.getBoxesById().tryGetValue(box.ParentId, obj)) {
break;
}
box = obj.v;
level++;
}
return level;
},
onLayoutStateChanged: function (sender, args) {
if (args.State.getCurrentOperation() === OrgChart.Layout.LayoutState.Operation.PreprocessVisualTree) {
// When layout algorithm is ready to preprocess the tree,
// we need to have box sizes ready -> hence have to render visible boxes in HTML.
// Rendering can happen at earlier time, but it's just more convenient to do it here,
// to utilize some readily available information about visual tree.
RPOrgChart.renderBoxes();
}
},
renderBoxes: function () {
var visitorFunc = function (node) {
var box = node.Element;
if (box.getIsDataBound()) {
// we're being run when nodes have already been marked as visible or hidden,
// based on IsCollapsed attribute of each Box
// so use this knowledge to prevent unnecessary rendering of invisible branches
if (node.State.IsHidden) {
return true;
}
box.Size = RPOrgChart.getBoxElementSize(box.DataId);
}
return true;
}
RPOrgChart.diagram.getVisualTree().IterateParentFirst(visitorFunc);
},
getBranchOptimizerFunc: function () {
return RPOrgChart[RPOrgChart.branchOptimizer];
},
branchOptimizerAllLinear: function(node) {
return node.getIsAssistantRoot() ? null : "linear";
},
branchOptimizerAllHanger2: function(node) {
return node.getIsAssistantRoot() ? null : "hanger2";
},
branchOptimizerAllHanger4: function(node) {
return node.getIsAssistantRoot() ? null : "hanger4";
},
branchOptimizerAllFishbone1: function(node) {
return node.getIsAssistantRoot() ? null : "fishbone1";
},
branchOptimizerAllFishbone2: function (node) {
return node.getIsAssistantRoot() ? null : "fishbone2";
},
branchOptimizerAllSingleColumnLeft: function (node) {
return node.getIsAssistantRoot() ? null : "singleColumnRight";
},
branchOptimizerAllSingleColumnRight: function (node) {
return node.getIsAssistantRoot() ? null : "singleColumnLeft";
},
branchOptimizerStackers: function(node) {
if (node.getIsAssistantRoot()) {
return null;
}
return node.Level === 0 // this is Node for boxContainer.SystemRoot, which is not visible itself
? "vstackTop"
: node.Level === 1 // this is children of SystemRoot - they appear as roots in the diagram
? "vstackMiddle"
: "hstack";
},
branchOptimizerSmart: function(node) {
if (node.getIsAssistantRoot()) {
return null;
}
var childCount = node.getChildCount();
if (childCount <= 1) {
return "vstack";
}
var nonLeafChildren = 0;
for (var i = 0; i < childCount; i++) {
if (node.Children.getItem(i).getChildCount() > 0) {
nonLeafChildren++;
}
}
if (nonLeafChildren <= 1) {
if (childCount <= 4) {
return "vstack";
}
if (childCount <= 8) {
return "fishbone1";
}
return "fishbone2";
}
return "hanger4";
},
boxSizeFunc: function (dataId) {
// ChartLayoutAlgorithm requires this function to accept data ID
// so have to convert it to Box ID first, to get rendered visual element
var boxId = RPOrgChart.diagram.getBoxes().getBoxesByDataId().getItem(dataId).Id;
return RPOrgChart.diagram.getBoxes().getBoxesById().getItem(boxId).Size;
},
getBoxElementSize: function (boxId) {
var geo = RPOrgChart.graph.model.cells[boxId].geometry;
return new OrgChart.Layout.Size.$ctor1(geo.width, geo.height);
},
positionBoxes: function () {
var diagram = RPOrgChart.diagram;
var state = new OrgChart.Layout.LayoutState(diagram);
state.addOperationChanged(RPOrgChart.onLayoutStateChanged);
state.BoxSizeFunc = Bridge.fn.bind(this, RPOrgChart.boxSizeFunc, null, true);
state.LayoutOptimizerFunc = Bridge.fn.bind(this, RPOrgChart.getBranchOptimizerFunc(), null, true);
OrgChart.Layout.LayoutAlgorithm.Apply(state);
var diagramBoundary = OrgChart.Layout.LayoutAlgorithm.ComputeBranchVisualBoundingRect(diagram.getVisualTree());
var offsetx = -diagramBoundary.getLeft() + diagramBoundary.getTop();
var graph = RPOrgChart.graph;
var cells = graph.model.cells;
var pointsList = [];
var visitorVertexFunc = function (node)
{
if (node.State.IsHidden) {
return false;
}
var box = node.Element;
if (box.getIsDataBound()) {
var cell = cells[box.DataId];
var geo = cell.geometry.clone();
geo.x = node.State.TopLeft.X + offsetx;
geo.y = node.State.TopLeft.Y;
graph.model.setGeometry(cell, geo);
}
return true;
}
var visitorEdgeFunc = function (node)
{
//The algorithm default is 5 px only above the node, this centers it
var yCorrection = RPOrgChart.correctY? Math.min(0, -(RPOrgChart.parentChildSpacing / 2) + 5) : 0;
// Render connectors
if (node.State.Connector != null) {
var cell = cells[node.Element.DataId];
var outgoingEdge = graph.getOutgoingEdges(cell);
var uniquePoints = {};
//Sort segments points from top to bottom or left to right + add offset
for (var ix = 0; ix < node.State.Connector.Segments.length; ix++)
{
var edge = node.State.Connector.Segments[ix];
edge.mark = 1 << ix; //TODO Support up to 31 segments. In this a limit?
edge.From.X += offsetx;
edge.To.X += offsetx;
var fx = edge.From.X, fy = edge.From.Y, tx = edge.To.X, ty = edge.To.Y;
if ((fx == tx && fy > ty) || (fy == ty && fx > tx))
{
var tmp = edge.From;
edge.From = edge.To;
edge.To = tmp;
}
}
//Collecting points including intersection of segments
for (var ix = 0; ix < node.State.Connector.Segments.length; ix++)
{
var edge = node.State.Connector.Segments[ix];
var fx = edge.From.X, fy = edge.From.Y, tx = edge.To.X, ty = edge.To.Y;
var fp = new mxPoint(fx, fy);
pointsList.push(fp);
fp.mark = edge.mark;
var up = uniquePoints[fx + ',' + fy];
if (up != null)
{
up.mark |= fp.mark;
}
else
{
uniquePoints[fx + ',' + fy] = fp;
}
var tp = new mxPoint(tx, ty);
pointsList.push(tp);
tp.mark = edge.mark;
var up = uniquePoints[tx + ',' + ty];
if (up != null)
{
up.mark |= tp.mark;
}
else
{
uniquePoints[tx + ',' + ty] = tp;
}
//Find intersections
for (var j = ix + 1; j < node.State.Connector.Segments.length; j++)
{
var e2 = node.State.Connector.Segments[j];
var fx2 = e2.From.X, fy2 = e2.From.Y, tx2 = e2.To.X, ty2 = e2.To.Y;
if (fx == tx && fy <= fy2 && ty >= fy2 && fx2 <= fx && tx2 >= fx) //Ver |_ Hor
{
var ip = new mxPoint(fx, fy2);
pointsList.push(ip);
ip.mark = edge.mark | e2.mark;
var up = uniquePoints[fx + ',' + fy2];
if (up != null)
{
up.mark |= ip.mark;
}
else
{
uniquePoints[fx + ',' + fy2] = ip;
}
}
else if (fy == ty && fx <= fx2 && tx >= fx2 && fy2 <= fy && ty2 >= fy) //Hor _| Ver
{
var ip = new mxPoint(fx2, fy);
pointsList.push(ip);
ip.mark = edge.mark | e2.mark;
var up = uniquePoints[fx2 + ',' + fy]
if (up != null)
{
up.mark |= ip.mark;
}
else
{
uniquePoints[fx2 + ',' + fy] = ip;
}
}
}
}
//Sort points on y then x
var pointsArr = [];
for (var k in uniquePoints)
{
pointsArr.push(uniquePoints[k]);
}
pointsArr.sort(function(a, b)
{
var dy = a.y - b.y;
return dy == 0? a.x - b.x : dy;
});
function pointOnCell(geo, p)
{
return p.x >= geo.x && p.x <= geo.x + geo.width && p.y >= geo.y && p.y <= geo.y + geo.height;
};
function adjustEdgeGeoAndStyle(edge, edgePoints)
{
var eGeo = edge.geometry.clone();
for (var i = 0; edgePoints && i < edgePoints.length; i++)
{
if (!edgePoints[i].corrected)
{
edgePoints[i].y += yCorrection;
edgePoints[i].corrected = true
}
}
eGeo.points = edgePoints;
graph.model.setGeometry(edge, eGeo);
//Remove entry and exit points
graph.setCellStyles('entryX', null, [edge]);
graph.setCellStyles('entryY', null, [edge]);
graph.setCellStyles('exitX', null, [edge]);
graph.setCellStyles('exitY', null, [edge]);
//Set type orthogonal
graph.setCellStyles('edgeStyle', 'orthogonalEdgeStyle', [edge]);
};
var outgoingEdge = graph.getOutgoingEdges(cell);
//Simple case of a single segment. TODO Handle this case earlier
if (pointsArr.length == 2 && outgoingEdge.length == 1)
{
adjustEdgeGeoAndStyle(outgoingEdge[0], pointsArr);
}
else
{
var srcGeo = cell.geometry;
var srcP;
//Find src starting point //TODO It should be first point always?
for (var i = 0; i < pointsArr.length; i++)
{
if (pointOnCell(srcGeo, pointsArr[i]))
{
srcP = pointsArr[i];
break;
}
}
var selected;
function getNextPoint(lp)
{
for (var i = 0; i < pointsArr.length; i++)
{
var p = pointsArr[i];
if (selected[p.x + ',' + p.y]) continue;
if (p.mark & lp.mark)
{
selected[p.x + ',' + p.y] = true;
return p;
}
}
}
for (var j = 0; j < outgoingEdge.length; j++)
{
if (outgoingEdge[j].target != null)
{
selected = {};
selected[srcP.x + ',' + srcP.y] = true;
var trgGeo = outgoingEdge[j].target.geometry;
var edgePoints = [srcP];
var lp = srcP;
var safeGuard = 0;
//Is BFS better?
while (safeGuard < 1000)
{
safeGuard++;
var np = getNextPoint(lp);
//retract, then remove this point
if (np == null)
{
edgePoints.pop();
lp = edgePoints[edgePoints.length - 1];
}
else
{
edgePoints.push(np);
lp = np;
if (pointOnCell(trgGeo, np)) break;
}
}
//Remove retracted points TODO can we do it in a better way?
if (edgePoints.length > 2)
{
var spX = edgePoints[0].x;
var lpX = edgePoints[edgePoints.length - 1].x;
for (var i = edgePoints.length - 2; i > 0; i--)
{
if ((spX > lpX && edgePoints[i].x < lpX) || (spX < lpX && edgePoints[i].x < spX))
{
edgePoints.splice(i, 1);
}
}
}
var eGeo = outgoingEdge[j].geometry.clone();
eGeo.points = edgePoints;
RPOrgChart.graph.model.setGeometry(outgoingEdge[j], eGeo);
//Fix edge points and style
adjustEdgeGeoAndStyle(outgoingEdge[j], edgePoints);
}
}
}
}
return true;
}
diagram.getVisualTree().IterateParentFirst(visitorVertexFunc);
diagram.getVisualTree().IterateParentFirst(visitorEdgeFunc);
//Cleanup
for (var i = 0; i < pointsList.length; i++)
{
delete pointsList[i].mark;
delete pointsList[i].corrected;
}
}
}
});
Bridge.init();

View File

@ -0,0 +1 @@
Used roughjs 4.6.6 from https://unpkg.com/roughjs@4.6.6/bundled/rough.js

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,2 @@
//fgnass.github.com/spin.js#v2.0.0
!function(a,b){"object"==typeof exports?module.exports=b():"function"==typeof define&&define.amd?define(b):a.Spinner=b()}(this,function(){"use strict";function a(a,b){var c,d=document.createElement(a||"div");for(c in b)d[c]=b[c];return d}function b(a){for(var b=1,c=arguments.length;c>b;b++)a.appendChild(arguments[b]);return a}function c(a,b,c,d){var e=["opacity",b,~~(100*a),c,d].join("-"),f=.01+c/d*100,g=Math.max(1-(1-a)/b*(100-f),a),h=j.substring(0,j.indexOf("Animation")).toLowerCase(),i=h&&"-"+h+"-"||"";return l[e]||(m.insertRule("@"+i+"keyframes "+e+"{0%{opacity:"+g+"}"+f+"%{opacity:"+a+"}"+(f+.01)+"%{opacity:1}"+(f+b)%100+"%{opacity:"+a+"}100%{opacity:"+g+"}}",m.cssRules.length),l[e]=1),e}function d(a,b){var c,d,e=a.style;for(b=b.charAt(0).toUpperCase()+b.slice(1),d=0;d<k.length;d++)if(c=k[d]+b,void 0!==e[c])return c;return void 0!==e[b]?b:void 0}function e(a,b){for(var c in b)a.style[d(a,c)||c]=b[c];return a}function f(a){for(var b=1;b<arguments.length;b++){var c=arguments[b];for(var d in c)void 0===a[d]&&(a[d]=c[d])}return a}function g(a,b){return"string"==typeof a?a:a[b%a.length]}function h(a){this.opts=f(a||{},h.defaults,n)}function i(){function c(b,c){return a("<"+b+' xmlns="urn:schemas-microsoft.com:vml" class="spin-vml">',c)}m.addRule(".spin-vml","behavior:url(#default#VML)"),h.prototype.lines=function(a,d){function f(){return e(c("group",{coordsize:k+" "+k,coordorigin:-j+" "+-j}),{width:k,height:k})}function h(a,h,i){b(m,b(e(f(),{rotation:360/d.lines*a+"deg",left:~~h}),b(e(c("roundrect",{arcsize:d.corners}),{width:j,height:d.width,left:d.radius,top:-d.width>>1,filter:i}),c("fill",{color:g(d.color,a),opacity:d.opacity}),c("stroke",{opacity:0}))))}var i,j=d.length+d.width,k=2*j,l=2*-(d.width+d.length)+"px",m=e(f(),{position:"absolute",top:l,left:l});if(d.shadow)for(i=1;i<=d.lines;i++)h(i,-2,"progid:DXImageTransform.Microsoft.Blur(pixelradius=2,makeshadow=1,shadowopacity=.3)");for(i=1;i<=d.lines;i++)h(i);return b(a,m)},h.prototype.opacity=function(a,b,c,d){var e=a.firstChild;d=d.shadow&&d.lines||0,e&&b+d<e.childNodes.length&&(e=e.childNodes[b+d],e=e&&e.firstChild,e=e&&e.firstChild,e&&(e.opacity=c))}}var j,k=["webkit","Moz","ms","O"],l={},m=function(){var c=a("style",{type:"text/css"});return b(document.getElementsByTagName("head")[0],c),c.sheet||c.styleSheet}(),n={lines:12,length:7,width:5,radius:10,rotate:0,corners:1,color:"#000",direction:1,speed:1,trail:100,opacity:.25,fps:20,zIndex:2e9,className:"spinner",top:"50%",left:"50%",position:"absolute"};h.defaults={},f(h.prototype,{spin:function(b){this.stop();{var c=this,d=c.opts,f=c.el=e(a(0,{className:d.className}),{position:d.position,width:0,zIndex:d.zIndex});d.radius+d.length+d.width}if(b&&(b.insertBefore(f,b.firstChild||null),e(f,{left:d.left,top:d.top})),f.setAttribute("role","progressbar"),c.lines(f,c.opts),!j){var g,h=0,i=(d.lines-1)*(1-d.direction)/2,k=d.fps,l=k/d.speed,m=(1-d.opacity)/(l*d.trail/100),n=l/d.lines;!function o(){h++;for(var a=0;a<d.lines;a++)g=Math.max(1-(h+(d.lines-a)*n)%l*m,d.opacity),c.opacity(f,a*d.direction+i,g,d);c.timeout=c.el&&setTimeout(o,~~(1e3/k))}()}return c},stop:function(){var a=this.el;return a&&(clearTimeout(this.timeout),a.parentNode&&a.parentNode.removeChild(a),this.el=void 0),this},lines:function(d,f){function h(b,c){return e(a(),{position:"absolute",width:f.length+f.width+"px",height:f.width+"px",background:b,boxShadow:c,transformOrigin:"left",transform:"rotate("+~~(360/f.lines*k+f.rotate)+"deg) translate("+f.radius+"px,0)",borderRadius:(f.corners*f.width>>1)+"px"})}for(var i,k=0,l=(f.lines-1)*(1-f.direction)/2;k<f.lines;k++)i=e(a(),{position:"absolute",top:1+~(f.width/2)+"px",transform:f.hwaccel?"translate3d(0,0,0)":"",opacity:f.opacity,animation:j&&c(f.opacity,f.trail,l+k*f.direction,f.lines)+" "+1/f.speed+"s linear infinite"}),f.shadow&&b(i,e(h("#000","0 0 4px #000"),{top:"2px"})),b(d,b(i,h(g(f.color,k),"0 0 1px rgba(0,0,0,.1)")));return d},opacity:function(a,b,c){b<a.childNodes.length&&(a.childNodes[b].style.opacity=c)}});var o=e(a("group"),{behavior:"url(#default#VML)"});return!d(o,"transform")&&o.adj?i():j=d(o,"animation"),h});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,81 @@
var mxIsElectron = navigator.userAgent != null &&
navigator.userAgent.toLowerCase().indexOf(' electron/') > -1 &&
navigator.userAgent.indexOf(' draw.io/') > -1;
/**
* Adds meta tag to the page.
*/
function mxmeta(content, httpEquiv)
{
try
{
var s = document.createElement('meta');
s.setAttribute('content', content);
s.setAttribute('http-equiv', httpEquiv);
var t = document.getElementsByTagName('meta')[0];
t.parentNode.insertBefore(s, t);
}
catch (e)
{
// ignore
}
};
function doImport(vsdxBuff, callback, error, file, customParam)
{
EditorUi.prototype.createUi = function(){};
EditorUi.prototype.addTrees = function(){};
EditorUi.prototype.updateActionStates = function(){};
var editorUi = new EditorUi();
var blob = file? file : new Blob([vsdxBuff], {type: 'application/octet-stream'});
editorUi.importVisio(blob, callback, error, file? file.name : null, customParam);
};
if (mxIsElectron)
{
mxmeta('default-src \'self\'; script-src \'self\'; connect-src \'self\' https://*.draw.io https://*.diagrams.net https://fonts.googleapis.com https://fonts.gstatic.com; img-src * data:; media-src *; font-src *; frame-src \'none\'; style-src \'self\' \'unsafe-inline\' https://fonts.googleapis.com; base-uri \'none\';child-src \'self\';object-src \'none\';', 'Content-Security-Policy');
electron.registerMsgListener('import', (vsdxBuff) =>
{
doImport(vsdxBuff, function(xml)
{
electron.sendMessage('import-success', xml);
},
function()
{
electron.sendMessage('import-error');
});
});
}
window.addEventListener('load', function()
{
document.getElementById('fileUpload').addEventListener('change', function()
{
const curFiles = this.files;
if(curFiles.length > 0)
{
function createDoneDiv(msg)
{
var doneDiv = document.createElement('div');
doneDiv.id = 'doneDiv';
doneDiv.innerHTML = msg;
document.body.appendChild(doneDiv);
};
doImport(null, function(xml)
{
window.importResXML = xml;
createDoneDiv('success');
}, function(err)
{
console.log(err)
createDoneDiv('error');
}, curFiles[0], window.customParam);
}
});
});