Ken2812221(留言墙 | 貢獻) 小无编辑摘要 标签:sourceedit |
小无编辑摘要 标签:sourceedit |
||
(未显示2个用户的70个中间版本) | |||
第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> |
||
− | 隊伍名:<input type="text" id="team_name" /> |
||
+ | <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" /><br />若各項數值為最大,請不要填寫 |
||
⚫ | |||
+ | <table><tr><td style="width: 70%"> |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | <td>隊長</td><td><input type="number" min="1" max="9999" /></td><td><input type="number" min="1" max="9999" /></td><td><input type="number" min="1" max="9999" /></td><td><input type="number" min="1" max="9999" /></td> |
||
⚫ | |||
⚫ | |||
− | + | </tr> |
|
⚫ | |||
− | <td>隊員1</td><td><input type="number" min="1" max="9999" /></td><td><input type="number" min="1" max="9999" /></td><td><input type="number" min="1" max="9999" /></td><td><input type="number" min="1" max="9999" /></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"> |
||
− | <td>隊員3</td><td><input type="number" min="1" max="9999" /></td><td><input type="number" min="1" max="9999" /></td><td><input type="number" min="1" max="9999" /></td><td><input type="number" min="1" max="9999" /></td> |
||
+ | <option value="" selected="selected">無</option> |
||
⚫ | |||
+ | <option value="1">I</option> |
||
⚫ | |||
+ | <option value="2">II</option> |
||
− | <td>隊員4</td><td><input type="number" min="1" max="9999" /></td><td><input type="number" min="1" max="9999" /></td><td><input type="number" min="1" max="9999" /></td><td><input type="number" min="1" max="9999" /></td> |
||
+ | <option value="3">III</option> |
||
⚫ | |||
+ | <option value="4">IV</option> |
||
⚫ | |||
+ | </select> |
||
− | <td>隊友</td><td><input type="number" min="1" max="9999" /></td><td><input type="number" min="1" max="9999" /></td><td><input type="number" min="1" max="9999" /></td><td><input type="number" min="1" max="9999" /></td> |
||
− | + | </td> |
|
− | </ |
+ | </tr> |
⚫ | |||
⚫ | |||
+ | <td>隊員1</td> |
||
⚫ | |||
− | <input id=" |
+ | <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> |
||
⚫ | |||
⚫ | |||
+ | <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> |
||
⚫ | |||
⚫ | |||
+ | <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> |
||
⚫ | |||
⚫ | |||
+ | <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> |
||
+ | <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> |
||
⚫ | |||
+ | </table> |
||
+ | </td><td> |
||
⚫ | |||
⚫ | |||
+ | <div id="preview_area"></div> |
||
+ | <input type="button" value="預覽" id="preview" /><input type="submit" /> |
||
+ | </form> |
||
<script> |
<script> |
||
(function NewTeam(){ |
(function NewTeam(){ |
||
第38行: | 第117行: | ||
} |
} |
||
− | function submit() { |
+ | function submit(title, text, func) { |
− | var token = mw.user.tokens.get('editToken'); |
||
$.post( |
$.post( |
||
"http://zh.tos.wikia.com/api.php", |
"http://zh.tos.wikia.com/api.php", |
||
第46行: | 第124行: | ||
appendtext: text, |
appendtext: text, |
||
title: title + '/通關技巧及參考隊伍', |
title: title + '/通關技巧及參考隊伍', |
||
− | token: |
+ | token: mw.user.tokens.get('editToken'), |
− | format: json |
+ | format: '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,'<br />') + '<br />~~' + '~~' + 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() |
||
+ | }, |
||
⚫ | |||
+ | $('#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(); |
||
+ | } |
||
+ | }); |
||
+ | }); |
||
})(); |
})(); |
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="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 $('
}
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>