Skip to content

Commit

Permalink
Sort codes available
Browse files Browse the repository at this point in the history
  • Loading branch information
Levminer committed Feb 4, 2022
1 parent dfe074f commit 57593ad
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 42 deletions.
3 changes: 1 addition & 2 deletions app/application/src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ const description_state = settings.settings.codes_description
const copy_state = settings.settings.reset_after_copy
const blur_state = settings.settings.blur_codes
const search_state = settings.settings.search_history

const sort_number = settings.experimental.sort
const sort_number = settings.settings.sort

/**
* Load file first time from dialog
Expand Down
73 changes: 40 additions & 33 deletions app/settings/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,40 @@ <h4 data-loc>You can view the logs for debugging. You can view all the logs in t

<!-- codes -->
<div id="codes" class="tabcontent part hidden">
<h3>Sort codes</h3>
<h4>You can choose how to sort the codes. By default codes are sorted by importing order.</h4>

<div class="relative inline-block">
<button id="sortButton" class="buttoni" onclick="sortDropdown()">
<svg xmlns="http://www.w3.org/2000/svg" class="relative top-1 h-6 w-6 pointer-events-none" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 9l4-4 4 4m0 6l-4 4-4-4" />
</svg>
Default
</button>

<div id="sortContent" class="animation hidden absolute right-0 z-20 w-72 mt-2 bg-white rounded-2xl overflow-hidden border-white border-2">
<a href="#" onclick="sortDropdownChoose(0)" class="block no-underline text-xl px-2 py-2 transform duration-200 ease-in text-black hover:bg-gray-600 hover:text-white">
<svg xmlns="http://www.w3.org/2000/svg" class="relative top-1 h-6 w-6 pointer-events-none" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 9l4-4 4 4m0 6l-4 4-4-4" />
</svg>
Default
</a>
<a href="#" onclick="sortDropdownChoose(1)" class="block no-underline text-xl px-2 py-2 transform duration-200 ease-in text-black hover:bg-gray-600 hover:text-white">
<svg xmlns="http://www.w3.org/2000/svg" class="relative top-1 h-6 w-6 pointer-events-none" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 4h13M3 8h9m-9 4h9m5-4v12m0 0l-4-4m4 4l4-4" />
</svg>
A-Z
</a>
<a href="#" onclick="sortDropdownChoose(2)" class="block no-underline text-xl px-2 py-2 transform duration-200 ease-in text-black hover:bg-gray-600 hover:text-white">
<svg xmlns="http://www.w3.org/2000/svg" class="relative top-1 h-6 w-6 pointer-events-none" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 4h13M3 8h9m-9 4h6m4 0l4-4m0 0l4 4m-4-4v12" />
</svg>
Z-A
</a>
</div>
</div>
<br />
<hr />
<h3 data-loc>Codes description</h3>
<h4 data-loc>The saved codes description will be visible. You can copy it after clicking it.</h4>
<div class="flex justify-center items-center w-72 h-[68px] bg-white mx-auto rounded-full">
Expand Down Expand Up @@ -426,41 +460,16 @@ <h4 data-loc>You can modify the global shortcuts here, read the documentation fo

<!-- experimental -->
<div id="experimental" class="tabcontent part hidden">
<h3>Sort codes</h3>
<h4>You can choose how to sort the codes. By default codes are sorted by importing order.</h4>

<div class="relative inline-block">
<button id="sortButton" class="buttoni" onclick="sortDropdown()">
<svg xmlns="http://www.w3.org/2000/svg" class="relative top-1 h-6 w-6 pointer-events-none" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 9l4-4 4 4m0 6l-4 4-4-4" />
<div class="md:w-4/5 lg:w-2/3 mx-auto rounded-2xl bg-gray-800 mt-5">
<h4 class="pt-5">These features are under development and can be unstable! Use it at your own risk!</h4>
<button class="buttoni mb-8" onclick="experimentalDocs()">
<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="M19.428 15.428a2 2 0 00-1.022-.547l-2.387-.477a6 6 0 00-3.86.517l-.318.158a6 6 0 01-3.86.517L6.05 15.21a2 2 0 00-1.806.547M8 4h8l-1 1v5.172a2 2 0 00.586 1.414l5 5c1.26 1.26.367 3.414-1.415 3.414H4.828c-1.782 0-2.674-2.154-1.414-3.414l5-5A2 2 0 009 10.172V5L8 4z" />
</svg>
Default
Features
</button>

<div id="sortContent" class="animation hidden absolute right-0 z-20 w-72 mt-2 bg-white rounded-2xl overflow-hidden border-white border-2">
<a href="#" onclick="sortDropdownChoose(0)" class="block no-underline text-xl px-2 py-2 transform duration-200 ease-in text-black hover:bg-gray-600 hover:text-white">
<svg xmlns="http://www.w3.org/2000/svg" class="relative top-1 h-6 w-6 pointer-events-none" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 9l4-4 4 4m0 6l-4 4-4-4" />
</svg>
Default
</a>
<a href="#" onclick="sortDropdownChoose(1)" class="block no-underline text-xl px-2 py-2 transform duration-200 ease-in text-black hover:bg-gray-600 hover:text-white">
<svg xmlns="http://www.w3.org/2000/svg" class="relative top-1 h-6 w-6 pointer-events-none" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 4h13M3 8h9m-9 4h9m5-4v12m0 0l-4-4m4 4l4-4" />
</svg>
A-Z
</a>
<a href="#" onclick="sortDropdownChoose(2)" class="block no-underline text-xl px-2 py-2 transform duration-200 ease-in text-black hover:bg-gray-600 hover:text-white">
<svg xmlns="http://www.w3.org/2000/svg" class="relative top-1 h-6 w-6 pointer-events-none" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 4h13M3 8h9m-9 4h6m4 0l4-4m0 0l4 4m-4-4v12" />
</svg>
Z-A
</a>
</div>
</div>

<h4 class="text-popup-yellow font-bold mb-0">This feature is WIP! It might be unstable or buggy!</h4>

<br />
<hr />

Expand All @@ -477,8 +486,6 @@ <h4>You can turn on Import screen capture. You can scan QR codes from your scree
></a>
<span id="tgt8" class="text-black text-xl">-</span>
</div>

<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
13 changes: 9 additions & 4 deletions app/settings/src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ if (reset_copy_state === true) {
}

// sort
const sort_number = settings.experimental.sort
const sort_number = settings.settings.sort

if (sort_number === 1) {
drp0.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" class="relative top-1 h-6 w-6 pointer-events-none" fill="none" viewBox="0 0 24 24" stroke="currentColor">
Expand Down Expand Up @@ -598,23 +598,23 @@ const sortDropdownChoose = (id) => {
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 9l4-4 4 4m0 6l-4 4-4-4" />
</svg> Default`

settings.experimental.sort = null
settings.settings.sort = null
break

case 1:
sort_button.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" class="relative top-1 h-6 w-6 pointer-events-none" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 4h13M3 8h9m-9 4h9m5-4v12m0 0l-4-4m4 4l4-4" />
</svg> A-Z`

settings.experimental.sort = 1
settings.settings.sort = 1
break

case 2:
sort_button.innerHTML = `<svg xmlns="http://www.w3.org/2000/svg" class="relative top-1 h-6 w-6 pointer-events-none" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 4h13M3 8h9m-9 4h6m4 0l4-4m0 0l4 4m-4-4v12" />
</svg> Z-A`

settings.experimental.sort = 2
settings.settings.sort = 2
break
}
}
Expand Down Expand Up @@ -1119,3 +1119,8 @@ const displayChoose = (id) => {
}
})
}

/* Experimental docs */
const experimentalDocs = () => {
shell.openExternal("https://docs.authme.levminer.com/#/settings?id=experimental-features")
}
2 changes: 1 addition & 1 deletion lib/typedef.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
* @property {boolean} settings.search_filter.description - Filter for description
* @property {number} settings.default_display - Default display
* @property {null|string} settings.language - Change language
* @property {null|string} settings.sort - Sort codes
*
* @property {object} experimental - Experimental
* @property {null|number} experimental.sort - Sort codes
* @property {boolean} experimental.screen_capture - Import screen capture
*
* @property {object} security - Security
Expand Down
8 changes: 7 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ const settings_file = {
},
default_display: 1,
language: null,
sort: null,
},
experimental: {
sort: null,
screen_capture: false,
},
security: {
Expand Down Expand Up @@ -271,6 +271,12 @@ if (settings.settings.language === undefined) {
saveSettings()
}

if (settings.settings.sort === undefined) {
settings.settings.sort = null

saveSettings()
}

/**
* Force dark mode
*/
Expand Down
Loading

0 comments on commit 57593ad

Please sign in to comment.