Skip to content

Commit f7bda11

Browse files
committed
feat: ✨ get params from query string
1 parent 4dfb663 commit f7bda11

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

js/main-en.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
const urlOrigin = location.origin;
6969
const urlPath = location.pathname;
7070
const urlHash = location.hash.replace('#', '');
71+
const urlParams = new URLSearchParams(window.location.search);
7172
const config = {
7273
databaseURL: "https://webbit-remote.firebaseio.com/"
7374
};
@@ -105,6 +106,13 @@
105106
}, 1000);
106107
});
107108

109+
// 讀取 query string 中的參數
110+
urlParams.forEach((value, key) => {
111+
if (key in list) {
112+
list[key] = value;
113+
}
114+
});
115+
108116
/* firebase 讀檔 */
109117
if (urlHash) {
110118
list = await database.ref(urlHash).once('value').then(result => {

js/main.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868
const urlOrigin = location.origin;
6969
const urlPath = location.pathname;
7070
const urlHash = location.hash.replace('#', '');
71+
const urlParams = new URLSearchParams(window.location.search);
7172
const config = {
7273
databaseURL: "https://webbit-remote.firebaseio.com/"
7374
};
@@ -105,6 +106,13 @@
105106
}, 1000);
106107
});
107108

109+
// 讀取 query string 中的參數
110+
urlParams.forEach((value, key) => {
111+
if (key in list) {
112+
list[key] = value;
113+
}
114+
});
115+
108116
/* firebase 讀檔 */
109117
if (urlHash) {
110118
list = await database.ref(urlHash).once('value').then(result => {

0 commit comments

Comments
 (0)