diff options
author | Mario Vavti <mario@mariovavti.com> | 2023-05-03 22:42:52 +0200 |
---|---|---|
committer | Mario Vavti <mario@mariovavti.com> | 2023-05-03 22:42:52 +0200 |
commit | 2d4b35fbc99062d52c6c32cacd158ceda661bb31 (patch) | |
tree | 03a64c452f06e295c5e97a596ec1b80d560141fe /view/tpl | |
parent | 57e2910477e81dfb9d8cf40334c013581d509617 (diff) | |
download | volse-hubzilla-2d4b35fbc99062d52c6c32cacd158ceda661bb31.tar.gz volse-hubzilla-2d4b35fbc99062d52c6c32cacd158ceda661bb31.tar.bz2 volse-hubzilla-2d4b35fbc99062d52c6c32cacd158ceda661bb31.zip |
provide possibility to flag via ajax calls to prevent pageloads
Diffstat (limited to 'view/tpl')
-rw-r--r-- | view/tpl/directory_header.tpl | 63 | ||||
-rw-r--r-- | view/tpl/direntry.tpl | 6 |
2 files changed, 65 insertions, 4 deletions
diff --git a/view/tpl/directory_header.tpl b/view/tpl/directory_header.tpl index f5ce7ce0a..a261762ac 100644 --- a/view/tpl/directory_header.tpl +++ b/view/tpl/directory_header.tpl @@ -19,7 +19,68 @@ {{** make sure this element is at the bottom - we rely on that in endless scroll **}} <div id="page-end" class="float-start w-100"></div> </div> -<script>$(document).ready(function() { loadingPage = false;});</script> <div id="page-spinner" class="spinner-wrapper"> <div class="spinner m"></div> </div> +<script> + $(document).ready(function() { + loadingPage = false; + {{if $directory_admin}} + $(document).on('click', '.directory-censor', function (e) { + e.preventDefault(); + + let that = this; + let url; + let path; + let severity; + let parent = this.closest('.directory-actions'); + let el; + + url = new URL(that.href) + + severity = url.searchParams.get('severity'); + path = url.pathname; + + console.log(url.searchParams.get('severity')); + + $.get( + path, + { + aj: 1, + severity : severity + }, + function(data) { + console.log(data) + if (data.success) { + + if (that.classList.contains('directory-censor-unsafe')) { + severity = data.flag ? 0 : 1; + el = parent.getElementsByClassName('directory-censor-hide')[0]; + if (el.classList.contains('active')) { + el.classList.toggle('active'); + url.searchParams.set('severity', 2); + el.href = url.toString(); + } + } + + if (that.classList.contains('directory-censor-hide')) { + severity = data.flag ? 0 : 2; + el = parent.getElementsByClassName('directory-censor-unsafe')[0]; + if (el.classList.contains('active')) { + el.classList.toggle('active'); + url.searchParams.set('severity', 1); + el.href = url.toString(); + } + } + + url.searchParams.set('severity', severity); + that.href = url.toString(); + that.classList.toggle('active'); + + } + } + ); + }); + {{/if}} + }); +</script> diff --git a/view/tpl/direntry.tpl b/view/tpl/direntry.tpl index 50714c072..16df987f4 100644 --- a/view/tpl/direntry.tpl +++ b/view/tpl/direntry.tpl @@ -1,11 +1,11 @@ <div class="directory-item{{if $entry.safe}} safe{{/if}}" id="directory-item-{{$entry.hash}}" > <div class="section-subtitle-wrapper clearfix"> - <div class="float-end"> + <div class="directory-actions float-end"> {{if $entry.censor_2}} - <a class="directory-censor btn btn{{$entry.censor_2_class}}-danger btn-sm" href="{{$entry.censor_2}}"> {{$entry.censor_2_label}}</a> + <a class="directory-censor directory-censor-hide btn btn-outline-danger btn-sm {{$entry.censor_2_class}}" href="{{$entry.censor_2}}"> {{$entry.censor_2_label}}</a> {{/if}} {{if $entry.censor}} - <a class="directory-censor btn btn{{$entry.censor_class}}-warning btn-sm" href="{{$entry.censor}}"> {{$entry.censor_label}}</a> + <a class="directory-censor directory-censor-unsafe btn btn-outline-warning btn-sm {{$entry.censor_class}}" href="{{$entry.censor}}"> {{$entry.censor_label}}</a> {{/if}} {{if $entry.ignlink}} <a class="directory-ignore btn btn-info btn-sm" href="{{$entry.ignlink}}"> {{$entry.ignore_label}}</a> |