mirror of
https://github.com/tlsnotary/PageSigner.git
synced 2026-01-08 22:27:57 -05:00
check that file picker was fully loaded
This commit is contained in:
@@ -1,43 +0,0 @@
|
||||
<style>
|
||||
body {
|
||||
background-image: linear-gradient(to right bottom, #d1d1d1, #d8d8d8, #dfdfdf, #e7e7e7, #eeeeee);
|
||||
}
|
||||
label {
|
||||
position: absolute;
|
||||
top: 100px;
|
||||
right: 40px;
|
||||
}
|
||||
|
||||
input[type="file"] {
|
||||
display: none;
|
||||
}
|
||||
.custom-file-upload {
|
||||
display: inline-block;
|
||||
background-color: #7b38d8;
|
||||
border-radius: 10px;
|
||||
border: 4px double #cccccc;
|
||||
color: #eeeeee;
|
||||
text-align: center;
|
||||
font-size: 28px;
|
||||
padding: 20px;
|
||||
width: 200px;
|
||||
-webkit-transition: all 0.5s;
|
||||
-moz-transition: all 0.5s;
|
||||
-o-transition: all 0.5s;
|
||||
transition: all 0.5s;
|
||||
cursor: pointer;
|
||||
margin: 5px;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<body>
|
||||
|
||||
<label for="import" class="custom-file-upload">
|
||||
Click to open a pgsg file
|
||||
</label>
|
||||
<input id="import" type="file"/>
|
||||
|
||||
|
||||
<script src="file_picker.js"></script>
|
||||
</body>
|
||||
@@ -118,17 +118,37 @@ function openFilePicker(){
|
||||
|
||||
chrome.tabs.create({url: url},
|
||||
async function(t){
|
||||
setTimeout(async function(){
|
||||
var myViews = chrome.extension.getViews();
|
||||
for (let win of myViews){
|
||||
if (myTabs.includes(win.tabid)) continue;
|
||||
//found a new tab
|
||||
win.showFilePicker()
|
||||
win.tabid = t.id;
|
||||
var is_testing = await getPref('testing')
|
||||
if (is_testing) win.prepare_testing()
|
||||
}
|
||||
}, 100)
|
||||
|
||||
function check(){
|
||||
|
||||
console.log('checking if file picker is ready...')
|
||||
setTimeout(async function(){
|
||||
var myViews = chrome.extension.getViews();
|
||||
//sometimes the View for the newly opened tab may not yet be available
|
||||
//so we must wait a little longer
|
||||
var isViewReady = false;
|
||||
for (let win of myViews){
|
||||
if (myTabs.includes(win.tabid)) continue;
|
||||
//found a new tab
|
||||
if (typeof(win.showFilePicker) == 'undefined') {
|
||||
//viewer.js hasnt yet been loaded into the DOM
|
||||
check();
|
||||
return;
|
||||
}
|
||||
isViewReady = true;
|
||||
win.showFilePicker()
|
||||
win.tabid = t.id;
|
||||
var is_testing = await getPref('testing')
|
||||
if (is_testing) win.prepare_testing()
|
||||
}
|
||||
if (! isViewReady){
|
||||
check();
|
||||
}
|
||||
}, 10)
|
||||
|
||||
}
|
||||
check();
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user