FANDOM


 
(未显示2个用户的47个中间版本)
第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>
  +
<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 />若數值為最大,請不要填寫
+
關卡難度:<select id="stagelevel"><option value="ultimate" selected="selected">地獄級</option><option value="nightmare">夢魘級</option><option value="basic">初級</option><option value="intermediate">中級</option><option value="advanced">高級</option><option value="extra">超級</option></select> 隊伍名:<input type="text" id="team_name" /> 關卡名:<input type="text" id="stage_name" disabled="disabled" /><br />若各項數值為最大,請不要填寫
<table id="new_team_table" class="wikitable" style="table-layout: fixed; float: left">
+
<table><tr><td style="width: 70%">
  +
<table id="new_team_table" class="wikitable" style="table-layout: fixed; width: 100%">
 
<tr>
 
<tr>
<th></th><th>編號</th><th>等級</th><th>技能回合數</th><th>昇華等級</th>
+
<th style="width:50px"></th><th>編號</th><th>等級</th><th>技能回合數</th><th>昇華等級</th>
 
</tr>
 
</tr>
 
<tr>
 
<tr>
<td>隊長</td><td><input type="number" min="1" max="9999" /></td><td><input type="number" min="1" max="99" /></td><td><input type="number" min="1" max="50" /></td><td><input type="number" min="1" max="4" /></td>
+
<td>隊長</td>
  +
<td><input type="number" data-id="id1" min="1" max="9999" required="required" /></td>
  +
<td><input type="number" data-id="lv1" min="1" max="99" placeholder="滿等勿填" /></td>
  +
<td><input type="number" data-id="cd1" min="1" max="50" placeholder="滿技勿填" /></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>
<td>隊員1</td><td><input type="number" min="1" max="9999" /></td><td><input type="number" min="1" max="99" /></td><td><input type="number" min="1" max="50" /></td><td><input type="number" min="1" max="4" /></td>
+
<td>隊員1</td>
  +
<td><input type="number" data-id="id2" min="1" max="9999" /></td>
  +
<td><input type="number" data-id="lv2" min="1" max="99" placeholder="滿等勿填" /></td>
  +
<td><input type="number" data-id="cd2" min="1" max="50" placeholder="滿技勿填" /></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>
<td>隊員2</td><td><input type="number" min="1" max="9999" /></td><td><input type="number" min="1" max="99" /></td><td><input type="number" min="1" max="50" /></td><td><input type="number" min="1" max="4" /></td>
+
<td>隊員2</td>
  +
<td><input type="number" data-id="id3" min="1" max="9999" /></td>
  +
<td><input type="number" data-id="lv3" min="1" max="99" placeholder="滿等勿填" /></td>
  +
<td><input type="number" data-id="cd3" min="1" max="50" placeholder="滿技勿填" /></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>
<td>隊員3</td><td><input type="number" min="1" max="9999" /></td><td><input type="number" min="1" max="99" /></td><td><input type="number" min="1" max="50" /></td><td><input type="number" min="1" max="4" /></td>
+
<td>隊員3</td>
  +
<td><input type="number" data-id="id4" min="1" max="9999" /></td>
  +
<td><input type="number" data-id="lv4" min="1" max="99" placeholder="滿等勿填" /></td>
  +
<td><input type="number" data-id="cd4" min="1" max="50" placeholder="滿技勿填" /></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>
<td>隊員4</td><td><input type="number" min="1" max="9999" /></td><td><input type="number" min="1" max="99" /></td><td><input type="number" min="1" max="50" /></td><td><input type="number" min="1" max="4" /></td>
+
<td>隊員4</td>
  +
<td><input type="number" data-id="id5" min="1" max="9999" /></td>
  +
<td><input type="number" data-id="lv5" min="1" max="99" placeholder="滿等勿填" /></td>
  +
<td><input type="number" data-id="cd5" min="1" max="50" placeholder="滿技勿填" /></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>
<td>隊友</td><td><input type="number" min="1" max="9999" /></td><td><input type="number" min="1" max="99" /></td><td><input type="number" min="1" max="50" /></td><td><input type="number" min="1" max="4" /></td>
+
<td>隊友</td>
  +
<td><input type="number" data-id="id6" min="1" max="9999" required="required" /></td>
  +
<td><input type="number" data-id="lv6" min="1" max="99" placeholder="滿等勿填" /></td>
  +
<td><input type="number" data-id="cd6" min="1" max="50" placeholder="滿技勿填" /></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>
完整通關攻略
+
</td><td>
<textarea id="attack_method" style="resize:none;width:300px;height:200px;"></textarea>
+
完整通關攻略<br />
<input type="submit" />
+
<textarea id="attack_method" style="resize:none;width:100%;height:200px;"></textarea><br /></td></tr></table>
  +
<div id="preview_area"></div>
  +
<input type="button" value="預覽" id="preview" /><input type="submit" />
 
</form>
 
</form>
 
<script>
 
<script>
第40行: 第42行:
 
}
 
}
 
 
function submit(title, text) {
+
function submit(title, text, func) {
 
$.post(
 
$.post(
 
"http://zh.tos.wikia.com/api.php",
 
"http://zh.tos.wikia.com/api.php",
第50行: 第52行:
 
format: 'json'
 
format: 'json'
 
},
 
},
function() {},
+
func, 'json'
'json'
 
 
);
 
);
 
}
 
}
 
 
 
function numberString(number) {
 
function numberString(number) {
  +
number = parseInt(number + '');
 
if(number < 10) {
 
if(number < 10) {
 
return '00' + number;
 
return '00' + number;
第62行: 第65行:
 
return '' + number;
 
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() + '|stagelv=' + $('#stagelevel').children(':selected').text();
  +
  +
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,'<br />') + '<br />~~' + '~~' + decodeURI('%7D%7D') + '\n');
  +
return text;
 
}
 
}
 
 
 
$('#stage_name').val((wgPageName.split('/'))[0]);
 
$('#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){
 
$('#new_team').on('submit', function(e){
 
e.preventDefault();
 
e.preventDefault();
var all = $('#new_team_table input');
+
showStatus('正在新增,請稍候', 1);
var text=decodeURI('%7B%7BRanks|size=700|title=') + $('#team_name').val() +
+
$(this).find('input[type=submit]:eq(0)').attr('disabled', true);
'|id1=' + numberString(all.eq( 0).val()) + '|lv1=' + all.eq( 1).val() + '|cd1=' + all.eq( 2).val() + '|ref1=' + all.eq( 3).val() +
+
'|id2=' + numberString(all.eq( 4).val()) + '|lv2=' + all.eq( 5).val() + '|cd2=' + all.eq( 6).val() + '|ref2=' + all.eq( 7).val() +
+
submit($('#stage_name').val(), buildText(), function (data) {
'|id3=' + numberString(all.eq( 8).val()) + '|lv3=' + all.eq( 9).val() + '|cd3=' + all.eq(10).val() + '|ref3=' + all.eq(11).val() +
+
if (typeof data == 'object') {
'|id4=' + numberString(all.eq(12).val()) + '|lv4=' + all.eq(13).val() + '|cd4=' + all.eq(14).val() + '|ref4=' + all.eq(15).val() +
+
if (typeof data.edit == 'object') {
'|id5=' + numberString(all.eq(16).val()) + '|lv5=' + all.eq(17).val() + '|cd5=' + all.eq(18).val() + '|ref5=' + all.eq(19).val() +
+
if (data.edit.result == "Success") {
'|id6=' + numberString(all.eq(20).val()) + '|lv6=' + all.eq(21).val() + '|cd6=' + all.eq(22).val() + '|ref6=' + all.eq(23).val() +
+
showStatus('新增成功,請等待跳轉...', 0);
'|explain=' + $('#attack_method').val().replace(/\n/g,'<br />') + '<br />~~' + '~~' + decodeURI('%7D%7D') + '\n';
+
window.location.href='http://zh.tos.wikia.com/wiki/' + $('#stage_name').val() + '/通關技巧及參考隊伍';
submit($('#stage_name').val(), text);
+
} else {
  +
error();
  +
}
  +
} else {
  +
error();
  +
}
  +
} else {
  +
error();
  +
}
  +
});
 
});
 
});
 
 

2015年8月15日 (星期六) 20:24的最后版本

<style type="text/css">#new_team_table input,#new_team_table select{width:calc(100% - 4px);}</style> <form id="new_team"> 關卡難度:<select id="stagelevel"><option value="ultimate" selected="selected">地獄級</option><option value="nightmare">夢魘級</option><option value="basic">初級</option><option value="intermediate">中級</option><option value="advanced">高級</option><option value="extra">超級</option></select> 隊伍名:<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" placeholder="滿等勿填" /> <input type="number" data-id="cd1" min="1" max="50" placeholder="滿技勿填" />

<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" placeholder="滿等勿填" /> <input type="number" data-id="cd2" min="1" max="50" placeholder="滿技勿填" />

<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" placeholder="滿等勿填" /> <input type="number" data-id="cd3" min="1" max="50" placeholder="滿技勿填" />

<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" placeholder="滿等勿填" /> <input type="number" data-id="cd4" min="1" max="50" placeholder="滿技勿填" />

<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" placeholder="滿等勿填" /> <input type="number" data-id="cd5" min="1" max="50" placeholder="滿技勿填" />

<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" placeholder="滿等勿填" /> <input type="number" data-id="cd6" min="1" max="50" placeholder="滿技勿填" />

<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() + '|stagelv=' + $('#stagelevel').children(':selected').text();

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 授权许可。