PageSourceSearch

https://gh-bern.jp/wp-content/plugins/my-snow-monkey/scripts/main.js?ver=1764516438

js gh-bern.jp collected 2026-10-04 11:30:25 UTC 7,853 bytes, 188 lines download raw bytes

1const bernKey = "bernLastValidatedDate";
2const rewarningIntervalMonth = 6;
3const rewarningIntervalSeconds = 86400;
4const cautionMessage = "日常生活で吠えることが多いですか?";
5
6const preRetrieval = () => {
7    const frm = document.getElementById("rsvform");
8    frm.submit();
9};
10
11const settings = [
12    {
13        id: "rsvsearch", message: cautionMessage, cautionFor: "はい",
14        preY: null, hrefY: "./#notice", preN: preRetrieval, hrefN: ""
15    },/*トップページ空室検索*/
16    {
17        id: "rsvvacant", message: cautionMessage, cautionFor: "はい",
18        preY: null, hrefY: "../#notice", preN: null, hrefN: "https://www.tenawan.ne.jp/lodgment/rec/004/634/r.asp"
19    },/*nav-menu--空室状況--pc*/
20    {
21        id: "rsvbook", message: cautionMessage, cautionFor: "はい",
22        preY: null, hrefY: "../#notice", preN: null, hrefN: "https://www.tenawan.ne.jp/lodgment/rec/004/634/pl.asp"
23    },/*nav-menu--宿泊プラン--pc*/
24    {
25        id: "sp-rsvvacant", message: cautionMessage, cautionFor: "はい",
26        preY: null, hrefY: "../#notice", preN: null, hrefN: "https://www.tenawan.ne.jp/lodgment/rec/004/634/r.asp"
27    },/*nav-menu--空室状況--sp*/
28    {
29        id: "sp-rsvbook", message: cautionMessage, cautionFor: "はい",
30        preY: null, hrefY: "../#notice", preN: null, hrefN: "https://www.tenawan.ne.jp/lodgment/rec/004/634/pl.asp"
31    },/*nav-menu--宿泊プラン--sp*/
32    {
33        id: "rsvcasual", message: cautionMessage, cautionFor: "はい",
34        preY: null, hrefY: "../#notice", preN: null, hrefN: "https://www.tenawan.ne.jp/lodgment/rec/004/634/pl.asp?O58"
35    },/*カジュアルコース*/
36    {
37        id: "rsvfull", message: cautionMessage, cautionFor: "はい", 
38        preY: null, hrefY: "../#notice", preN: null, hrefN: "https://www.tenawan.ne.jp/lodgment/rec/004/634/pl.asp?O6"
39    },/*おまかせコース*/
40    {
41        id: "rsvtongue", message: cautionMessage, cautionFor: "はい", 
42        preY: null, hrefY: "../#notice", preN: null, hrefN: "https://www.tenawan.ne.jp/lodgment/rec/004/634/pl.asp?O9"
43    },/*タンシチュー*/
44    {
45        id: "rsvbouillabaisse", message: cautionMessage, cautionFor: "はい", 
46        preY: null, hrefY: "../#notice", preN: null, hrefN: "https://www.tenawan.ne.jp/lodgment/rec/004/634/pl.asp?O8"
47    },/*ブイヤベース*/
48    {
49        id: "rsvsteak", message: cautionMessage, cautionFor: "はい", 
50        preY: null, hrefY: "../#notice", preN: null, hrefN: "https://www.tenawan.ne.jp/lodgment/rec/004/634/pl.asp?O56"
51    },/*ステーキ*/
52    {
53        id: "rsvcheese", message: cautionMessage, cautionFor: "はい", 
54        preY: null, hrefY: "../#notice", preN: null, hrefN: "https://www.tenawan.ne.jp/lodgment/rec/004/634/pl.asp?O7"
55    },/*チーズフォンデュ*/
56    {
57        id: "rsvpaella", message: cautionMessage, cautionFor: "はい", 
58        preY: null, hrefY: "../#notice", preN: null, hrefN: "https://www.tenawan.ne.jp/lodgment/rec/004/634/pl.asp?O36"
59    },/*パエリア*/
60    {
61        id: "rsvtwin", message: cautionMessage, cautionFor: "はい", 
62        preY: null, hrefY: "../#notice", preN: null, hrefN: "https://www.tenawan.ne.jp/lodgment/rec/004/634/pl.asp?L2"
63    },/*ツインルーム*/
64    {
65        id: "rsvtriple", message: cautionMessage, cautionFor: "はい", 
66        preY: null, hrefY: "../#notice", preN: null, hrefN: "https://www.tenawan.ne.jp/lodgment/rec/004/634/pl.asp?L9"
67    },/*トリプルルーム*/
68    {
69        id: "rsvdeluxe", message: cautionMessage, cautionFor: "はい", 
70        preY: null, hrefY: "../#notice", preN: null, hrefN: "https://www.tenawan.ne.jp/lodgment/rec/004/634/pl.asp?L10"
71    },/*デラックスツインルーム*/
72];
73
74const okCheck = () => {
75    const strLastDate = JSON.parse(localStorage.getItem(bernKey));
76    if (!strLastDate) return false;
77    const lastDate = new Date(strLastDate);
78    const currentDate = new Date();
79    return (currentDate.getTime() - lastDate.getTime() < rewarningIntervalSeconds*1000);
80    //    return (currentDate.getTime() - lastDate.getTime() < rewarningIntervalMonth*30*24*60*60*1000);
81};
82const okSave = () => {
83    localStorage.setItem(bernKey, JSON.stringify(new Date()));
84};
85
86const doSet = ({ id, message, cautionFor, preY, hrefY, preN, hrefN }) => {
87    const [hrefCaution, hrefTransition] = (cautionFor == "はい" ?[hrefY, hrefN] : [hrefN, hrefY]);
88    const [preCaution, preTransition] = (cautionFor == "はい" ? [preY,preN] : [preN, preY]);
89    const element = document.getElementById(id);
90    if (element == null) return;
91    const onClick = async (event) => {
92        if (okCheck()) {
93            okSave();
94            if (preTransition) preTransition();
95            if (hrefTransition) window.location.href = hrefTransition;
96        } else {
97            const ret = await getChoiceWithDialog(message, "はい", "いいえ");
98            switch (ret) {
99                case null:
100                    break;
101                case cautionFor:
102                    if (preCaution) preCaution();
103                    if (hrefCaution) window.location.href = hrefCaution;
104                    break;
105                default:
106                    okSave();
107                    if (preTransition) preTransition();
108                    if (hrefTransition) window.location.href = hrefTransition;
109                    break;
110            };
111            const nav = document.getElementById("drawer-nav");
112            if (nav){
113                nav.setAttribute("aria-hidden","true");
114            }
115        };
116    };
117    element.addEventListener('click', onClick);
118};
119
120const removeKey = () => {
121    localStorage.removeItem(bernKey);
122};
123
124const getChoiceWithDialog = (message, ...buttonCaptions) => {
125    return new Promise(
126        (resolve, reject) => {
127            const dialog = document.createElement("dialog");
128            const p = document.createElement("p");
129            p.innerHTML = message;
130            dialog.appendChild(p);
131
132            const div = document.createElement("div");
133            div.style.display = "flex";
134            buttonCaptions.forEach((caption) => {
135                const button = document.createElement("button");
136                button.innerHTML = caption;
137                button.addEventListener("click", event => {dialog.close(); resolve(caption); });
138                div.appendChild(button);
139            });
140            dialog.appendChild(div);
141            document.body.appendChild(dialog);
142
143            dialog.addEventListener("close", event => {dialog.remove(); resolve(null); });
144            dialog.showModal();
145        }
146    );
147};
148
149const makeSelectYM = () => {
150    const selectym = document.getElementById("selectym");
151    if (selectym == null) return;
152
153    const date = new Date();
154    let year = date.getFullYear();
155    const thismonth = date.getMonth() + 1;
156    for (let i = 0, month = thismonth; i < 6; i++) {
157        const op = document.createElement("option");
158        op.setAttribute("value", (year - 2000) * 100 + month); if
159            (month == thismonth) op.setAttribute("selected", "");
160        op.innerText = year + "年" + month + "月";
161        month++; if (month == 13) { month = 1; year++; };
162        selectym.append(op);
163    };
164};
165
166const makeSelectD = () => {
167    const selectd = document.getElementById("selectd");
168    if (selectd == null) return;
169    const date = new Date();
170    const today = date.getDate();
171    const lastday = 31;
172    for (let i = 1; i <= lastday; i++) {
173        const op = document.createElement("option");
174        op.setAttribute("value", i);
175        if (i == today)
176            op.setAttribute("selected", "");
177        op.innerText = i + "日";
178        selectd.append(op);
179    };
180};
181
182const init = () => {
183    settings.forEach(doSet);
184    makeSelectYM();
185    makeSelectD();
186};
187
188document.addEventListener('DOMContentLoaded', init);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.