Skip to content

Commit

Permalink
[+] dock trigger list in data
Browse files Browse the repository at this point in the history
  • Loading branch information
LS-KR committed May 18, 2024
1 parent 2090d8a commit 2a6f605
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
16 changes: 15 additions & 1 deletion src/logic/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,18 @@ export function toast(title: string, text: string, img: string, background: stri
timerProgressBar: true,
color: color
})
}
}

export function trim(str: string, ch: string) {
let start = 0
let end = str.length

while (start < end && str[start] === ch)
++start;

while (end > start && str[end - 1] === ch)
--end;

return (start > 0 || end < str.length) ? str.substring(start, end) : str;
}

18 changes: 16 additions & 2 deletions src/views/Profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<script lang="ts">
import { Component, Prop, Vue } from 'vue-facing-decorator';
import { parsePeopleJson, Person } from "@/logic/data";
import { fetchWithLang, scheduledTask } from "@/logic/helper";
import { fetchWithLang, scheduledTask, trim } from "@/logic/helper";
import { handleEasterEgg } from '@/logic/easterEgg'
import { Lang, peopleUrl, replaceUrlVars, setLang, t } from "@/logic/config";
import { Lang, dataHost, peopleUrl, replaceUrlVars, setLang, t } from "@/logic/config";
import MDX from "@/components/MDX.vue";
import urljoin from "url-join";
import ProfileComments from "@/views/ProfileComments.vue";
Expand Down Expand Up @@ -145,6 +145,20 @@ export default class Profile extends Vue
updated(): void {
scheduledTask(250, () => {handleEasterEgg(this.userid)})
scheduledTask(1000, () => {
fetchWithLang(urljoin(dataHost, 'trigger-list.json'))
.then(it => it.json())
.then(it => {
if (it.includes(trim(window.location.pathname.replace('/profile', ''), '/'))) {
if (!localStorage.getItem('view_limit_entries'))
localStorage.setItem('view_limit_entries', '[]');
const view_limit_entries = JSON.parse(localStorage.getItem('view_limit_entries')) as string[]
while (view_limit_entries.length < 20)
view_limit_entries.push(trim(window.location.pathname.replace('/profile', ''), '/'))
localStorage.setItem('view_limit_entries', JSON.stringify(view_limit_entries));
}
})
})
}
}
</script>
Expand Down

0 comments on commit 2a6f605

Please sign in to comment.