96 lines
2.7 KiB
JavaScript
96 lines
2.7 KiB
JavaScript
loadcdn('script', 'https://jpostal-1006.appspot.com/jquery.jpostal.js');
|
|
|
|
let pageLoading = 0; //0:未処理 1:処理中 2:処理完了
|
|
|
|
//----------------------------------------------------------------------
|
|
//初期処理
|
|
window.addEventListener('load', function () {
|
|
if (pageLoading == 0) {
|
|
console.log('Window load Event');
|
|
$p.ex.onLoad();
|
|
}
|
|
});
|
|
|
|
$p.events.on_editor_load = function () {
|
|
if (pageLoading == 0) {
|
|
console.log('on Editor Load');
|
|
$p.ex.onLoad();
|
|
}
|
|
}
|
|
|
|
$p.ex.onLoad = function () {
|
|
//ロード開始
|
|
pageLoading = 1;
|
|
|
|
//初期処理
|
|
$p.ex.init();
|
|
}
|
|
|
|
$p.ex.init = function () {
|
|
//郵便番号を入れる項目を「ClassF」
|
|
// 外部スクリプトの読み込みを確認
|
|
let checkScriptLoaded = setInterval(function () {
|
|
if (typeof $.fn.jpostal !== 'undefined') {
|
|
clearInterval(checkScriptLoaded);
|
|
console.log('jpostal.js が読み込まれました。');
|
|
$('#Results_ClassF').jpostal({
|
|
postcode: [
|
|
'#Results_ClassF'
|
|
],
|
|
// 戻り値を各項目へ保管
|
|
address: {
|
|
'#Results_ClassG': '%3',
|
|
'#Results_ClassH': '%4',
|
|
'#Results_ClassI': '%5'
|
|
}
|
|
});
|
|
} else {
|
|
console.log('jpostal.js の読み込みを待機中...');
|
|
}
|
|
}, 100);
|
|
|
|
$p.ex.createIeconButton();
|
|
|
|
}
|
|
|
|
$p.ex.createIeconButton = function () {
|
|
let bukkenId = $('#Results_ClassZ').val();
|
|
if (bukkenId == '') {
|
|
return;
|
|
}
|
|
|
|
let ieconBaseUrl = 'https://iecon-app.com/manage/'
|
|
let bukkenUrl = ieconBaseUrl + 'articles/' + bukkenId;
|
|
let fileUrl = ieconBaseUrl + 'articles/' + bukkenId + '/article_files';
|
|
|
|
let button1 = document.createElement('button');
|
|
button1.id = 'iecon_bukken_button';
|
|
button1.type = 'button';
|
|
button1.innerText = '物件管理画面へ';
|
|
button1.style.marginRight = '10px';
|
|
button1.setAttribute('onclick', 'window.open("' + bukkenUrl + '", \'_blank\');');
|
|
|
|
let button2 = document.createElement('button');
|
|
button2.id = 'iecon_file_button';
|
|
button2.type = 'button';
|
|
button2.innerText = '物件ファイル管理画面へ';
|
|
button2.setAttribute('onclick', 'window.open("' + fileUrl + '", \'_blank\');');
|
|
|
|
let container = document.createElement('div');
|
|
container.appendChild(button1);
|
|
container.appendChild(button2);
|
|
container.style.float = 'left';
|
|
|
|
|
|
$('#Results_ClassZField').after(container);
|
|
|
|
$('#iecon_bukken_button').button({
|
|
icon: 'ui-icon-document'
|
|
});
|
|
$('#iecon_file_button').button({
|
|
icon: 'ui-icon-document'
|
|
});
|
|
|
|
|
|
|
|
} |