Skip to content

Commit

Permalink
Import from webcam available #141
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Nov 24, 2021
1 parent 290d463 commit 79ebfe3
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 76 deletions.
4 changes: 2 additions & 2 deletions app/import/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ <h4>
</svg>
Choose image(s)
</button>
<button class="buttoni hidden mb-5" id="but2" onclick="qrCamera()">
<button class="buttoni mb-5" id="but2" onclick="qrCamera()">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 9a2 2 0 012-2h.93a2 2 0 001.664-.89l.812-1.22A2 2 0 0110.07 4h3.86a2 2 0 011.664.89l.812 1.22A2 2 0 0018.07 7H19a2 2 0 012 2v9a2 2 0 01-2 2H5a2 2 0 01-2-2V9z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 13a3 3 0 11-6 0 3 3 0 016 0z" />
Expand Down Expand Up @@ -111,7 +111,7 @@ <h4>
</svg>
Choose image(s)
</button>
<button class="buttoni hidden mb-5" id="but3" onclick="gaCamera()">
<button class="buttoni mb-5" id="but3" onclick="gaCamera()">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 9a2 2 0 012-2h.93a2 2 0 001.664-.89l.812-1.22A2 2 0 0110.07 4h3.86a2 2 0 011.664.89l.812 1.22A2 2 0 0018.07 7H19a2 2 0 012 2v9a2 2 0 01-2 2H5a2 2 0 01-2-2V9z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 13a3 3 0 11-6 0 3 3 0 016 0z" />
Expand Down
5 changes: 0 additions & 5 deletions app/import/src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ const folder_path = dev ? path.join(app.getPath("appData"), "Levminer", "Authme
*/
const settings = JSON.parse(fs.readFileSync(path.join(folder_path, "settings", "settings.json"), "utf-8"))

if (settings.experimental.webcam === true) {
document.querySelector("#but2").style.display = "inline-block"
document.querySelector("#but3").style.display = "inline-block"
}

// ? check for webcam
const checkWebcam = (callback) => {
const md = navigator.mediaDevices
Expand Down
15 changes: 3 additions & 12 deletions app/settings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -919,20 +919,11 @@ <h4>You can choose how to sort the saved and loaded codes. By default codes are
</div>
</div>
<h4 class="text-popup-yellow font-bold mb-0">This feature is WIP! It might be unstable or buggy!</h4>
<!--
<br />
<hr />
<h3>Use webcam for import</h3>
<h4>You can use your webcam to scan QR code(s). Works well with high quality webcams.</h4>
<div class="flex justify-center items-center w-72 h-[68px] bg-white mx-auto rounded-full">
<a href="#" onclick="webcam()">
<div class="pointer-events-none relative inline-block w-10 mr-2 align-middle select-none bg-gray-900 border-2 border-gray-900 rounded-full">
<input tabindex="-1" id="tgl8" type="checkbox" class="toggle" />
<label for="tgl8" class="toggle-bg block overflow-hidden h-6 rounded-full bg-white cursor-pointer"></label></div
></a>
<span id="tgt8" class="text-black text-xl">-</span>
</div>
<h4 class="text-popup-yellow font-bold mb-0">This feature is WIP! It might be unstable or buggy!</h4>
<!-- <h4 class="text-popup-red font-bold mb-0">This feature is WIP! Use it at your own risk!</h4> -->
<h4 class="text-popup-red font-bold mb-0">This feature is WIP! Use it at your own risk!</h4>
-->
</div>
</div>
</div>
Expand Down
57 changes: 0 additions & 57 deletions app/settings/src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,17 +172,6 @@ if (hardware_state === true) {
tgl7.checked = true
}

// webcam
let webcam_state = settings.experimental.webcam

if (webcam_state === true) {
tgt8.textContent = "On"
tgl8.checked = true
} else {
tgt8.textContent = "Off"
tgl8.checked = false
}

// ? startup
const startup = () => {
if (startup_state == true) {
Expand Down Expand Up @@ -565,52 +554,6 @@ const dropdownChoose = (id) => {
ipc.send("reload_application")
}

// ? webcam
const webcam = () => {
const toggle = () => {
if (webcam_state === true) {
settings.experimental.webcam = false

save()

tgt8.textContent = "Off"
tgl8.checked = false

webcam_state = false
} else {
settings.experimental.webcam = true

save()

tgt8.textContent = "On"
tgl8.checked = true

webcam_state = true
}
}

dialog
.showMessageBox({
title: "Authme",
buttons: ["Yes", "No", "Cancel"],
defaultId: 2,
cancelId: 2,
noLink: true,
type: "warning",
message: "If you want to change this setting you have to restart the app! \n\nDo you want to restart it now?",
})
.then((result) => {
if (result.response === 0) {
toggle()
restart()
}

if (result.response === 1) {
toggle()
}
})
}

// ? save settings
const save = () => {
fs.writeFileSync(path.join(folder_path, "settings", "settings.json"), JSON.stringify(settings, null, "\t"))
Expand Down

0 comments on commit 79ebfe3

Please sign in to comment.