したらばTOP ■掲示板に戻る■ 全部 1-100 最新50 | メール | |
レス数が900を超えています。1000を超えると投稿できなくなるよ。

戦国IXA ツールスレPart48

634名無しさん:2023/08/30(水) 08:46:46 ID:iOR7Vu4I
>>631
2個目
functionの中身ごっそり書き換えたので完成形だけ置いておきます

// 本丸・所領防御陣形の列一括入れ替え 20230828ここから
function switchDefenceLine() {
var honmaru_url = '/card/defense_formation_deck.php',
shoryo_url = '/card/sub_area_defense_formation_deck.php';
if (location.pathname != honmaru_url && location.pathname != shoryo_url) {
return;
}

var hon_sho_flg = location.pathname == honmaru_url ? '本丸' : '所領',
post_url = '/card/defense_formation_deck_if.php',
unit_id = [];

// 各列のunit_idを取得
$('div.home_defense_formation_line_wrap').each(function() {
unit_id.push($(this).find('div.home_defense_formation_card_space:first').attr('data-unit_id'));
});
if (unit_id.filter(Boolean).length < 2) return;

// 要素定義
var line_str = ['第壱[1]列', '第弐[2]列', '第参[3]列', '第肆[4]列'],
div_tag = $('<div id="switch_defence" style="display: table; height: 28px;">'),
p_tag = $('<p style="display: table-cell; vertical-align: middle;">'),
label_from = $('<label for="select_from" style="color: #FFF;">From: </label>'),
sele_from = $('<select name="select_from" id="select_from" style="margin-right: 5px;">'),
label_to = $('<label for="select_to" style="color: #FFF">To: </label>'),
sele_to = $('<select name="select_to" id="select_to" style="margin-right: 10px;">');
if (hon_sho_flg == '本丸') {
line_str.push('第伍[5]列');
}
for (var i = 0; i < (unit_id.filter(Boolean)).length; i++) {
sele_from.append($('<option value="' + i + '">' + line_str[i] + '</option>'));
sele_to.append($('<option value="' + i + '">' + line_str[i] + '</option>'));
}

// 入れ替え処理
var swap_btn = $('<input type="button" value="列入れ替え">').on('click', function() {

// データ送信処理
var post_swap_defense_line = function(data_list) {
$.ajax({
type: 'post',
url: post_url,
data: data_list.data,
xhrFields: {
'X-Requested-With': 'XMLHttpRequest',
},
}).then(function(res) {
Info.log(data_list.from_line + '列目と' + (data_list.from_line + data_list.data.sort) + '列目を入れ替え中...');
$(this).prop('disabled', false);
var href = hon_sho_flg == '本丸' ? honmaru_url : shoryo_url;
setTimeout(Info.title, 2000, '完了', href);
}, null);
}

// 入れ替えデータ取得
var from_line = parseInt($('#select_from').find('option:selected').val()),
to_line = parseInt($('#select_to').find('option:selected').val());
if (from_line == to_line) {
alert('FromとToが同じです');
return false;
}
$(this).prop('disabled', true);
var data = {
'order': 'swapLine',
'unit_id': unit_id[from_line],
'sort': (to_line - from_line),
'is_sub_area_defense_formation': hon_sho_flg == '本丸' ? 0 : 1,
},
send_data = {'data': data, 'from_line': (from_line + 1), };
nowLoading();
Info.title(hon_sho_flg + '防御陣形【列一括入れ替え】');
post_swap_defense_line(send_data);

});

// 要素追加
p_tag.append(label_from, sele_from, label_to, sele_to, swap_btn);
div_tag.append(p_tag);
$('ul.home_defense_formation_foot_btns').find('li').eq(0).after(div_tag);
}
// 20230828ここまで


新着レスの表示


名前: E-mail(省略可)

※書き込む際の注意事項はこちら

※画像アップローダーはこちら

(画像を表示できるのは「画像リンクのサムネイル表示」がオンの掲示板に限ります)

掲示板管理者へ連絡 無料レンタル掲示板