This repository has been archived by the owner on Apr 22, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.svelte
83 lines (57 loc) · 2.37 KB
/
main.svelte
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<script>
export let OLSKPasscodeDispatchContinue;
export const modPublic = {};
import { OLSKLocalized } from 'OLSKInternational';
import OLSKCrypto from 'OLSKCrypto';
import OLSKPasscodeLogic from './ui-logic.js';
Object.assign(modPublic, OLSKPasscodeLogic);
const mod = {
_OLSKModalView: null,
// VALUE
_ValueContinueDisabled: true,
// DATA
DataContinueEnabled () {
return mod._ValuePassword1 && mod._ValuePassword2 && (mod._ValuePassword1 === mod._ValuePassword2) && mod._ValueFutile;
},
// INTERFACE
InterfaceFutileFieldDidInput () {
mod._ValueContinueDisabled = !mod.DataContinueEnabled();
},
InterfaceContinueButtonDidClick () {
mod.ControlSet(mod._ValuePassword1);
mod._OLSKModalView.modPublic.OLSKModalViewClose();
OLSKPasscodeDispatchContinue();
},
// CONTROL
async ControlSet (inputData) {
localStorage.setItem('OLSK_PASSCODE_HASH', OLSKCrypto.OLSKCryptoPBKDF2Hash(await OLSKCrypto.OLSKCryptoPBKDF2Key(inputData)));
mod._ValuePassword1 = mod._ValuePassword2 = '';
mod._ValueFutile = false;
},
// LIFECYCLE
LifecycleModuleDidMount() {
Object.assign(modPublic, mod._OLSKModalView.modPublic);
},
};
import { onMount } from 'svelte';
onMount(mod.LifecycleModuleDidMount);
import OLSKModalView from 'OLSKModalView';
</script>
<OLSKModalView bind:this={ mod._OLSKModalView } OLSKModalViewTitleText={ OLSKLocalized('OLSKPasscodeLauncherItemConfigureText') }>
<div class="OLSKPasscode OLSKDecor">
<div>
<div class="OLSKPasscodeBackupNotice">{ OLSKLocalized('OLSKPasscodeBackupNoticeText') }</div>
<p><input class="OLSKPasscodePasswordField1" type="password" placeholder={ OLSKLocalized('OLSKPasscodePasswordField1Text') } bind:value={ mod._ValuePassword1 } /></p>
<p><input class="OLSKPasscodePasswordField2" type="password" placeholder={ OLSKLocalized('OLSKPasscodePasswordField2Text') } bind:value={ mod._ValuePassword2 } /></p>
<p>
<label class="OLSKPasscodeFutileFieldLabel">
<input class="OLSKPasscodeFutileField" type="checkbox" bind:checked={ mod._ValueFutile } on:change={ mod.InterfaceFutileFieldDidInput } />
{ OLSKLocalized('OLSKPasscodeFutileFieldLabelText') }
</label>
</p>
<p>
<button class="OLSKPasscodeContinueButton" disabled={ mod._ValueContinueDisabled } on:click={ mod.InterfaceContinueButtonDidClick }>{ OLSKLocalized('OLSKPasscodeContinueButtonText') }</button>
</p>
</div>
</div>
</OLSKModalView>