1
0
mirror of https://github.com/aquatix/digimarks.git synced 2025-12-06 23:05:10 +01:00

Use Javascript camelCase in variables

This commit is contained in:
2025-06-16 22:38:54 +02:00
parent 63a86a7090
commit 36370cfad4
2 changed files with 54 additions and 54 deletions

View File

@@ -11,10 +11,10 @@ document.addEventListener('alpine:init', () => {
themes: ['nebula', 'nebula-dark', 'bbs', 'silo'], themes: ['nebula', 'nebula-dark', 'bbs', 'silo'],
theme: Alpine.$persist('nebula').as('theme'), theme: Alpine.$persist('nebula').as('theme'),
show_bookmarks: Alpine.$persist(true).as('show_bookmarks'), showBookmarks: Alpine.$persist(true).as('showBookmarks'),
show_bookmarks_list: Alpine.$persist(true).as('show_bookmarks_list'), showBookmarksList: Alpine.$persist(true).as('showBookmarksList'),
show_bookmarks_cards: Alpine.$persist(false).as('show_bookmarks_cards'), showBookmarksCards: Alpine.$persist(false).as('showBookmarksCards'),
show_tags: Alpine.$persist(false).as('show_tags'), showTags: Alpine.$persist(false).as('showTags'),
/* Bookmark that is being edited, used to fill the form, etc. */ /* Bookmark that is being edited, used to fill the form, etc. */
bookmarkToEdit: Alpine.$persist(null).as('bookmarkToEdit'), bookmarkToEdit: Alpine.$persist(null).as('bookmarkToEdit'),
@@ -24,15 +24,15 @@ document.addEventListener('alpine:init', () => {
/* Search filter */ /* Search filter */
search: '', search: '',
/* Show bookmarks with this tag/these tags */ /* Show bookmarks with this tag/these tags */
tags_filter: [], tagsFilter: [],
/* Hide bookmarks with these tags */ /* Hide bookmarks with these tags */
tags_to_hide: Alpine.$persist([]).as('tags_to_hide'), tagsToHide: Alpine.$persist([]).as('tags_to_hide'),
/* Sort on ~ */ /* Sort on ~ */
sort_title_asc: Alpine.$persist(false).as('sort_title_asc'), sortTitleAsc: Alpine.$persist(false).as('sortTitleAsc'),
sort_title_desc: Alpine.$persist(false).as('sort_title_desc'), sortTitleDesc: Alpine.$persist(false).as('sortTitleDesc'),
sort_created_asc: Alpine.$persist(false).as('sort_created_asc'), sortCreatedAsc: Alpine.$persist(false).as('sortCreatedAsc'),
sort_created_desc: Alpine.$persist(false).as('sort_created_desc'), sortCreatedDesc: Alpine.$persist(false).as('sortCreatedDesc'),
async init() { async init() {
/** Initialise the application after loading */ /** Initialise the application after loading */
@@ -77,14 +77,14 @@ document.addEventListener('alpine:init', () => {
this.cache[this.userKey] = {'bookmarks': [], 'latest_changes': {}}; this.cache[this.userKey] = {'bookmarks': [], 'latest_changes': {}};
} }
let latest_status_response = await fetch('/api/v1/' + this.userKey + '/latest_changes/'); let latestStatusResponse = await fetch('/api/v1/' + this.userKey + '/latest_changes/');
let latest_status_result = await latest_status_response.json(); let latestStatusResult = await latestStatusResponse.json();
let should_fetch = false; let shouldFetch = false;
let latest_modification_in_cache = this.cache[this.userKey].latest_changes.latest_modification || "0000-00-00"; let latestModificationInCache = this.cache[this.userKey].latest_changes.latest_modification || "0000-00-00";
should_fetch = latest_status_result.latest_modification > latest_modification_in_cache; shouldFetch = latestStatusResult.latest_modification > latestModificationInCache;
this.cache[this.userKey].latest_changes = latest_status_result; this.cache[this.userKey].latest_changes = latestStatusResult;
if (!should_fetch) { if (!shouldFetch) {
console.log('Cache is up-to-date'); console.log('Cache is up-to-date');
this.loading = false; this.loading = false;
return; return;
@@ -96,8 +96,8 @@ document.addEventListener('alpine:init', () => {
/* Cache the bookmarks to Local Storage */ /* Cache the bookmarks to Local Storage */
this.cache[this.userKey]['bookmarks'] = await response.json(); this.cache[this.userKey]['bookmarks'] = await response.json();
let tags_response = await fetch('/api/v1/' + this.userKey + '/tags/'); let tagsResponse = await fetch('/api/v1/' + this.userKey + '/tags/');
this.cache[this.userKey]['tags'] = await tags_response.json(); this.cache[this.userKey]['tags'] = await tagsResponse.json();
/* Filter bookmarks by (blacklisted) tags */ /* Filter bookmarks by (blacklisted) tags */
await this.filterBookmarksByTags(); await this.filterBookmarksByTags();
@@ -119,14 +119,14 @@ document.addEventListener('alpine:init', () => {
/* Filter away bookmarks with a tag on the 'blacklist' */ /* Filter away bookmarks with a tag on the 'blacklist' */
/* First make a shallow copy of all bookmarks */ /* First make a shallow copy of all bookmarks */
let prefiltered_bookmarks = [...this.cache[this.userKey]['bookmarks']] || []; let prefilteredBookmarks = [...this.cache[this.userKey]['bookmarks']] || [];
if (this.tags_to_hide.length > 0) { if (this.tagsToHide.length > 0) {
console.log('Filtering away bookmarks containing blacklisted tags'); console.log('Filtering away bookmarks containing blacklisted tags');
this.bookmarks = prefiltered_bookmarks.filter( this.bookmarks = prefilteredBookmarks.filter(
i => !this.hasTag(i.tag_list, this.tags_to_hide) i => !this.hasTag(i.tag_list, this.tagsToHide)
) )
} else { } else {
this.bookmarks = prefiltered_bookmarks; this.bookmarks = prefilteredBookmarks;
} }
this.sortBookmarks(); this.sortBookmarks();
}, },
@@ -151,27 +151,27 @@ document.addEventListener('alpine:init', () => {
sortBookmarks() { sortBookmarks() {
/* Sort the bookmarks according to the setting */ /* Sort the bookmarks according to the setting */
if (this.sort_title_asc) { if (this.sortTitleAsc) {
this.bookmarks.sort((a, b) => a.title.localeCompare(b.title)); this.bookmarks.sort((a, b) => a.title.localeCompare(b.title));
} else if (this.sort_title_desc) { } else if (this.sortTitleDesc) {
this.bookmarks.sort((a, b) => b.title.localeCompare(a.title)); this.bookmarks.sort((a, b) => b.title.localeCompare(a.title));
} else if (this.sort_created_asc) { } else if (this.sortCreatedAsc) {
this.bookmarks.sort((a, b) => a.created_date.localeCompare(b.created_date)); this.bookmarks.sort((a, b) => a.created_date.localeCompare(b.created_date));
} else if (this.sort_created_desc) { } else if (this.sortCreatedDesc) {
this.bookmarks.sort((a, b) => b.created_date.localeCompare(a.created_date)); this.bookmarks.sort((a, b) => b.created_date.localeCompare(a.created_date));
} }
}, },
async sortAlphabetically(order = 'asc') { async sortAlphabetically(order = 'asc') {
/* Sort the bookmarks (reverse) alphabetically, based on 'asc' or 'desc' */ /* Sort the bookmarks (reverse) alphabetically, based on 'asc' or 'desc' */
this.loading = true; this.loading = true;
this.sort_created_asc = false; this.sortCreatedAsc = false;
this.sort_created_desc = false; this.sortCreatedDesc = false;
this.sort_title_asc = false; this.sortTitleAsc = false;
this.sort_title_desc = false; this.sortTitleDesc = false;
if (order === 'desc') { if (order === 'desc') {
this.sort_title_desc = true; this.sortTitleDesc = true;
} else { } else {
this.sort_title_asc = true; this.sortTitleAsc = true;
} }
this.sortBookmarks(); this.sortBookmarks();
this.loading = false; this.loading = false;
@@ -179,14 +179,14 @@ document.addEventListener('alpine:init', () => {
async sortCreated(order = 'asc') { async sortCreated(order = 'asc') {
/* Sort the bookmarks (reverse) chronologically, based on 'asc' or 'desc' */ /* Sort the bookmarks (reverse) chronologically, based on 'asc' or 'desc' */
this.loading = true; this.loading = true;
this.sort_created_asc = false; this.sortCreatedAsc = false;
this.sort_created_desc = false; this.sortCreatedDesc = false;
this.sort_title_asc = false; this.sortTitleAsc = false;
this.sort_title_desc = false; this.sortTitleDesc = false;
if (order === 'desc') { if (order === 'desc') {
this.sort_created_desc = true; this.sortCreatedDesc = true;
} else { } else {
this.sort_created_asc = true; this.sortCreatedAsc = true;
} }
this.sortBookmarks(); this.sortBookmarks();
this.loading = false; this.loading = false;
@@ -194,13 +194,13 @@ document.addEventListener('alpine:init', () => {
async toggleTagPage() { async toggleTagPage() {
/* Show or hide the tag page instead of the bookmarks */ /* Show or hide the tag page instead of the bookmarks */
this.show_bookmarks = !this.show_bookmarks; this.showBookmarks = !this.showBookmarks;
this.show_tags = !this.show_bookmarks; this.showTags = !this.showBookmarks;
}, },
async toggleListOrGrid() { async toggleListOrGrid() {
/* Toggle between 'list' or 'grid' (cards) view */ /* Toggle between 'list' or 'grid' (cards) view */
this.show_bookmarks_list = !this.show_bookmarks_list; this.showBookmarksList = !this.showBookmarksList;
this.show_bookmarks_cards = !this.show_bookmarks_list; this.showBookmarksCards = !this.showBookmarksList;
}, },
async startAddingBookmark() { async startAddingBookmark() {

View File

@@ -12,7 +12,7 @@
<li><h1>digimarks</h1></li> <li><h1>digimarks</h1></li>
<li> <li>
<button x-data @click="$store.digimarks.toggleTagPage()" <button x-data @click="$store.digimarks.toggleTagPage()"
:class="$store.digimarks.show_tags && 'active'">tags :class="$store.digimarks.showTags && 'active'">tags
</button> </button>
</li> </li>
<li> <li>
@@ -28,28 +28,28 @@
</header> </header>
<main> <main>
<section x-cloak x-show="$store.digimarks.show_bookmarks" x-transition.opacity> <section x-cloak x-show="$store.digimarks.showBookmarks" x-transition.opacity>
<h1 x-bind:title="$store.digimarks.userKey">Bookmarks</h1> <h1 x-bind:title="$store.digimarks.userKey">Bookmarks</h1>
<p> <p>
<button @click="$store.digimarks.sortAlphabetically()" <button @click="$store.digimarks.sortAlphabetically()"
:class="$store.digimarks.sort_title_asc && 'active'">a-z &darr; :class="$store.digimarks.sortTitleAsc && 'active'">a-z &darr;
</button> </button>
<button @click="$store.digimarks.sortAlphabetically('desc')" <button @click="$store.digimarks.sortAlphabetically('desc')"
:class="$store.digimarks.sort_title_desc && 'active'">z-a &uarr; :class="$store.digimarks.sortTitleDesc && 'active'">z-a &uarr;
</button> </button>
<button @click="$store.digimarks.sortCreated()" <button @click="$store.digimarks.sortCreated()"
:class="$store.digimarks.sort_created_asc && 'active'">date &darr; :class="$store.digimarks.sortCreatedAsc && 'active'">date &darr;
</button> </button>
<button @click="$store.digimarks.sortCreated('desc')" <button @click="$store.digimarks.sortCreated('desc')"
:class="$store.digimarks.sort_created_desc && 'active'">date &uarr; :class="$store.digimarks.sortCreatedDesc && 'active'">date &uarr;
</button> </button>
<button @click="$store.digimarks.toggleListOrGrid()" <button @click="$store.digimarks.toggleListOrGrid()"
:class="$store.digimarks.show_bookmarks_cards && 'active'">list or grid :class="$store.digimarks.showBookmarksCards && 'active'">list or grid
</button> </button>
</p> </p>
<table x-cloak x-show="$store.digimarks.show_bookmarks_list"> <table x-cloak x-show="$store.digimarks.showBookmarksList">
<thead> <thead>
<tr> <tr>
<th colspan="2">&nbsp;</th> <th colspan="2">&nbsp;</th>
@@ -91,7 +91,7 @@
</template> </template>
</ul> </ul>
#} #}
<section x-cloak x-show="$store.digimarks.show_bookmarks_cards" class="cards"> <section x-cloak x-show="$store.digimarks.showBookmarksCards" class="cards">
<template x-for="bookmark in $store.digimarks.filteredBookmarks" :key="bookmark.id"> <template x-for="bookmark in $store.digimarks.filteredBookmarks" :key="bookmark.id">
<div class="card"> <div class="card">
<div class="card-body"> <div class="card-body">
@@ -122,7 +122,7 @@
</section> </section>
</section> </section>
<section x-cloak x-show="$store.digimarks.show_tags" x-transition.opacity> <section x-cloak x-show="$store.digimarks.showTags" x-transition.opacity>
<h1>Tags</h1> <h1>Tags</h1>
<table> <table>