Update file load and save + parent selection get and set + debug bookmarklet compiler + frame view image (only)
This commit is contained in:
parent
cb62ddab67
commit
4f7fd380d4
7
app.html
7
app.html
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
<menu>
|
<menu>
|
||||||
<button select-get title="Get selected text on the page"
|
<button select-get title="Get selected text on the page"
|
||||||
onclick="$text.value = getParentSelection()">
|
onclick="$text.value = CC.bin2buffer(getParentSelection())">
|
||||||
<i class="fas fa-align-left"></i>
|
<i class="fas fa-align-left"></i>
|
||||||
<i class="fas fa-caret-down"></i>
|
<i class="fas fa-caret-down"></i>
|
||||||
</button>
|
</button>
|
||||||
|
@ -44,7 +44,7 @@
|
||||||
<button open title="Load a file from disk"
|
<button open title="Load a file from disk"
|
||||||
onclick="$`[type=file]`.click()">
|
onclick="$`[type=file]`.click()">
|
||||||
<i class="far fa-folder-open"></i>
|
<i class="far fa-folder-open"></i>
|
||||||
<input type="file" onchange="read(this.files[0]).then( s=> $text.value = s ); $filename.value = this.files[0].name"/>
|
<input type="file" onchange="read(this.files[0]).then( a=> $text.value = a ); $filename.value = this.files[0].name"/>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<input filename type="text" eo:placeHolder="Filo nami" en:placeHolder="File name" fr:placeHolder="Nom du fichier"/>
|
<input filename type="text" eo:placeHolder="Filo nami" en:placeHolder="File name" fr:placeHolder="Nom du fichier"/>
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
<i class="far fa-save"></i>
|
<i class="far fa-save"></i>
|
||||||
</button>
|
</button>
|
||||||
<button select-set en:title="Replace selected text on the page" fr:title="Remplacer la séléction" eo:title="Sovargi al disko"
|
<button select-set en:title="Replace selected text on the page" fr:title="Remplacer la séléction" eo:title="Sovargi al disko"
|
||||||
onclick="setParentSelection( $text.value )">
|
onclick="setParentSelection( buffer2bin($text.value) )">
|
||||||
<i class="fas fa-align-left"></i>
|
<i class="fas fa-align-left"></i>
|
||||||
<i class="fas fa-caret-up"></i>
|
<i class="fas fa-caret-up"></i>
|
||||||
</button>
|
</button>
|
||||||
|
@ -102,6 +102,7 @@
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
background: white;
|
||||||
}
|
}
|
||||||
:host-context([frame]) iframe { display: block; }
|
:host-context([frame]) iframe { display: block; }
|
||||||
button {
|
button {
|
||||||
|
|
8
app.js
8
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`
|
, $text = $`ui-data`
|
||||||
, $filename = $`[filename]`
|
, $filename = $`[filename]`
|
||||||
|
|
||||||
opener && document.documentElement.classtList.add('parented')
|
opener && document.documentElement.classList.add('parented')
|
||||||
// sel=opener.document.getSelection().type=='None'||'Range'
|
// sel=opener.document.getSelection().type=='None'||'Range'
|
||||||
|
|
||||||
const getParentSelection = ()=> opener && opener.document.getSelection().toString()
|
const getParentSelection = ()=> opener && opener.document.getSelection().toString()
|
||||||
|
@ -127,7 +127,7 @@ const read = file=> new Promise( (ok,ko)=> {
|
||||||
let r = new FileReader()
|
let r = new FileReader()
|
||||||
r.onload = e=> ok( r.result )
|
r.onload = e=> ok( r.result )
|
||||||
r.onerror = e=> ko()
|
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 buffer2utf8 = buf=> bin2utf8( buffer2bin(buf) )
|
||||||
|
|
||||||
const utf82bin = str=> encodeURIComponent(str)
|
const utf82bin = str=> encodeURIComponent(str)
|
||||||
// replaces any uri escape sequence, such as %0A,
|
/* replaces any uri escape sequence, such as %0A, */
|
||||||
// with binary escape, such as 0x0A
|
/* with binary escape, such as 0x0A */
|
||||||
.replace(/%([0-9A-F]{2})/g, (s,$1)=> String.fromCharCode(parseInt($1, 16)) )
|
.replace(/%([0-9A-F]{2})/g, (s,$1)=> String.fromCharCode(parseInt($1, 16)) )
|
||||||
|
|
||||||
const utf82buffer = str=> bin2buffer(utf82bin(str))
|
const utf82buffer = str=> bin2buffer(utf82bin(str))
|
||||||
|
|
|
@ -4,13 +4,20 @@ writeFileSync(
|
||||||
'kriptoptlet'
|
'kriptoptlet'
|
||||||
, `javascript:win=window.open('','','titlebar=no,location=no');win.document.write(\`${
|
, `javascript:win=window.open('','','titlebar=no,location=no');win.document.write(\`${
|
||||||
readFileSync('kriptopter', 'utf8')
|
readFileSync('kriptopter', 'utf8')
|
||||||
|
.replace(/\\/g,'\\\\')
|
||||||
|
.replace(/%0A/g,'\%0A')
|
||||||
.replace(/`/g,'\\`')
|
.replace(/`/g,'\\`')
|
||||||
.replace(/\$\{/g,'\\${')
|
.replace(/\$\{/g,'\\${')
|
||||||
.replace(/\n/g,'\\n')
|
.replace(/\n/g,'\\n')
|
||||||
|
.replace(/\t/g,'\\t')
|
||||||
}\`)`
|
}\`)`
|
||||||
, 'utf8'
|
, '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) )
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
2
ui.js
2
ui.js
|
@ -82,6 +82,8 @@ class Data extends UI {
|
||||||
console.log(arguments)
|
console.log(arguments)
|
||||||
if( newValue != null && this._value && CC['buffer2'+this.type] )
|
if( newValue != null && this._value && CC['buffer2'+this.type] )
|
||||||
this.shadowRoot.$`textarea`.value = CC['buffer2'+this.type]( this._value )
|
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'}) )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue