2022-10-02 20:18:05 +09:00
{% extends "base.html" %}
{% block content %}
< div >
{{ macros.m_button_group([['globalSettingSaveBtn', '설정 저장']])}}
{{ macros.m_row_start('5') }}
{{ macros.m_row_end() }}
2022-10-06 14:39:43 +09:00
{{ macros.m_hr() }}
2022-10-02 20:18:05 +09:00
< nav >
{{ macros.m_tab_head_start() }}
{{ macros.m_tab_head2('basic', 'Basic', true) }}
{{ macros.m_tab_head2('advanced', 'Advanced', false) }}
{{ macros.m_tab_head_end() }}
</ nav >
< form id = 'setting' name = 'setting' >
< div class = "tab-content" id = "nav-tabContent" >
{{ macros.m_tab_content_start('basic', true) }}
{{ macros.setting_checkbox('notify_telegram_use', '텔레그램 사용', value=arg['notify_telegram_use']) }}
< div id = "notify_telegram_use_div" class = "collapse" >
{{ macros.setting_input_text('notify_telegram_token', 'Bot Token', value=arg['notify_telegram_token']) }}
{{ macros.setting_input_text('notify_telegram_chat_id', 'My Chat ID', value=arg['notify_telegram_chat_id'], col='3') }}
{{ macros.setting_input_text_and_buttons('tmp_text_telegram', 'Test', [['tmp_telegram_test_btn', '전송']], value='테스트 메시지입니다.', col='9', desc=['사용자가 먼저 봇과 대화를 시작하여 대화창이 생성된 상태여야 합니다.', '(대화창이 있을 경우에만 알림 수신)']) }}
{{ macros.setting_checkbox('notify_telegram_disable_notification', '알람 Disable', value=arg['notify_telegram_disable_notification'], desc='On : 알람 소리 없이 메시지를 수신합니다.') }}
</ div >
{{ macros.m_hr() }}
{{ macros.setting_checkbox('notify_discord_use', '디스코드 사용', value=arg['notify_discord_use']) }}
< div id = "notify_discord_use_div" class = "collapse" >
{{ macros.setting_input_text('notify_discord_webhook', '웹훅', value=arg['notify_discord_webhook']) }}
{{ macros.setting_input_text_and_buttons('tmp_text_discord', 'Test', [['tmp_discord_test_btn', '전송']], value='테스트 메시지입니다.', col='9') }}
</ div >
{{ macros.m_tab_content_end() }}
{{ macros.m_tab_content_start('advanced', false) }}
{{ macros.setting_checkbox('notify_advaned_use', '사용', value=arg['notify_advaned_use'], desc=['충분히 내용 숙지하고 사용하세요.', '사용시 기본설정은 무시됩니다.']) }}
< div id = "notify_advaned_use_div" class = "collapse" >
2022-10-06 14:39:43 +09:00
{{ macros.setting_input_textarea('_notify_advaned_policy', '정책', value=arg['notify_advaned_policy'], row='30') }}
2022-10-02 20:18:05 +09:00
{{ macros.setting_input_text_and_buttons('tmp_text_advanced', 'Test', [['tmp_advanced_test_btn', '전송']], value='테스트 메시지입니다.', col='9', desc=['메시지 ID = 형식', '형식의 구분자 |', '텔레그램 : bot_token,chat_id | 디스코드 : 웹훅 URL', '예) DEFAULT = 794150118:AAEAAAAAAAAAAAAAAA,186485141|https://discordapp.com/api/webhooks/626295849....', '모든 알림을 텔레그램과 디스코드에 보냄']) }}
{{ macros.setting_input_text('tmp_message_id', 'Test Message ID', value='DEFAULT') }}
</ div >
{{ macros.m_tab_content_end() }}
</ div > <!--tab-content-->
</ form >
</ div > <!--전체-->
< script type = "text/javascript" >
var package_name = "{{arg['package_name']}}" ;
var sub = "{{arg['sub'] }}" ;
$ ( document ). ready ( function (){
use_collapse ( "notify_telegram_use" );
use_collapse ( "notify_discord_use" );
use_collapse ( "notify_advaned_use" );
});
$ ( '#notify_telegram_use' ). change ( function () {
use_collapse ( 'notify_telegram_use' );
});
$ ( '#notify_discord_use' ). change ( function () {
use_collapse ( 'notify_discord_use' );
});
$ ( '#notify_advaned_use' ). change ( function () {
use_collapse ( 'notify_advaned_use' );
});
$ ( "body" ). on ( 'click' , '#tmp_telegram_test_btn' , function ( e ){
e . preventDefault ();
bot_token = document . getElementById ( "notify_telegram_token" ). value ;
chat_id = document . getElementById ( "notify_telegram_chat_id" ). value ;
text = document . getElementById ( "tmp_text_telegram" ). value ;
$ . ajax ({
url : '/' + package_name + '/ajax/' + sub + '/telegram_test' ,
type : "POST" ,
cache : false ,
data : { bot_token : bot_token , chat_id : chat_id , text : text },
dataType : "json" ,
success : function ( ret ) {
if ( ret ) {
$ . notify ( '<strong>전송 하였습니다.</strong>' , {
type : 'success'
});
} else {
$ . notify ( '<strong>전송에 실패하였습니다.<br>' + ret + '</strong>' , {
type : 'warning'
});
}
}
});
});
$ ( "body" ). on ( 'click' , '#tmp_discord_test_btn' , function ( e ){
e . preventDefault ();
url = document . getElementById ( "notify_discord_webhook" ). value ;
text = document . getElementById ( "tmp_text_discord" ). value ;
$ . ajax ({
url : '/' + package_name + '/ajax/' + sub + '/discord_test' ,
type : "POST" ,
cache : false ,
data : { url : url , text : text },
dataType : "json" ,
success : function ( ret ) {
if ( ret ) {
$ . notify ( '<strong>전송 하였습니다.</strong>' , {
type : 'success'
});
} else {
$ . notify ( '<strong>전송에 실패하였습니다.<br>' + ret + '</strong>' , {
type : 'warning'
});
}
}
});
});
$ ( "body" ). on ( 'click' , '#tmp_advanced_test_btn' , function ( e ){
e . preventDefault ();
policy = document . getElementById ( "notify_advaned_policy" ). value ;
text = document . getElementById ( "tmp_text_advanced" ). value ;
message_id = document . getElementById ( "tmp_message_id" ). value ;
$ . ajax ({
url : '/' + package_name + '/ajax/' + sub + '/advanced_test' ,
type : "POST" ,
cache : false ,
data : { policy : policy , text : text , message_id : message_id },
dataType : "json" ,
success : function ( ret ) {
if ( ret ) {
$ . notify ( '<strong>전송 하였습니다.</strong>' , {
type : 'success'
});
} else {
$ . notify ( '<strong>전송에 실패하였습니다.<br>' + ret + '</strong>' , {
type : 'warning'
});
}
}
});
});
$ ( "body" ). on ( 'click' , '#capture_btn' , function ( e ){
e . preventDefault ();
url = document . getElementById ( 'tmp_go_url' ). value
$ . ajax ({
url : '/' + package_name + '/ajax/' + sub + '/capture' ,
type : "POST" ,
cache : false ,
data : { url : url },
dataType : "json" ,
success : function ( data ) {
if ( data . ret == 'success' ) {
tmp = '<img src="' + data . data + '" class="img-fluid">'
document . getElementById ( "image_div" ). innerHTML = tmp ;
} else {
$ . notify ( '<strong>실패하였습니다.</strong>' , {
type : 'warning'
});
}
}
});
});
//, ['full_capture_btn', '전체 캡처 이미지 다운']
$ ( "body" ). on ( 'click' , '#full_capture_btn' , function ( e ){
e . preventDefault ();
url = document . getElementById ( 'tmp_go_url' ). value
$ . ajax ({
url : '/' + package_name + '/ajax/' + sub + '/full_capture' ,
type : "POST" ,
cache : false ,
data : { url : url },
dataType : "json" ,
success : function ( data ) {
if ( data . ret == 'success' ) {
console . log ( 'xxx' )
tmp = '<img src="' + data . data + '" class="img-fluid">'
document . getElementById ( "image_div" ). innerHTML = tmp ;
} else {
$ . notify ( '<strong>실패하였습니다.</strong>' , {
type : 'warning'
});
}
}
});
});
</ script >
{% endblock %}