PageSourceSearch

https://www.gg.go.kr/governor/resources/governor/js/controller/SubPageCtrl.js

js gg.go.kr collected 2026-09-24 08:54:27 UTC 3,652 bytes, 102 lines download raw bytes

1import { ScheduleCtrl } from "./components/ScheduleCtrl.js";
2import { SubHerstoryCtrl } from "./pages/sub/SubHerstoryCtrl.js";
3import { ShareCtrl } from "./components/ShareCtrl.js";
4
5
6/**
7 * 
8 */
9export class SubPageCtrl {
10    constructor() { }
11    /**
12     * 폴더경로 받아오기
13     * @param {Array} folders [{String}]
14     * @returns 
15     */
16    set_folders(folders = []) {
17        this.folders = folders;
18        return this;
19    }//set_folders
20    /* ====================================== */
21    /* ====================================== */
22    /* ====================================== */
23    /**
24     * 
25     */
26    init = async () => {
27        if (!this.folders || !this.folders.length) {
28            throw new Error("폴더 경로 배열이 올바르지 않거나, length가 0입니다")
29        }
30
31        /* 공유하기 버튼 클릭시 */
32        new ShareCtrl().init();
33
34        /* 가장 마지막 주소 */
35        const lastRouter = this.folders[this.folders.length - 1];
36
37        /* 일반인지, 읽기페이지인지 */
38        this.get_url_diff();
39
40        /* 페이지에 따른 서브컨트롤러 작동 */
41        await this.activate_by_router(lastRouter);
42
43    }//init
44
45    /**
46     * 목록인지 읽기인지 쓰기인지 파악혀라
47     */
48    get_url_diff = () => {
49        const pathname = window.location.pathname;
50        if (pathname.includes("_read.html")) {
51            this.isRead = true;
52        }
53        if (pathname.includes("_write.html")) {
54            this.isWrite = true;
55        }
56    }//get_url_diff
57
58    /**
59     * 페이지에 따른 서브컨트롤러 작동
60     * @param {String}
60 lastRouter 가장 마지막 라우터 이름(현재페이지) 
61     */
62    activate_by_router = async (lastRouter) => {
63        switch (lastRouter) {
64            /* [추미애입니다 > 일정] */
65            case "schedule": {
66                await ScheduleCtrl.init();
67            } break;
68
69            /* [추미애입니다 > herstory] */
70            case "herstory": {
71                await new SubHerstoryCtrl().init();
72            } break;
73
74            /* [소통과 참여 > 편하G버스 정책 게시판] */
75            case "easygbus": {
76                if (this.isWrite) {
77                    console.log("hi");
78                    const $textarea = document.querySelector("textarea.wrtfd-wysiwyg");
79                    let $count = document.querySelector(".reason-count");
80                    $textarea.addEventListener("input",(e)=>{
81                        if(!$count){
82                            $count = document.createElement("P");     
83                            $count.classList.add(`reason-count`);
84                            $count.innerHTML = "0 / 500";
85                            $count.style.cssText = "margin-top:10px;font-size:12px;color:#666;"
86                            $textarea.parentElement.previousElementSibling.appendChild($count);
87                        }
88                        const currLen = e.target.value.length;
89                        $count.innerHTML = `<strong style="font-weight:800;color:${currLen < 400 ? "#333" : (currLen >= 480 ? "red" : "orange")}">${currLen}</strong> / 500`;
90                    });
91                }
92                if (this.isRead) { return; }
93                /* 목록 페이지일때 */
94                
95            } break;
96        }
97    }//activate_by_router
98
99    /* ====================================== */
100    /* ====================================== */
101    /* ====================================== */
102}//class:SubPageCtrl

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.