]> 91.132.146.200 Git - bibliotheca-php.git/commitdiff
adding input char limit and some js to show it
authorBanana <mail@bananas-playground.net>
Mon, 10 May 2021 20:44:47 +0000 (22:44 +0200)
committerBanana <mail@bananas-playground.net>
Mon, 10 May 2021 20:44:47 +0000 (22:44 +0200)
CHANGELOG
TODO
webclient/view/default/entry/field-text3-description.html
webclient/view/default/entry/field-textarea-content.html
webclient/view/default/entry/field-textarea.html
webclient/view/default/manageentry/field-number.html
webclient/view/default/manageentry/field-text.html
webclient/view/default/manageentry/field-text3.html
webclient/view/default/manageentry/field-textarea.html

index 034cf1415382d98d2663006fadfd65aba5e6b228..06930371ef6cceb5b6618f0b619136d2e5735c0a 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -36,6 +36,7 @@
        * After adding an entry the option to view or edit the entry is now available
        * Added game info tool.
        * Added new fields for a game collection
+       * input and textarea do have a maxlength now. JS used to display the remaining chars
 
 1.0 - Castle 20210106
        * First usable version
diff --git a/TODO b/TODO
index b3ff757ebf6b49f4d21f6f580be682a40ff2a80a..3720f2cd83fa0350b8265f388079f22718c14014 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,5 +1,3 @@
-* input length check and display
-
 * stats overview page. amount of entries. file / cache and db storage. Version info and where to find it.
 * User and groupmanagement: Check where a user or group is used!
 * Better error handling and display while adding / update and delete
index 065ab0f7aa1896f68d981f682935aa619809e03a..b5def6a3def23fec728a9282547721dd006b191e 100644 (file)
@@ -1 +1 @@
-<p data-field-name="text3-description" class="uk-text-lead" data-field-id="<?php echo $field['identifier']; ?>"><?php echo Summoner::ifset($field, 'value'); ?></p>
+<p data-field-name="text3-description" class="uk-text-lead" data-field-id="<?php echo $field['identifier']; ?>"><?php echo nl2br(Summoner::ifset($field, 'value')); ?></p>
index 6e5e340a3428b307a04a418c9b32e93db2e35880..75e8432d38e80a0aa91c3034dc7561760cf1ba91 100644 (file)
@@ -1 +1 @@
-<p data-field-name="textarea-content" data-field-id="<?php echo $field['identifier']; ?>" class="uk-dropcap"><?php echo Summoner::ifset($field, 'value'); ?></p>
+<p data-field-name="textarea-content" data-field-id="<?php echo $field['identifier']; ?>" class="uk-dropcap"><?php echo nl2br(Summoner::ifset($field, 'value')); ?></p>
index 7cd22c27e4fe92376496cd88d8b7ca7978290a1e..49638c4d2c1d16e8c2e2b913e4f4ad15ac0a0c00 100644 (file)
@@ -1 +1 @@
-<p data-field-name="textarea" data-field-id="<?php echo $field['identifier']; ?>"><span class="uk-text-muted"><?php echo $field['displayname']; ?>:</span> <?php echo Summoner::ifset($field, 'value'); ?></p>
+<p data-field-name="textarea" data-field-id="<?php echo $field['identifier']; ?>"><span class="uk-text-muted"><?php echo $field['displayname']; ?>:</span> <?php echo nl2br(Summoner::ifset($field, 'value')); ?></p>
index 1148a10a5d6f89051c690fab7e817ed8652c54ab..306f0e6212b33ffa559048d780d3af4b4e011715 100644 (file)
@@ -1,7 +1,8 @@
 <div class="uk-margin">
        <label class="uk-form-label" for="<?php echo $field['identifier']; ?>"><?php echo $field['displayname']; ?></label>
        <div class="uk-form-controls">
-               <input class="uk-input" id="<?php echo $field['identifier']; ?>" type="number" autocomplete="off"
+               <input class="uk-input" id="<?php echo $field['identifier']; ?>" type="number"
+                      autocomplete="off" maxlength="10"
                       name="fdata[<?php echo $field['identifier']; ?>]"
                       value="<?php echo Summoner::ifset($TemplateData['editData'], $field['identifier']); ?>"
                >
index 0c918942a3ab9614eca049f813dc3844ef77bb6e..da37bd5ee74471d3e42811a44a90e60e0bd7ee30 100644 (file)
@@ -4,7 +4,9 @@
                <input class="uk-input" id="<?php echo $field['identifier']; ?>" type="text" autocomplete="off"
                   name="fdata[<?php echo $field['identifier']; ?>]"
                   value="<?php echo Summoner::ifset($TemplateData['editData'], $field['identifier']); ?>"
+              maxlength="128"
                >
+               <small id="<?php echo $field['identifier']; ?>_counter" class="uk-float-right"><?php echo 128-strlen(Summoner::ifset($TemplateData['editData'], $field['identifier'])); ?></small>
                <?php if(Summoner::ifset($field,'bulkedit')) { ?>
                <select class="uk-select" name="fdata[additionalEditOption][<?php echo $field['identifier']; ?>]">
                        <option value="">Select bulk edit option</option>
                <?php } ?>
        </div>
 </div>
+
+<script type="text/javascript">
+       {
+       const inputElement = document.getElementById("<?php echo $field['identifier']; ?>");
+       const inputCounter = document.getElementById("<?php echo $field['identifier']; ?>_counter");
+
+       inputElement.addEventListener("input", event => {
+               const target = event.currentTarget;
+               const maxLength = target.getAttribute("maxlength");
+               const currentLength = target.value.length;
+
+               inputCounter.innerHTML = `${maxLength - currentLength}`;
+       });
+       }
+</script>
index d7dcba1bf8d9ed96aec4da465b6c06bce3f4172f..268d61577b7c0d8189d155b6d718411f46269464 100644 (file)
@@ -2,8 +2,10 @@
        <label class="uk-form-label" for="<?php echo $field['identifier']; ?>"><?php echo $field['displayname']; ?></label>
        <div class="uk-form-controls">
                <textarea class="uk-textarea" autocomplete="off"
-                                 id="<?php echo $field['identifier']; ?>" rows="3"
+                                 id="<?php echo $field['identifier']; ?>"
+                                 rows="3" maxlength="255"
                                  name="fdata[<?php echo $field['identifier']; ?>]"><?php echo Summoner::ifset($TemplateData['editData'], $field['identifier']); ?></textarea>
+               <small id="<?php echo $field['identifier']; ?>_counter" class="uk-float-right"><?php echo 255-strlen(Summoner::ifset($TemplateData['editData'], $field['identifier'])); ?></small>
                <?php if(Summoner::ifset($field,'bulkedit')) { ?>
                <select class="uk-select" name="fdata[additionalEditOption][<?php echo $field['identifier']; ?>]">
                        <option value="">Select bulk edit option</option>
                <?php } ?>
        </div>
 </div>
+
+<script type="text/javascript">
+       {
+       const textarea = document.getElementById("<?php echo $field['identifier']; ?>");
+       const textareaCounter = document.getElementById("<?php echo $field['identifier']; ?>_counter");
+
+       textarea.addEventListener("input", event => {
+               const target = event.currentTarget;
+               const maxLength = target.getAttribute("maxlength");
+               const currentLength = target.value.length;
+
+               textareaCounter.innerHTML = `${maxLength - currentLength}`;
+       });
+       }
+</script>
index 07189a45326fb41d8d0616fa81061832e8d1f95f..afba135d95c245d7c9650fc4f8dffc1c3f6ba56e 100644 (file)
@@ -2,7 +2,8 @@
        <label class="uk-form-label" for="<?php echo $field['identifier']; ?>"><?php echo $field['displayname']; ?></label>
        <div class="uk-form-controls">
                <textarea class="uk-textarea" autocomplete="off"
-                       id="<?php echo $field['identifier']; ?>" rows="6"
+                       id="<?php echo $field['identifier']; ?>"
+               rows="8"
                        name="fdata[<?php echo $field['identifier']; ?>]"><?php echo Summoner::ifset($TemplateData['editData'], $field['identifier']); ?></textarea>
                <?php if(Summoner::ifset($field,'bulkedit')) { ?>
                <select class="uk-select" name="fdata[additionalEditOption][<?php echo $field['identifier']; ?>]">