Skip to content

Commit

Permalink
Fix carousel
Browse files Browse the repository at this point in the history
  • Loading branch information
zbx1425 committed Dec 6, 2023
1 parent 141da53 commit fb64e5a
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 43 deletions.
70 changes: 34 additions & 36 deletions assets/js/app.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
var messages = {};
'use strict'

document.addEventListener("DOMContentLoaded", function() {
let userLanguage = (navigator.language || navigator.userLanguage).toLowerCase();
while (userLanguage && !messages[userLanguage]) {
if (userLanguage.indexOf('-') === -1) {
userLanguage = 'en';
break;
} else {
userLanguage = userLanguage.substring(0, userLanguage.lastIndexOf('-'));
}
let userLanguage = (navigator.language || navigator.userLanguage).toLowerCase();
while (userLanguage && !messages[userLanguage]) {
if (userLanguage.indexOf('-') === -1) {
userLanguage = 'en';
break;
} else {
userLanguage = userLanguage.substring(0, userLanguage.lastIndexOf('-'));
}
}

const i18n = VueI18n.createI18n({
locale: userLanguage,
fallbackLocale: 'en',
messages,
});

const app = Vue.createApp({
setup() {
const langs = Vue.ref(messages);
const showNavbar = Vue.ref(false);
const scrolled = Vue.ref(false);

return {
langs,
showNavbar,
scrolled
};
},
const i18n = VueI18n.createI18n({
locale: userLanguage,
fallbackLocale: 'en',
messages,
});

mounted() {
window.addEventListener('scroll', () => {
this.scrolled = window.scrollY > 0;
});
}
});
const app = Vue.createApp({
setup() {
const langs = Vue.ref(messages);
const showNavbar = Vue.ref(false);
const scrolled = Vue.ref(false);

return {
langs,
showNavbar,
scrolled
};
},

app.use(i18n)
app.mount('body')
mounted() {
window.addEventListener('scroll', () => {
this.scrolled = window.scrollY > 0;
});
}
});

app.use(i18n);
app.mount('body');
1 change: 1 addition & 0 deletions assets/js/lang/de.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
if (!messages) var messages = {};
messages["de"] = {
"lang.name": "DE",

Expand Down
1 change: 1 addition & 0 deletions assets/js/lang/en.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
if (!messages) var messages = {};
messages["en"] = {
"lang.name": "EN",

Expand Down
1 change: 1 addition & 0 deletions assets/js/lang/zh.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
if (!messages) var messages = {};
messages["zh"] = {
"lang.name": "繁中",

Expand Down
1 change: 1 addition & 0 deletions assets/js/lang/zh_cn.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
if (!messages) var messages = {};
messages["zh-cn"] = {
"lang.name": "简中",

Expand Down
13 changes: 6 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,13 @@

<script src="https://unpkg.com/vue@3/dist/vue.global.prod.js"></script>
<script src="https://unpkg.com/vue-i18n@9/dist/vue-i18n.global.prod.js"></script>

<script src="assets/js/app.js"></script>
<script src="assets/js/carousel.js" defer></script>

<script src="assets/js/lang/en.js"></script>
<script src="assets/js/lang/zh.js"></script>
<script src="assets/js/lang/zh_cn.js"></script>
<script src="assets/js/lang/de.js"></script>
<script src="assets/js/lang/en.js" defer></script>
<script src="assets/js/lang/zh.js" defer></script>
<script src="assets/js/lang/zh_cn.js" defer></script>
<script src="assets/js/lang/de.js" defer></script>
<script src="assets/js/app.js" defer></script>
<script src="assets/js/carousel.js" defer></script>

<title>Minecraft Transit Railway</title>
</head>
Expand Down

0 comments on commit fb64e5a

Please sign in to comment.