Add ui for setting max downloads, max time, and password.
This commit is contained in:
parent
fe4eb1d582
commit
5ec2486c57
8 changed files with 134 additions and 5 deletions
10
android/pages/error.js
Normal file
10
android/pages/error.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
const html = require('choo/html');
|
||||
|
||||
export default function error(_state, _emit) {
|
||||
return html`<body>
|
||||
<div id="white">
|
||||
<h1>Error</h1>
|
||||
<p>Sorry, an error occurred.</p>
|
||||
</div>
|
||||
</body>`;
|
||||
}
|
|
@ -5,6 +5,7 @@ export default function mainPage(state, emit) {
|
|||
event.preventDefault();
|
||||
emit('pushState', '/preferences');
|
||||
}
|
||||
|
||||
function uploadFile(event) {
|
||||
event.preventDefault();
|
||||
const target = event.target;
|
||||
|
@ -13,15 +14,16 @@ export default function mainPage(state, emit) {
|
|||
return;
|
||||
}
|
||||
|
||||
emit('pushState', '/upload');
|
||||
emit('pushState', '/options');
|
||||
emit('addFiles', { files: [file] });
|
||||
emit('upload', {});
|
||||
}
|
||||
|
||||
return html`<body>
|
||||
<div id="white">
|
||||
<div id="centering">
|
||||
<a href="#" onclick=${clickPreferences}>
|
||||
preferenes
|
||||
<img id="top-banner" src=${state.getAsset('top-banner.png')} />
|
||||
<a id="hamburger" href="#" onclick=${clickPreferences}>
|
||||
<img src=${state.getAsset('preferences.png')} />
|
||||
</a>
|
||||
<img src=${state.getAsset('encrypted-envelope.png')} />
|
||||
<h4>Private, Encrypted File Sharing</h4>
|
||||
|
|
94
android/pages/options.js
Normal file
94
android/pages/options.js
Normal file
|
@ -0,0 +1,94 @@
|
|||
const html = require('choo/html');
|
||||
|
||||
export default function options(state, emit) {
|
||||
function clickCancel(event) {
|
||||
event.preventDefault();
|
||||
emit('pushState', '/');
|
||||
}
|
||||
|
||||
async function submitForm(event) {
|
||||
event.preventDefault();
|
||||
if (this.addPassword.checked) {
|
||||
if (this.password.value !== this.confirmPassword.value) {
|
||||
state.passwordDoesNotMatchError = true;
|
||||
emit('render');
|
||||
return;
|
||||
} else {
|
||||
state.passwordDoesNotMatchError = false;
|
||||
}
|
||||
}
|
||||
emit('upload', {
|
||||
type: 'click',
|
||||
dlimit: parseInt(event.target.numDownloads.value),
|
||||
password: event.target.password.value
|
||||
});
|
||||
emit('pushState', '/upload');
|
||||
}
|
||||
|
||||
function addPasswordChange(event) {
|
||||
const pw = document.getElementById('password-section');
|
||||
if (event.target.checked) {
|
||||
pw.style.display = 'block';
|
||||
} else {
|
||||
pw.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
const passwordDoesNotMatchDisplayStyle = state.passwordDoesNotMatchError
|
||||
? 'display: block'
|
||||
: 'display: none';
|
||||
const passwordChecked = state.passwordDoesNotMatchError ? true : false;
|
||||
|
||||
return html`<body>
|
||||
<div id="white">
|
||||
<div id="options">
|
||||
<a onclick=${clickCancel} class="cancel" href="#">
|
||||
cancel
|
||||
</a>
|
||||
<h5>Selected files</h5>
|
||||
<ul>
|
||||
<li>file</li>
|
||||
</ul>
|
||||
<div id="options-controls">
|
||||
<form onsubmit=${submitForm}>
|
||||
<div id="expires-after-section">
|
||||
<h5>Expires after</h5>
|
||||
<select name="numDownloads">
|
||||
<option value="1">1 download</option>
|
||||
<option value="2">2 downloads</option>
|
||||
<option value="3">3 downloads</option>
|
||||
<option value="4">4 downloads</option>
|
||||
<option value="5">5 downloads</option>
|
||||
<option value="20">20 downloads</option>
|
||||
<option value="50">50 downloads</option>
|
||||
<option value="100">100 downloads</option>
|
||||
<option value="200">200 downloads</option>
|
||||
</select>
|
||||
or
|
||||
<select name="maxTime">
|
||||
<option value="300">5 minutes</option>
|
||||
<option value="3600">1 hour</option>
|
||||
<option value="86400" selected="true">24 hours</option>
|
||||
<option value="604800">7 days</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="set-password-section">
|
||||
<input onchange=${addPasswordChange} name="addPassword" autocomplete="off" type="checkbox" checked=${passwordChecked}>
|
||||
<label for="addPassword">Protect with password</label>
|
||||
<div id="password-section" style=${passwordDoesNotMatchDisplayStyle}>
|
||||
<div style=${passwordDoesNotMatchDisplayStyle}>
|
||||
Passwords must match.
|
||||
</div>
|
||||
<h5>Password:</h5>
|
||||
<input name="password" type="password" />
|
||||
<h5>Confirm password:</h5>
|
||||
<input name="confirmPassword" type="password" />
|
||||
</div>
|
||||
</div>
|
||||
<button>Send</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>`;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue