FANDOM


第1行: 第1行:
 
<div class="attr-l" id="status_bar" style="text-align:center; font-weight:bold; line-height:25px; font-size:15px; display: none"></div>
 
<div class="attr-l" id="status_bar" style="text-align:center; font-weight:bold; line-height:25px; font-size:15px; display: none"></div>
<style type="text/css">#new_team_table input{width:calc(100% - 4px);}</style>
+
<style type="text/css">#new_team_table input,#new_team_table select{width:calc(100% - 4px);}</style>
 
<form id="new_team">
 
<form id="new_team">
隊伍名:<input type="text" id="team_name" /> 關卡名:<input type="text" id="stage_name" disabled="disabled" /><br />
+
隊伍名:<input type="text" id="team_name" /> 關卡名:<input type="text" id="stage_name" disabled="disabled" /><br />若各項數值為最大,請不要填寫
 
<table><tr><td style="width: 70%">
 
<table><tr><td style="width: 70%">
 
<table id="new_team_table" class="wikitable" style="table-layout: fixed; width: 100%">
 
<table id="new_team_table" class="wikitable" style="table-layout: fixed; width: 100%">
第13行: 第13行:
 
<td><input type="number" data-id="lv1" min="1" max="99" /></td>
 
<td><input type="number" data-id="lv1" min="1" max="99" /></td>
 
<td><input type="number" data-id="cd1" min="1" max="50" /></td>
 
<td><input type="number" data-id="cd1" min="1" max="50" /></td>
<td><input type="number" data-id="ref1" min="1" max="4" /></td>
+
<td>
  +
<select data-id="ref1">
  +
<option value="" selected="selected">無</option>
  +
<option value="1">I</option>
  +
<option value="2">II</option>
  +
<option value="3">III</option>
  +
<option value="4">IV</option>
  +
</select>
  +
</td>
 
</tr>
 
</tr>
 
<tr>
 
<tr>
第20行: 第20行:
 
<td><input type="number" data-id="lv2" min="1" max="99" /></td>
 
<td><input type="number" data-id="lv2" min="1" max="99" /></td>
 
<td><input type="number" data-id="cd2" min="1" max="50" /></td>
 
<td><input type="number" data-id="cd2" min="1" max="50" /></td>
<td><input type="number" data-id="ref2" min="1" max="4" /></td>
+
<td>
  +
<select data-id="ref2">
  +
<option value="" selected="selected">無</option>
  +
<option value="1">I</option>
  +
<option value="2">II</option>
  +
<option value="3">III</option>
  +
<option value="4">IV</option>
  +
</select>
  +
</td>
 
</tr>
 
</tr>
 
<tr>
 
<tr>
第27行: 第27行:
 
<td><input type="number" data-id="lv3" min="1" max="99" /></td>
 
<td><input type="number" data-id="lv3" min="1" max="99" /></td>
 
<td><input type="number" data-id="cd3" min="1" max="50" /></td>
 
<td><input type="number" data-id="cd3" min="1" max="50" /></td>
<td><input type="number" data-id="ref3" min="1" max="4" /></td>
+
<td>
  +
<select data-id="ref3">
  +
<option value="" selected="selected">無</option>
  +
<option value="1">I</option>
  +
<option value="2">II</option>
  +
<option value="3">III</option>
  +
<option value="4">IV</option>
  +
</select>
  +
</td>
 
</tr>
 
</tr>
 
<tr>
 
<tr>
第34行: 第34行:
 
<td><input type="number" data-id="lv4" min="1" max="99" /></td>
 
<td><input type="number" data-id="lv4" min="1" max="99" /></td>
 
<td><input type="number" data-id="cd4" min="1" max="50" /></td>
 
<td><input type="number" data-id="cd4" min="1" max="50" /></td>
<td><input type="number" data-id="ref4" min="1" max="4" /></td>
+
<td>
  +
<select data-id="ref4">
  +
<option value="" selected="selected">無</option>
  +
<option value="1">I</option>
  +
<option value="2">II</option>
  +
<option value="3">III</option>
  +
<option value="4">IV</option>
  +
</select>
  +
</td>
 
</tr>
 
</tr>
 
<tr>
 
<tr>
第41行: 第41行:
 
<td><input type="number" data-id="lv5" min="1" max="99" /></td>
 
<td><input type="number" data-id="lv5" min="1" max="99" /></td>
 
<td><input type="number" data-id="cd5" min="1" max="50" /></td>
 
<td><input type="number" data-id="cd5" min="1" max="50" /></td>
<td><input type="number" data-id="ref5" min="1" max="4" /></td>
+
<td>
  +
<select data-id="ref5">
  +
<option value="" selected="selected">無</option>
  +
<option value="1">I</option>
  +
<option value="2">II</option>
  +
<option value="3">III</option>
  +
<option value="4">IV</option>
  +
</select>
  +
</td>
 
</tr>
 
</tr>
 
<tr>
 
<tr>
第48行: 第48行:
 
<td><input type="number" data-id="lv6" min="1" max="99" /></td>
 
<td><input type="number" data-id="lv6" min="1" max="99" /></td>
 
<td><input type="number" data-id="cd6" min="1" max="50" /></td>
 
<td><input type="number" data-id="cd6" min="1" max="50" /></td>
<td><input type="number" data-id="ref6" min="1" max="4" /></td>
+
<td>
  +
<select data-id="ref6">
  +
<option value="" selected="selected">無</option>
  +
<option value="1">I</option>
  +
<option value="2">II</option>
  +
<option value="3">III</option>
  +
<option value="4">IV</option>
  +
</select>
  +
</td>
 
</tr>
 
</tr>
 
</table>
 
</table>
第113行: 第113行:
 
function buildText() {
 
function buildText() {
 
 
var all = $('#new_team_table input');
+
var all = $('#new_team_table input,#new_team_table select');
 
var text = decodeURI('%7B%7BRanks|size=700|title=') + $('#team_name').val();
 
var text = decodeURI('%7B%7BRanks|size=700|title=') + $('#team_name').val();
 
 

2015年7月18日 (星期六) 02:56的版本

<style type="text/css">#new_team_table input,#new_team_table select{width:calc(100% - 4px);}</style> <form id="new_team"> 隊伍名:<input type="text" id="team_name" /> 關卡名:<input type="text" id="stage_name" disabled="disabled" />
若各項數值為最大,請不要填寫

編號等級技能回合數昇華等級
隊長 <input type="number" data-id="id1" min="1" max="9999" required="required" /> <input type="number" data-id="lv1" min="1" max="99" /> <input type="number" data-id="cd1" min="1" max="50" />

<select data-id="ref1"> <option value="" selected="selected">無</option> <option value="1">I</option> <option value="2">II</option> <option value="3">III</option> <option value="4">IV</option> </select>

隊員1 <input type="number" data-id="id2" min="1" max="9999" /> <input type="number" data-id="lv2" min="1" max="99" /> <input type="number" data-id="cd2" min="1" max="50" />

<select data-id="ref2"> <option value="" selected="selected">無</option> <option value="1">I</option> <option value="2">II</option> <option value="3">III</option> <option value="4">IV</option> </select>

隊員2 <input type="number" data-id="id3" min="1" max="9999" /> <input type="number" data-id="lv3" min="1" max="99" /> <input type="number" data-id="cd3" min="1" max="50" />

<select data-id="ref3"> <option value="" selected="selected">無</option> <option value="1">I</option> <option value="2">II</option> <option value="3">III</option> <option value="4">IV</option> </select>

隊員3 <input type="number" data-id="id4" min="1" max="9999" /> <input type="number" data-id="lv4" min="1" max="99" /> <input type="number" data-id="cd4" min="1" max="50" />

<select data-id="ref4"> <option value="" selected="selected">無</option> <option value="1">I</option> <option value="2">II</option> <option value="3">III</option> <option value="4">IV</option> </select>

隊員4 <input type="number" data-id="id5" min="1" max="9999" /> <input type="number" data-id="lv5" min="1" max="99" /> <input type="number" data-id="cd5" min="1" max="50" />

<select data-id="ref5"> <option value="" selected="selected">無</option> <option value="1">I</option> <option value="2">II</option> <option value="3">III</option> <option value="4">IV</option> </select>

隊友 <input type="number" data-id="id6" min="1" max="9999" required="required" /> <input type="number" data-id="lv6" min="1" max="99" /> <input type="number" data-id="cd6" min="1" max="50" />

<select data-id="ref6"> <option value="" selected="selected">無</option> <option value="1">I</option> <option value="2">II</option> <option value="3">III</option> <option value="4">IV</option> </select>

完整通關攻略

<textarea id="attack_method" style="resize:none;width:100%;height:200px;"></textarea>

<input type="button" value="預覽" id="preview" /><input type="submit" /> </form> <script> (function NewTeam(){ if(typeof jQuery == "undefined") { setTimeout(NewTeam, 100); return; }

if(typeof mw == "undefined") { setTimeout(NewTeam, 100); return; }

function submit(title, text, func) { $.post( "http://zh.tos.wikia.com/api.php", { action: 'edit', appendtext: text, title: title + '/通關技巧及參考隊伍', token: mw.user.tokens.get('editToken'), format: 'json' }, func, 'json' ); }

function numberString(number) { number = parseInt(number + ); if(number < 10) { return '00' + number; } else if (number < 100) { return '0' + number; } else { return + number; } }

function showStatus(text, type) { var status_bar = $('#status_bar'); status_bar.show('slow'); status_bar.text(text); status_bar.removeClass('attr-w attr-l attr-f'); switch (type) { case 0: status_bar.addClass('attr-w'); return; case 1: status_bar.addClass('attr-l'); return; case 2: status_bar.addClass('attr-f'); return; } }

function error () { $(this).find('input[type=submit]:eq(0)').attr('disabled', false); showStatus('發生錯誤,請重新整理後再試一次,並請確保在網路狀態良好環境下進行', 2); }

function encode (v) { return $('<div/>').text(v).html(); }

function buildText() {

var all = $('#new_team_table input,#new_team_table select'); var text = decodeURI('%7B%7BRanks|size=700|title=') + $('#team_name').val();

for(var i = 0; i < all.length; i++) { if(all.eq(Math.floor((i)/4)*4).val() == ) continue; if(all.eq(i).val() == ) continue; text += ('|' + all.eq(i).data('id') + '=' + ((i%4==0)?numberString(all.eq(i).val()):all.eq(i).val())); }

text += ('|explain=' + encode($('#attack_method').val()).replace(/~/g, decodeURIComponent('%26%23126%3B')).replace(/\n/g,'
') + '
~~' + '~~' + decodeURI('%7D%7D') + '\n'); return text; }

$('#stage_name').val((wgPageName.split('/'))[0]);

$('#preview').click(function() { $.getJSON('http://zh.tos.wikia.com/api.php', { action: 'parse', format: 'json', text: buildText() }, function (data) { $('#preview_area').children().remove(); $(data.parse.text['*']).appendTo('#preview_area'); } ); });

$('#new_team').on('submit', function(e){ e.preventDefault(); showStatus('正在新增,請稍候', 1); $(this).find('input[type=submit]:eq(0)').attr('disabled', true);

submit($('#stage_name').val(), buildText(), function (data) { if (typeof data == 'object') { if (typeof data.edit == 'object') { if (data.edit.result == "Success") { showStatus('新增成功,請等待跳轉...', 0); window.location.href='http://zh.tos.wikia.com/wiki/' + $('#stage_name').val() + '/通關技巧及參考隊伍'; } else { error(); } } else { error(); } } else { error(); } }); });

})(); </script>

除了特别提示,社区内容遵循CC-BY-SA 授权许可。