function DebugMsg(txt,flg=1) { if(flg) { console.log(txt); } } var aFlg; $.ajax({ success:function(response) { aFlg = true; }, error:function() { aFlg = false; } }); $('form').submit(function(e) { DebugMsg('フォーム送信'); if((ImageSize + ContentSize) > MaxFileSize) { $('.MODULE').show(); $('.FAILED .MSG').html(SizeOver); $('.FAILED').show(); return false; } e.preventDefault(); var $frm = $(this); $('.CONNECT').show(); $('.MODULE').show(); var SubmitData = CreateSubmitData($frm); DebugMsg(SubmitData); $.ajax({ url:$frm.attr('action'), method:'POST', data:SubmitData, processData:false, contentType:false, success:function(result, textStatus, xhr) { DebugMsg('Success'); DebugMsg(result); DebugMsg(textStatus); DebugMsg(xhr); res = result.split("{%}"); DebugMsg(res); if(res[0] == 'move') { location.href = res[1]; } else if(res[0] == 'check' || res[0] == 'regist') { $('.CONNECT').hide(); $('.SUCCESS').empty(); $('.SUCCESS').append(res[1]); $('.SUCCESS').show(); } else if(res[0] == 'append') { $('.WINDOW.LIST').empty(); $('.WINDOW.LIST').append(res[1]); $('.CONNECT').hide(); $('.MODULE').hide(); } else { $('.CONNECT').hide(); } }, error:function(xhr, textStatus, error) { DebugMsg('Error'); DebugMsg(xhr); DebugMsg(textStatus); DebugMsg(error); $('.CONNECT').hide(); } }); }); function CreateSubmitData(_frm) { //フォーム送信データ作成 var Data = new FormData(); TmpData = $(_frm).serializeArray(); DebugMsg(TmpData); $.each(TmpData, function(i, elem){ if(elem.name.indexOf('multiselect') == -1) { Data.append(elem.name, elem.value); } }); DebugMsg(Data); $('input[type="file"]').each(function(i, elem) { if($(elem)[0].files['length']) { Data.append($(elem).attr('name'), $(elem)[0].files[0]); } }); DebugMsg(Data); return Data; } function ExportFiles(_path) { $('.CONNECT').show(); $('.MODULE').show(); $.ajax({ url:_path, method:'GET', beforeSend:function(xhr) { xhr.overrideMimeType("text/comma-separated-values; charset=shift_jis"); }, success:function(result, textStatus, xhr) { //DebugMsg('SUCCESS'); DebugMsg(result); result = result.split("{%}"); let FileName = result[1]; result = Encoding.stringToCode(result[0]); result = Encoding.convert(result, "SJIS", "UNICODE"); result = new Uint8Array(result); let downloadData = new Blob([result], {type:'text/csv;charset=sjis;'}); //DebugMsg(result); if(window.navigator.msSaveBlob) { window.navigator.msSaveBlob(downloadData, FileName); $('.CONNECT').hide(); $('.MODULE').hide(); } else { let downloadUrl = (window.URL || window.webkitURL).createObjectURL(downloadData); let link = document.createElement('a'); link.href = downloadUrl; link.download = FileName; link.click(); (window.URL || window.webkitURL).revokeObjectURL(downloadUrl); $('.CONNECT').hide(); $('.MODULE').hide(); } }, error:function(xhr, textStatus, error) { DebugMsg('ERROR'); $('.CONNECT').hide(); $('.MODULE').hide(); } }); } jQuery(function($) { //サイドナビ開閉 $(document).on('click', 'li[cabin]', function(){ $(this).next('ul').toggle(); $(this).toggleClass("OPEN CLOSE"); }); //リンク $(document).on("click", "[href]", function() { if($(this).attr("href") != '') { if(!$(this).attr('target')) { location.href = $(this).attr("href"); } else { window.open($(this).attr("href")); } } }); //エクスポート $(document).on("click", "[export]", function() { if($(this).attr("export") != '') { /*DebugMsg('Export');*/ ExportFiles($(this).attr("export")); } }); //メール送信 $(document).on("click", "[send]", function() { if($(this).attr("send") != '') { /*DebugMsg('メール送信');*/ SendMail($(this)); } }); //レポート起動 $(document).on("click", "[ajax]", function() { if($(this).attr("ajax") != '') { DebugMsg('レポート起動'); ShowReport($(this).attr("ajax")); } }); //公開設定 $(document).on("click", ".BTN.ChangeOPEN", function() { /*DebugMsg("公開設定");*/ SubmitForm($(this)); }); $(document).on("click", ".BTN.ChangeCLOSE", function() { /*DebugMsg("非公開");*/ SubmitForm($(this)); }); $(document).on("click", ".BTN.SEARCH", function() { /*DebugMsg("検索");*/ SubmitSearch($(this)); }); $(document).on("click", ".BTN.DELETE", function() { /*DebugMsg("削除");*/ SubmitForm($(this)); }); $(document).on("click", ".BTN.COPY", function() { DebugMsg("コピー"); SubmitForm($(this)); }); //ファイル選択解除 $(document).on("click", ".BTN.FileClear", function() { DebugMsg("公開設定"); FileClear($(this)); }); //パスワード表示切り替え $(document).on("click", ".BTN.SUB.PWD", function(){ ChengePwdShow($(this)); }); }); function ChengePwdShow(_btn) { DebugMsg("パスワード表示変更"); if($('input[name="pwd"]').get(0).type == 'password') { $('input[name="pwd"]').get(0).type = 'text'; _btn.val('非表示'); _btn.prop('title','パスワードを非表示にする'); } else { $('input[name="pwd"]').get(0).type = 'password'; _btn.val('表示'); _btn.prop('title','パスワードを表示する'); } } function SubmitForm(_btn) { $('.CONNECT').show(); $('.MODULE').show(); var SubmitData = CreateSubmitData(_btn.parents("form")); var Url = _btn.attr('action'); $.ajax({ url:Url, method:'POST', data:SubmitData, processData:false, contentType:false, success:function(result, textStatus, xhr) { DebugMsg('Success'); DebugMsg(result); DebugMsg(textStatus); DebugMsg(xhr); res = result.split("{%}"); DebugMsg(res); if(res[0] == 'move') { location.href = res[1]; } else if(res[0] == 'check' || res[0] == 'regist') { $('.CONNECT').hide(); $('.SUCCESS').empty(); $('.SUCCESS').append(res[1]); $('.SUCCESS').show(); } else if(res[0] == 'append') { $('.WINDOW.LIST').empty(); $('.WINDOW.LIST').append(res[1]); $('.CONNECT').hide(); $('.MODULE').hide(); } else { $('.CONNECT').hide(); } }, error:function(xhr, textStatus, error) { DebugMsg('Error'); DebugMsg(xhr); DebugMsg(textStatus); DebugMsg(error); $('.CONNECT').hide(); } }); } function SubmitSearch(_btn) { var SubmitData = CreateSubmitData(_btn.parents("form")); var Url = _btn.attr('action'); _btn.parents("form").attr("action", Url); _btn.parents("form").submit(); } function SendMail(_btn) { $('.CONNECT').show(); $('.MODULE').show(); var SubmitData = CreateSubmitData(_btn.parents("form")); var Url = _btn.attr('send'); DebugMsg('メール送信 = '+Url); $.ajax({ url:Url, method:'POST', data:SubmitData, processData:false, contentType:false, success:function(result, textStatus, xhr) { DebugMsg('Success'); DebugMsg(result); DebugMsg(textStatus); DebugMsg(xhr); res = result.split("{%}"); DebugMsg(res); if(res[0] == 'move') { location.href = res[1]; } else if(res[0] == 'check' || res[0] == 'regist') { $('.CONNECT').hide(); $('.SUCCESS').empty(); $('.SUCCESS').append(res[1]); $('.SUCCESS').show(); } else if(res[0] == 'append') { $('.WINDOW.LIST').empty(); $('.WINDOW.LIST').append(res[1]); $('.CONNECT').hide(); $('.MODULE').hide(); } else { $('.CONNECT').hide(); } }, error:function(xhr, textStatus, error) { DebugMsg('Error'); DebugMsg(xhr); DebugMsg(textStatus); DebugMsg(error); $('.CONNECT').hide(); } }); } function ShowReport(_url) { $('.CONNECT').show(); $('.MODULE').show(); $.ajax({ url:_url, method:'POST', processData:false, contentType:false, success:function(result, textStatus, xhr) { DebugMsg('Success'); DebugMsg(result); DebugMsg(textStatus); DebugMsg(xhr); res = result.split("{%}"); DebugMsg(res); if(res[0] == 'check' || res[0] == 'regist') { $('.CONNECT').hide(); $('.SUCCESS').empty(); $('.SUCCESS').append(res[1]); $('.SUCCESS').show(); } else { $('.CONNECT').hide(); } }, error:function(xhr, textStatus, error) { DebugMsg('Error'); DebugMsg(xhr); DebugMsg(textStatus); DebugMsg(error); $('.CONNECT').hide(); } }); } /*公開設定*/ function UpdateOpen(_btn) { } /*全チェック*/ function CheckAll(_btn) { $(_btn).parents('form').find('.PAGES').each(function() { DebugMsg($(this).css("display")); if($(this).css("display") == "none") { DebugMsg($(this).attr('id')+" : 解除"); $(this).find('[type="checkbox"]').prop('checked', false); } else { DebugMsg($(this).attr('id')+" : チェック"); $(this).find('[type="checkbox"]').prop('checked', true); } }); ButtonDisabled($(_btn).parents('form')); } /*チェック解除*/ function ClearAll(_btn) { $(_btn).parents('form').find('.PAGES').each(function() { $(this).find('[type="checkbox"]').prop('checked', false); }); ButtonDisabled($(_btn).parents('form')); } /*ボタンDisabled判定*/ function ButtonDisabled(_form) { if($(_form).find('.PAGES').find('[type=checkbox]:checked').length > 0) { $(_form).find('.BTN.COPY').prop("disabled", false); $(_form).find('.BTN.DELETE').prop("disabled", false); $(_form).find('.BTN.ChangeOPEN').prop("disabled", false); $(_form).find('.BTN.ChangeCLOSE').prop("disabled", false); $(_form).find('.BTN.SEND').prop("disabled", false); } else { $(_form).find('.BTN.COPY').prop("disabled", true); $(_form).find('.BTN.DELETE').prop("disabled", true); $(_form).find('.BTN.ChangeOPEN').prop("disabled", true); $(_form).find('.BTN.ChangeCLOSE').prop("disabled", true); $(_form).find('.BTN.SEND').prop("disabled", true); } } /*チェックボックス動作*/ $('body').on('click','input[type="checkbox"]', function() { ButtonDisabled($(this).parents('form')); }); /*アップロードファイル名変換 + 容量確認*/ var ImageSize = 0; var ContentSize = 0; var PackageSize = 0; var InfomationSize = 0; $(function() { $('[type=file]').change(function(e) { console.log($(this).attr('id')); $('#'+$(this).attr('id')+'Text').html($(this).val().replace('C:\\fakepath\\','')); if($(this).attr('id').indexOf('Image') !== -1) { var ImageReader = new FileReader(); var Target = '#'+$(this).attr('id')+'Preview'; ImageReader.onload = function(e) { $(Target).attr('src',e.target.result); } ImageReader.readAsDataURL(e.target.files[0]); ImageSize = $(this).prop('files')[0].size; } else if($(this).attr('id').indexOf('Package') !== -1) { PackageFile = $(this).prop('files')[0].size; } else if($(this).attr('id').indexOf('Infomation') !== -1) { InfomationSize = $(this).prop('files')[0].size; } else if($(this).attr('id').indexOf('Content') !== -1) { ContentSize = $(this).prop('files')[0].size; } if((ImageSize + ContentSize + PackageFile + InfomationSize) > MaxFileSize) { $('.MODULE').show(); $('.FAILED .MSG').html(SizeOver); $('.FAILED').show(); } }); }); /*SCOタイプ選択*/ $(function() { $('#Type').on('change', function() { var type = $('option:selected', this).val(); if(type != 3 && type != 0) { $('.SCOFILE').show(); if(type != 2 && type < 7) { $('.KICKFILE').show(); } else { $('.KICKFILE').hide(); } if(type == 9) { $('.SCOFILE').hide(); } else { $('.SCOFILE').show(); } } else { if(type == 0) { $('.KICKFILE').hide(); } else { $('.KICKFILE').show(); } $('.SCOFILE').hide(); } }); }); /*ファイル選択解除*/ function FileClear(_btn) { var Type = _btn.attr('id').split('.')[0]; $('#'+Type).val(''); $('#'+Type+'Text').html('ファイルを選択してください。'); if(Type == 'ContentFile') { ContentSize = 0; } else if(Type == 'PackageFile') { PackageSize = 0; } else if(Type == 'InfomationFile') { InfomationSize = 0; } else if(Type == 'ThumbnailImage') { ImageSize = 0; $('#'+Type+'Preview').attr('src',''); } } /*ユーザ権限選択*/ function SelectAuth(_auth) { if(_auth != 1) { $('#Gid').multiselect('enable'); } else { $('#Gid').multiselect('disable'); } } /*読み込み完了後描画*/ $(document).ready(function() { $('.MAIN').css('display','flex'); $('body').css('display','flex'); });