PageSourceSearch

https://member.technews.tw/js/layout.js?ver=202609241644

js technews.tw collected 2026-09-24 08:44:21 UTC 3,949 bytes, 119 lines download raw bytes

1$(function() {
2    tnPopupModalInit('TNModelStatic', 'static');
3    tnPopupModalInit('TNModelBasic');
4});
5
6/**
7 * 會員中心登出
8 */
9function tnBackendLogout()
10{
11    let logoutForm = document.createElement('form');
12    logoutForm.setAttribute('method', 'POST');
13    logoutForm.setAttribute('action', '/logout');
14    logoutForm.setAttribute('style', 'display:none');
15
16    let tokenInput = document.createElement('input');
17    tokenInput.setAttribute('name', '_token');
18    tokenInput.setAttribute('value', document.querySelector('meta[name="csrf-token"]').content);
19    logoutForm.appendChild(tokenInput);
20
21    let isBackendInput = document.createElement('input');
22    isBackendInput.setAttribute('name', 'is_backend');
23    isBackendInput.setAttribute('value', 1);
24    logoutForm.appendChild(isBackendInput);
25
26    document.getElementsByTagName("body")[0].appendChild(logoutForm);
27
28    logoutForm.submit();
29}
30
31/**
32 * 初始popup視窗
33 * @param id
34 * @param backdrop
35 */
36function tnPopupModalInit(id, backdrop = 'true')
37{
38    // backdrop: true 觸碰背景可關閉
39    // backdrop: static 觸碰背景不可關閉
40    $('body').append(`<div id="${id}" class="tnAlert modal fade tn-modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-modal="true" data-backdrop="${backdrop}"></div>`);
41}
42
43/**
44 * Popup視窗
45 * @param title
46 * @param body
47 * @param accept
48 * @param backdrop
49 */
50function tnPopupModal(title, body, accept = '我知道了', reject = '', callbacks = '', backdrop = 'true')
51{
52    let popupModal = (backdrop == 'static') ? $('#TNModelStatic') : $('#TNModelBasic');
53    let acceptBtn = (accept !== '') ?
54        `<a class="secondary" data-dismiss="modal" aria-label="Close" onclick=\"${callbacks}\">${accept}</a>` : '';
55    let rejectBtn = (reject !== '') ?
56        `<a class="primary modalInner" data-dismiss="modal" aria-label="Close">${reject}</a>` : '';
57
58    let titleDiv = (title !== '') ?
59        `<div class="modal-title"><h4>${title}</h4></div>` : '';
60    let btnDev = (acceptBtn !== '' || rejectBtn !== '') ?
61        `<div class="modal-btn">${acceptBtn} ${rejectBtn}</div>` : '';
62    let bodyDiv = (btnDev !== '') ?
63        `<div class="modal-detail">${body}</div>` : body;
64
65    let closeBtn = (backdrop != 'static') ? `<button type="button" class="modalInner close" data-dismiss="modal" aria-label="Close">
66                                        <span aria-hidden="true">×</span>
67                                    </button>` : '';
68
69    let template = `<div class="modal-dialog" role="document">
70                        <div class="modal-content">
71                            <div class="modal-body">
72                                ${titleDiv}
73                                ${bodyDiv}       
74                                ${btnDev}  
75                            </div>
76                            ${closeBtn}
77                        </div>
78                    </div>`;
79
80    if (popupModal.length) {
81        popupModal.html(template);
82        popupModal.modal('show');
83    } else {
84        alert(body);
85    }
86}
87
88/**
89 * 轉址詢問popup
90 * @param url
91 */
92function tnRedirectConfirmPopup(url)
93{
94    let title = '確定要離開當前頁面嗎?';
95    let body = '您的內容設定尚未儲存或是提交,若離開當前頁面可能會造成資料遺失。';
96    let acceptBtn = '是,前往其他頁面';
97    let rejectBtn = '否,我再考慮一下';
98    tnPopupModal(title, body, acceptBtn, rejectBtn, `tnRedirectTo('${url}')`);
99}
100
101
102function tnRedirectTo(url)
103{
104    location.href = url;
105}
106
107/**
108 * 刪除cookie
109 * @param cookieName
110 * @param domainHost
111 */
112function tnDeleteCookie(cookieName, domainHost) {
113    let cookieValue = '';
114    var expD = new Date();
115    expD.setTime(expD.getTime() - 1);
116    var uexpires = "expires="+expD.toUTCString();
117    var domain = "domain="+domainHost;
118    document.cookie = cookieName + "=" + cookieValue + "; " + uexpires + "; path=/;" + domain + ";";
119}

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.