add settings object, add convenience functions when marking coins in the future

This commit is contained in:
koksnuss 2020-05-05 23:47:11 +02:00
parent 4572af6d7b
commit f6659dc56e
3 changed files with 110 additions and 4 deletions

View File

@ -22,6 +22,67 @@ import { Cookie } from './modules/cookie.mjs';
$(document).ready(function() { $(document).ready(function() {
//
// Options
//
let settings = {
circulation: '',
found_now: true,
found: true,
buy_only: false,
checked: false,
ec: false
}
// button #advanced_options
$('#show_advanced_options').click(function() {
$('#advanced_options').slideToggle();
});
// checkbox #exists
$('input#exists').change(function() {
if (this.checked === true) {
// save settings
settings['circulation'] = $('#circulation').val();
let checkboxes = $('#found_now, #found, #datetime_now, #buy_only, #checked, #ec')
.map(function() {
return {
[$(this).prop('id')]: $(this).prop('checked')
}
}).get();
for (let box of checkboxes) {
for (let item in box) { settings[item] = box[item]; }
}
// disable settings
$('#circulation').val('Auflage');
$('#found, #buy_only, #checked, #ec').each(function() {
$(this).prop('checked', false);
});
$('#found, #select_usernames, #datetime_now, #datetime_custom, #circulation, #buy_only, #checked, #ec').each(function() {
$(this).prop('disabled', 'disabled');
});
// checkbox #exists not checked
} else {
// restore settings
$('#circulation').val(settings['circulation']);
$('#found_now, #found, #datetime_now, #buy_only, #checked, #ec').each(function() {
let setting = $(this).prop('id');
$(this).prop('checked', settings[setting]);
});
// enable settings
$('#found, #select_usernames, #datetime_now, #datetime_custom, #circulation, #buy_only, #checked, #ec').each(function() {
$(this).prop('disabled', '');
});
}
});
function render_login(input_name, input_color) { function render_login(input_name, input_color) {
// manage user login // manage user login

View File

@ -123,7 +123,7 @@ td > * {
} }
td.noexist { td.exists {
background-color: #434343; background-color: #434343;
} }
@ -203,3 +203,27 @@ div#username {
background-color: rgb(0,0,0); background-color: rgb(0,0,0);
background-color: rgba(0,0,0,0.4); background-color: rgba(0,0,0,0.4);
} }
div#advanced_options {
border-top: 1px solid gray;
position: fixed;
left: 0;
bottom: 70px;
width: 100%;
height: 70px;
/*line-height: 70px;*/
background-color: white;
text-align: center;
z-index: 1;
/*display: none;*/
}
div#advanced_options > label {
float: left;
padding: 5px;
margin: 0;
}
input#circulation {
width: 100px;
}

View File

@ -1,7 +1,28 @@
<div id="advanced_options">
<label for="circulation">
<input id="circulation" type="text" value="Auflage">
</label>
<label for="buy_only" id="label_buy_only">
<input id="buy_only" type="checkbox">
Kursmünze&nbsp;
</label>
<label for="checked" id="label_checked">
<input id="checked" type="checkbox">
Überprüft, einsortiert&nbsp;
</label>
<label for="ec" id="label_ec">
<input id="ec" type="checkbox">
Eurocollector 2002&nbsp;
</label>
<label for="exists">
<input id="exists" type="checkbox">
Existiert nicht
</label>
</div>
<div class="username"> <div class="username">
<label for="found" id="found_label"> <label for="found" id="found_label">
<input id="found" type="checkbox" checked="checked"> <input id="found" type="checkbox" checked="checked">
gefunden von
</label> </label>
<label for="select_usernames" id="for_select_usernames"> <label for="select_usernames" id="for_select_usernames">
<select id="select_usernames" name="username" form="username_form" class="form-control"> <select id="select_usernames" name="username" form="username_form" class="form-control">
@ -19,8 +40,8 @@
<input type="radio" name="datetime" id="datetime_custom"> <input type="radio" name="datetime" id="datetime_custom">
Datum Datum
</label> </label>
<button id="show_advanced_options" class="btn btn-info">+ Mehr</button>
<button id="show_add_user" class="btn btn-info">+ Namen hinzufügen</button> <button id="show_add_user" class="btn btn-info">+ Name</button>
</div> </div>
<div id="modal_add_user" class="modal-container"> <div id="modal_add_user" class="modal-container">