PageSourceSearch

https://lingyuzhao.top/js/index-main.js

js lingyuzhao.top collected 2026-10-06 13:16:13 UTC 11,119 bytes, 350 lines download raw bytes

1// 初始化弹窗组件
2const jokerBoxPopUp = new JokerBox_popUp(document.getElementsByClassName("body_div")[0]);
3
4initButton();
5
6/**
7 * 初始化网站系统 index 数据
8 */
9function initIndex() {
10    console.info("initIndex run!");
11    // 判断是否有搜索参数 有的话就直接将页面更换为搜索页面
12    const strings = search_Params('search');
13    if (strings.length !== 0) {
14        $(showArea).load("search.html");
15        return
16    }
17    // 初始化用户按钮
18    initButtonByUserPL();
19    // 初始化页面 此时可能没有用户信息 所以在这里初始化
20    initPageByParam(false);
21}
22
23const checkConnectFun = () => chatSocket !== undefined && chatSocket.readyState === WebSocket.OPEN;
24
25/**
26 *
27 * @type {boolean} 离线的消息是否打印过
28 */
29let chatSocket_ALERT_ran = false;
30
31/**
32 * 在首页的socket 初始化操作
33 */
34const init_chatSocketFromIndex = () => {
35    if (checkConnectFun()) {
36        return;
37    }
38    if (isNotLogin()) {
39        console.warn("未登录的实时通道只有获取online功能!!!");
40    }
41    // 初始化聊天服务
42    LY_MblChat.initChat(
43        (ws) => chatSocket = ws,
44        (status) => {
45            if (status === 3024) {
46                // 代表是js关闭 不需要执行操作
47                return
48            }
49            if (chatSocket_ALERT_ran) {
50                return
51            }
52            chatSocket_ALERT_ran = true;
53            Ring.playRing('dengDeng');
54            jokerBoxPopUp.show('您已离线!!! 请检查网络连接哦! 无法连接至服务器!');
55        },
56        (ns) => {
57            if (checkSocketIsNotConnect(chatSocket) && ns !== undefined) {
58                chatSocket = ns;
59                Ring.playRing('dengDeng');
60                chatSocket_ALERT_ran = false;
61                jokerBoxPopUp.show("您已重新与服务器取得连接!!");
62            }
63        }, checkConnectFun
64    )
65}
66
67/**
68 * 初始化页面
69 * @param haveCookie 当前是否具有 cookie 信息
70 */
71function initPageByParam(haveCookie) {
72    const strings1 = search_Params("page");
73    if (strings1.length === 0) {
74        if (haveCookie) {
75            return;
76        }
77        $(showArea).load("Home.html")
78        return;
79    }
80    toPage(strings1[strings1.length - 1], search_Params("id"), haveCookie);
81}
82
83/**
84 * 如果已经登录了,则调用此回调函数
85 */
86const loginFun = () => {
87    // 初始化网站
88    initIndex();
89}
90
91// 内容展示框
92const showArea = document.getElementById("showArea");
93// 水平导航的标题
94const webTitle = document.getElementById("web-title");
95
96
97/**
98 *
99 * @type {boolean} 如果在打开网站的时候没有cookie 则 返回 true
100 */
101const start_noCookie = getLatestCookieValue(WEB_CONF['COOKIE_ID']) === undefined;
102
103// 初始化服务器配置数据以及用户数据,如果用户未登录则无法获取到用户数据
104initWebConf(loginFun, initIndex, undefined);
105
106/**
107 * 数据存储源 第一个为自己的数据 第二个为对方或自己数据的临时存储空间 第三个为当前访问的资源
108 * {permissionLevel: *, sex: *, name: *, id: *, res:*}
109 */
110let my, my_temp;
111let chatSocket = undefined;
112whoAmI((res) => {
113    if (res[WEB_CONF.RES_RETURN] !== WEB_CONF.RES_RETURN_OK_VALUE) {
114        console.info("初始化用户令牌出错", res);
115        toExceptionPage();
116        return;
117    }
118    my = res;
119    my_temp = my;
120    // 初始化页面 具有cookie
121    initPageByParam(true)
122    // 刷新配置
123    if (start_noCookie) {
124        // 开始进行访问统计
125        visMark()
126        // 实例化 盘镜 服务器客户端
127        initDiskMirror();
128        // 初始化连接
129        init_chatSocketFromIndex();
130    } else {
131        initWebConf(
132            () => {
133                // 初始化连接
134                init_chatSocketFromIndex()
135                // 开始进行访问统计
136                visMark()
137                // 根据用户权限初始化按钮
138                initButtonByUserPL();
139                // 检查数据
140                checkNewData();
141                // 实例化 盘镜 服务器客户端
142                initDiskMirror();
143            }, undefined, undefined,
144            // 初始化壁纸
145            initWebBackImage
146        )
147    }
148})
149
150// 设置导航的登录按钮
151click_login_user.onclick = () => {
152    if (my === undefined || my.name === undefined || my.permissionLevel === null || isPL(my, 'PermissionLevel.VISITOR')) {
153        axios.defaults.withCredentials = true;
154        $(showArea).load("Login.html");
155        webTitle.innerText = "用户登录";
156        return;
157    }
158    my_temp = my;
159    USER_CONF_TEMP = USER_CONF;
160    PersonalHomepage();
161}
162
163// 设置所有未知按钮
164for (let elementsByClassNameElement of document.getElementsByClassName("no_data")) {
165    elementsByClassNameElement.onclick = () => {
166        axios.defaults.withCredentials = true;
167        $(showArea).load("NotFind.html");
168        webTitle.innerText = "未知资源";
169    }
170}
171
172// 设置邮箱按钮
173const index_user_mali = document.getElementById("index_user_mali");
174index_user_mali.onclick = () => {
175    axios.defaults.withCredentials = true;
176    // 查看是否已经登录
177    if (my === undefined || isPL(my, undefined) || isPL(my, 'PermissionLevel.VISITOR')) {
178        console.log("system_terminal.onclick", my);
179        // 还未登录 需要登录;
180        $(showArea).load("Login.html");
181        webTitle.innerText = "请先登录";
182        return;
183    }
184    $(showArea).load("listMali.html");
185    webTitle.innerText = "邮件信箱";
186}
187
188// 设置用户管理按钮
189const index_user_manager = document.getElementById("index_user_manager");
190index_user_manager.onclick = () => {
191    axios.defaults.withCredentials = true;
192    // 查看是否已经登录
193    if (my === undefined || isPL(my, undefined) || isPL(my, 'PermissionLevel.VISITOR')) {
194        console.log("system_terminal.onclick", my);
195        // 还未登录 需要登录
196        $(showArea).load("Login.html");
197        webTitle.innerText = "请先登录";
198        return;
199    }
200    $(showArea).load("listUserManager.html");
201    webTitle.innerText = "邮件信箱";
202}
203
204// 设置轮播图管理按钮
205const index_carousel_manager = document.getElementById("index_carousel_manager");
206index_carousel_manager.onclick = () => {
207    axios.defaults.withCredentials = true;
208    toPage("listRChat.html");
209    webTitle.innerText = "轮播管理";
210}
211
212// 设置资源空间
213const user_resource_manager = document.getElementById("user_resource_manager");
214user_resource_manager.onclick = () => {
215    axios.defaults.withCredentials = true;
216    toPage("DiskMirrorFileManager.html", [], true);
217    webTitle.innerText = "资源空间";
218}
219
220// 设置动态中心按钮
221const trends_listTrends = document.getElementById("trends_listTrends");
222trends_listTrends.onclick = () => {
223    $(showArea).load("listTrends.html");
224    webTitle.innerText = "动态世界";
225}
226
227// 设置文章中心按钮
228const article_listArticle = document.getElementById("article_listArticle");
229article_listArticle.onclick = () => {
230    $(showArea).load("listArticle.html");
231    webTitle.innerText = "文章板块";
232}
233
234// 设置工具面板按钮
235const tools_listTool = document.getElementById('tools_listTool');
236tools_listTool.onclick = () => {
237    $(showArea).load("listTool.html");
238    webTitle.innerText = "工具面板";
239}
240
241// 设置游戏娱乐按钮
242const games_listTool = document.getElementById('games_listTool');
243games_listTool.onclick = () => {
244    $(showArea).load("listGame.html");
245    webTitle.innerText = "休闲游戏";
246}
247
248
249// 设置系统终端按钮
250const system_terminal = document.getElementById("system_terminal");
251system_terminal.onclick = () => {
252    axios.defaults.withCredentials = true;
253    // 查看是否已经登录
254    if (my === undefined || isPL(my, undefined) || isPL(my, 'PermissionLevel.VISITOR')) {
255        console.log("system_terminal.onclick", my);
256        // 还未登录 需要登录
257        $(showArea).load("Login.html");
258        webTitle.innerText = "请先登录";
259        return
260    }
261    $(showArea).load("ServerTerminal.html");
262    webTitle.innerText = "系统终端";
263}
264
265// 设置菜单按钮
266const setOption = document.getElementById("setOption");
267
268function setOptions_click() {
269    axios.defaults.withCredentials = true;
270    console.log("setOption.onclick", my);
271    // 查看是否已经登录
272    if (my === undefined || isPL(my, undefined) || isPL(my, 'PermissionLevel.VISITOR')) {
273        // 还未登录 需要登录
274        $(showArea).load("Login.html");
275        webTitle.innerText = "请先登录";
276        return;
277    }
278    $(showArea).load("setOption.html");
279    webTitle.innerText = "设置菜单";
280}
281
282setOption.onclick = setOptions_click;
283
284// 设置个人信息按钮
285function PersonalHomepage() {
286    axios.defaults.withCredentials = true;
287    // 查看是否已经登录
288    if (isNotLogin()) {
289        // 还未登录 需要登录
290        $(showArea).load("Login.html");
291        webTitle.innerText = "请先登录";
292        return
293    }
294    $(showArea).load("PersonalHomepage.html")
295    webTitle.innerText = "个人中心";
296}
297
298// 设置留言板按钮
299const comment_button = document.getElementById("siteComment");
300comment_button.onclick = () => {
301    $(showArea).load("SiteComment.html");
302    webTitle.innerText = "留言板";
303}
304
305// 设置关于按钮
306const about_button = document.getElementById("about_button");
307about_button.onclick = () => {
308    $(showArea).load("about.html");
309    webTitle.innerText = "关于我们";
310}
311
312/**
313 * 检查是否有新数据 有就将对应的按钮设置上闪烁
314 */
315function checkNewData() {
316    // 首先获取到当前的未读邮件
317    axios(
318        {
319            url: backEnd_host_href() + '/' + WEB_CONF['CONTROLLER_MALI'] + WEB_CONF['DETERMINE_UNREAD_QUANTITY']
320        }
321    ).then(
322        (res) => {
323            res = res.data;
324            if (res[WEB_CONF.RES_RETURN] > 0) {
325                // 代表有新数据 开始赋予邮件按钮样式
326                index_user_mali.style.animation = 'flicker_boxShadow 1.5s linear infinite';
327                index_user_mali.style.textShadow = '0 0 1vh #ffffff';
328                jokerBoxPopUp.show("您有 " + res[WEB_CONF.RES_RETURN] + " 个未读邮件哦!!!");
329            }
330        }
331    )
332}
333
334if (isMobileDevice()) {
335    // 隐藏 只能在 PC 显示的控件
336    const elementsByClassName1 = document.getElementsByClassName("pc_allow");
337    for (let i = 0; i < elementsByClassName1.length; i++) {
338        elementsByClassName1[i].style.display = 'none';
339    }
340}
341
342// 设置返回页面 按钮
343document.getElementById("index_back_page").onclick = () => {
344    const s = backNow_PAGE();
345    if (s === 'index.html') {
346        window.history.back();
347    } else {
348        $(showArea).load(s);
349    }
350};

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.