PageSourceSearch

https://www.korea.kr/jsV5/fcm_common.js?time=202610021912

js korea.kr collected 2026-10-02 10:15:06 UTC 3,029 bytes, 108 lines download raw bytes

1
2// 파이어베이스 사용 가능 여부 확인 (1:가능, 0:불가능)
3function fn_checkFirebase() {
4	const agent = navigator.userAgent.toLowerCase();
5	const inapp = agent.indexOf("inapp");
6	const safari = agent.indexOf("safari");
7	const chrome = agent.indexOf("chrome");
8	
9	if(inapp > -1 || (safari > -1 && chrome == -1)) { 
10		return 0;
11	} else {
12		return 1;
13	}
14}
15
16var firebaseConfig = {
17	apiKey: "AIzaSyApWnilxwPiu4cp5_yvOqtKUeKP7BXSXZk",
18	authDomain: "korea-kr.firebaseapp.com",
19	projectId: "korea-kr",
20	storageBucket: "korea-kr.appspot.com",
21	messagingSenderId: "6477873872",
22	appId: "1:6477873872:web:2322cff2fbf2ac53bad4d5",
23	measurementId: "G-KDC8NHJF70"
24};
25
26var messaging;
27var permission = 'denied';
28
29if(fn_checkFirebase()) { 
30	// Initialize Firebase
31	firebase.initializeApp(firebaseConfig);
32	messaging = firebase.messaging();
33	permission = Notification.permission;
34}
35
36// 종모양 컨트롤
37function fn_controllNoti(type) {
38	if(type == "ON") {
39		$('#notify_button_id').removeClass("off");
40		$('#notify_button_id').html('<span class="sr-only">알림<span>ON</span></span>');
41	} else {		
42		if(!$('#notify_button_id').hasClass('off')){
43			$('#notify_button_id').addClass('off');
44			$('#notify_button_id').html('<span class="sr-only">알림설정<span>OFF</span></span>');
45		}
46	}
47}
48
49const getToken = () => {
50	messaging.getToken()
51		.then((currentToken) => {
52			if (currentToken && !checkLocalStorageItem('token', currentToken)) {
53				var param = { token: currentToken };
54				var jshr = $.getJSON('/etc/fcmTokenInit.do', param, function(data) {
55					console.log('토큰 DB 등록 완료');
56				});
57				jshr.complete(function() {
58					setLocalStorageItem('token', currentToken);
59					console.log('토큰 LocalStorage 등록 완료');
60				});
61			}
62		})
63		.catch((err) => {
64			console.log('토큰 가져오기 실패', err);
65		});
66};
67
68const requestPermission = () => {
69	Notification.requestPermission()
70		.then((permission) => {
71			if (permission === 'granted') {
72				console.log('푸시 허용');
73				getToken(); 
74				
75			} else if (permission === 'denied') {
76				console.log('푸시 차단');
77				const currentToken = getLocalStorageItem('token');
78				if (currentToken !== 'D') {
79					setLocalStorageItem('token', 'D');
80				}
81			} else {
82				console.log('푸시 기본값');
83			}
84		});
85};
86
87// 사용자 정보 조회 후 종모양 설정
88const controllNotiBtn = () => {
89	if (permission === 'granted') {
90		var param = { token: getLocalStorageItem('token') };
91		var jshr = $.getJSON('/etc/checkUserSetting.do', param, function(data) {
92			console.log("현재 사용자 알림 설정값 갯수 : "+data.result);
93			if(data.result > 0 || data.result == -1) {
94				fn_controllNoti("ON");
95			} else {
96				fn_controllNoti("OFF");
97			}
98		});
99	} else if (permission === 'denied') {
100		fn_controllNoti("OFF");
101	}
102}
103
104requestPermission(); 
105
106const getLocalStorageItem = (k) => localStorage.getItem(k);
107const setLocalStorageItem = (k, v) => localStorage.setItem(k, v);
108const checkLocalStorageItem = (k, v) => localStorage.getItem(k) === v;

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.