FANDOM


 
(未显示2个用户的13个中间版本)
第3行: 第3行:
 
<form id="new_team">
 
<form id="new_team">
 
<table><tr><td>
 
<table><tr><td>
遊戲ID:<input style="width:60%;" type="number" id="gameid" /><br />隊伍名:<input style="width:60%;" type="text" id="team_name" /><br />用戶名:<input style="width:60%;" type="text" id="user_name" disabled="disabled" /><br />關卡名:<input style="width:60%;" type="text" id="stage_name" disabled="disabled" /><br />關卡難易度:<select id="stagelevel"><option value="ultimate" selected="selected">地獄級</option><option value="nightmare">夢魘級</option></select><br />魔法石通關:<input type="number" id="diamond_num" min="0" max="99" value="0" /><br />成就通關:<select id="achievement_num"><option value="0" selected="selected">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option></select><br /><font color="red"><span id="en_1"></span><br /><span id="msg"></span><span id="en_2"></span></font>
+
遊戲ID:<input style="width:60%;" type="number" id="gameid" /><br />隊伍名:<input style="width:60%;" type="text" id="team_name" /><br />用戶名:<input style="width:60%;" type="text" id="user_name" disabled="disabled" /><br />關卡名:<input style="width:60%;" type="text" id="stage_name" disabled="disabled" /><br />關卡難易度:<select id="stagelevel"></select><br />魔法石通關:<input type="number" id="diamond_num" min="0" max="99" value="0" /><br />成就通關:<select id="achievement_num"><option value="0" selected="selected">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option></select><br /><font color="red"><span id="en_1"></span><br /><span id="msg"></span><span id="en_2"></span></font>
 
</td><td style="width:70%"><table id="new_team_table" class="wikitable" style="table-layout: fixed; width: 100%">
 
</td><td style="width:70%"><table id="new_team_table" class="wikitable" style="table-layout: fixed; width: 100%">
 
<tr>
 
<tr>
第160行: 第160行:
 
{
 
{
 
var num = url.indexOf('?');
 
var num = url.indexOf('?');
if(!num)return null;
+
if(num == -1)return null;
 
var str = url.substring(num + 1, url.length);
 
var str = url.substring(num + 1, url.length);
var pairs = str.split(decodeURIComponent('%26'))[0];
+
var pairs = str.split(decodeURIComponent('%26'));
 
var obj = {};
 
var obj = {};
for(var pairstr in pairs)
+
for(var index in pairs)
 
{
 
{
var pair = pairstr.split('=');
+
var pair = pairs[index].split('=');
 
obj[pair[0]] = pair[1];
 
obj[pair[0]] = pair[1];
 
}
 
}
第190行: 第190行:
 
 
 
var map = parseArguments(location.href);
 
var map = parseArguments(location.href);
if(!map)history.back();
+
if(map) {
  +
var maptemp = decodeURIComponent(map['StageTitle']);
  +
$.getJSON('http://zh.tos.wikia.com/api.php', {
  +
action: 'query',
  +
titles: maptemp,
  +
prop: 'categories',
  +
format: 'json',
  +
indexpageids: 1
  +
}, function(json) {
  +
var pageid=(json.query.pageids[0] == -1)?history.back():json.query.pageids[0];
  +
var pagelen = json.query.pages[pageid].categories;
  +
if(pagelen) {
  +
for (var i = 0; i < pagelen.length; i++) {
  +
var pagecategory = json.query.pages[pageid].categories[i].title.replace('Category:','');
  +
if(pagecategory == '關卡') {
  +
} else if(pagecategory == '現正開放關卡') {
  +
} else {
  +
console.log(pagecategory);
  +
$('#stagelevel').append($('<option></option>').val(pagecategory).text(pagecategory));
  +
}
  +
}
  +
}
  +
});
  +
} else history.back();
 
$('#stage_name').val(decodeURIComponent(map['StageTitle']));
 
$('#stage_name').val(decodeURIComponent(map['StageTitle']));
 
$('#user_name').val((wgUserName.replace(' ','_')));
 
$('#user_name').val((wgUserName.replace(' ','_')));

2015年10月12日 (一) 23:42的最后版本

<style type="text/css">#new_team_table input,#new_team_table select{width:calc(100% - 4px);}</style> <form id="new_team">

遊戲ID:<input style="width:60%;" type="number" id="gameid" />
隊伍名:<input style="width:60%;" type="text" id="team_name" />
用戶名:<input style="width:60%;" type="text" id="user_name" disabled="disabled" />
關卡名:<input style="width:60%;" type="text" id="stage_name" disabled="disabled" />
關卡難易度:<select id="stagelevel"></select>
魔法石通關:<input type="number" id="diamond_num" min="0" max="99" value="0" />
成就通關:<select id="achievement_num"><option value="0" selected="selected">0</option><option value="1">1</option><option value="2">2</option><option value="3">3</option></select>

編號等級技能回合數昇華等級
隊長 <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:100px;" placeholder="※通關攻略請盡量詳細說明,內容請勿空白。嚴禁在此處發佈徵友及公會招生訊息。"></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 parseArguments(url) { var num = url.indexOf('?'); if(num == -1)return null; var str = url.substring(num + 1, url.length); var pairs = str.split(decodeURIComponent('%26')); var obj = {}; for(var index in pairs) { var pair = pairs[index].split('='); obj[pair[0]] = pair[1]; } return obj; }

function buildText() {

var all = $('#new_team_table input,#new_team_table select'); var text = decodeURI('%7B%7BNewRanks|title=') + $('#team_name').val() + '|stagelv=' + $('#stagelevel').children(':selected').text() + '|A=' + $('#achievement_num').children(':selected').val() + '|D=' + $('#diamond_num').val(); if($('#gameid').val() > 0) { text += '|id=' + decodeURI('%5B%5BUser_Talk:') + $('#user_name').val() + '|' + $('#gameid').val() + decodeURI('%5D%5D'); } 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; }

var map = parseArguments(location.href); if(map) { var maptemp = decodeURIComponent(map['StageTitle']); $.getJSON('http://zh.tos.wikia.com/api.php', { action: 'query', titles: maptemp, prop: 'categories', format: 'json', indexpageids: 1 }, function(json) { var pageid=(json.query.pageids[0] == -1)?history.back():json.query.pageids[0]; var pagelen = json.query.pages[pageid].categories; if(pagelen) { for (var i = 0; i < pagelen.length; i++) { var pagecategory = json.query.pages[pageid].categories[i].title.replace('Category:',); if(pagecategory == '關卡') { } else if(pagecategory == '現正開放關卡') { } else { console.log(pagecategory); $('#stagelevel').append($('<option></option>').val(pagecategory).text(pagecategory)); } } } }); } else history.back(); $('#stage_name').val(decodeURIComponent(map['StageTitle'])); $('#user_name').val((wgUserName.replace(' ','_'))); $('#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 授权许可。