diff --git a/app.html b/app.html index 46ad8dd..27a6908 100644 --- a/app.html +++ b/app.html @@ -28,7 +28,7 @@ @@ -44,7 +44,7 @@ @@ -54,7 +54,7 @@ @@ -102,6 +102,7 @@ position: absolute; top: 0; box-sizing: border-box; + background: white; } :host-context([frame]) iframe { display: block; } button { diff --git a/app.js b/app.js index 31b6f47..cb4ef2b 100644 --- a/app.js +++ b/app.js @@ -7,7 +7,7 @@ const algo = { name: "AES-GCM", iv: Uint8Array.from([120,1,248,135,62,71,87,156, , $text = $`ui-data` , $filename = $`[filename]` -opener && document.documentElement.classtList.add('parented') +opener && document.documentElement.classList.add('parented') // sel=opener.document.getSelection().type=='None'||'Range' const getParentSelection = ()=> opener && opener.document.getSelection().toString() @@ -127,7 +127,7 @@ const read = file=> new Promise( (ok,ko)=> { let r = new FileReader() r.onload = e=> ok( r.result ) r.onerror = e=> ko() - r.readAsText( file ) + r.readAsArrayBuffer( file ) }) @@ -172,8 +172,8 @@ const bin2utf8 = binstr=> decodeURIComponent( const buffer2utf8 = buf=> bin2utf8( buffer2bin(buf) ) const utf82bin = str=> encodeURIComponent(str) - // replaces any uri escape sequence, such as %0A, - // with binary escape, such as 0x0A + /* replaces any uri escape sequence, such as %0A, */ + /* with binary escape, such as 0x0A */ .replace(/%([0-9A-F]{2})/g, (s,$1)=> String.fromCharCode(parseInt($1, 16)) ) const utf82buffer = str=> bin2buffer(utf82bin(str)) diff --git a/kompilo.js b/kompilo.js index 31de557..e1feee7 100644 --- a/kompilo.js +++ b/kompilo.js @@ -4,13 +4,20 @@ writeFileSync( 'kriptoptlet' , `javascript:win=window.open('','','titlebar=no,location=no');win.document.write(\`${ readFileSync('kriptopter', 'utf8') + .replace(/\\/g,'\\\\') + .replace(/%0A/g,'\%0A') .replace(/`/g,'\\`') .replace(/\$\{/g,'\\${') .replace(/\n/g,'\\n') + .replace(/\t/g,'\\t') }\`)` , 'utf8' ) +/* +javascript:win=window.open('','','titlebar=no,location=no'); fetch('https://git.p2p.legal/dig/kriptopter/raw/master/kriptopter').then(res=>res.text()).then(app=>win.document.write(app) ) +*/ + diff --git a/ui.js b/ui.js index 919fc37..eebb81e 100644 --- a/ui.js +++ b/ui.js @@ -82,6 +82,8 @@ class Data extends UI { console.log(arguments) if( newValue != null && this._value && CC['buffer2'+this.type] ) this.shadowRoot.$`textarea`.value = CC['buffer2'+this.type]( this._value ) + else if( this.type == 'frame' ) + this.shadowRoot.$`iframe`.src = URL.createObjectURL(new File([$text.value],'file.jpg',{type: 'image/jpeg'}) ) } }