|
|
| (未显示同一用户的40个中间版本) |
| 第1行: |
第1行: |
| <includeonly><div id="dollPicContain"></div><script type="text/javascript">(window.RLQ=window.RLQ||[]).push(["jquery",function(){
| | <script> |
| if(location.hash.indexOf("MOD")>-1){var posit=1}else{var posit=0}
| | (function () { |
| var firstload = false; | | var bgList = [ |
| var dollvoice = "<!--{$dollvoice|escape:'html'}-->"
| | { name: "图鉴背景", file: "图鉴背景.jpg" }, |
| var dollname = "[ <!--{$dollname|escape:'html'}--> ]";
| | { name: "默认背景", file: "默认背景.jpg" }, |
| var pic_data = [];
| | { name: "临时作战室", file: "临时作战室.jpg" }, |
| <!--{if ($pic1)}-->pic_data.push({name:"<!--{$pic1name|escape:'html'}-->", line:"<!--{$line1|escape:'html'}-->", pic:"<!--{$pic1|escape:'html'}-->", pic_d:"<!--{$pic1d|escape:'html'}-->", anime:"<!--{$pic1a|escape:'html'}-->", pic_h:"<!--{$pic1h|escape:'html'}-->", pic_d_h:"<!--{$pic1dh|escape:'html'}-->"});<!--{/if}-->
| | { name: "荒街涂鸦", file: "荒街涂鸦.jpg" }, |
| <!--{if ($pic2)}-->pic_data.push({name:"<!--{$pic2name|escape:'html'}-->", line:"<!--{$line2|escape:'html'}-->", pic:"<!--{$pic2|escape:'html'}-->", pic_d:"<!--{$pic2d|escape:'html'}-->", anime:"<!--{$pic2a|escape:'html'}-->", pic_h:"<!--{$pic2h|escape:'html'}-->", pic_d_h:"<!--{$pic2dh|escape:'html'}-->"});<!--{/if}-->
| | { name: "旧日都市", file: "旧日都市.jpg" }, |
| <!--{if ($pic3)}-->pic_data.push({name:"<!--{$pic3name|escape:'html'}-->", line:"<!--{$line3|escape:'html'}-->", pic:"<!--{$pic3|escape:'html'}-->", pic_d:"<!--{$pic3d|escape:'html'}-->", anime:"<!--{$pic3a|escape:'html'}-->", pic_h:"<!--{$pic3h|escape:'html'}-->", pic_d_h:"<!--{$pic3dh|escape:'html'}-->"});<!--{/if}-->
| | { name: "平安夜一角", file: "平安夜一角.jpg" }, |
| <!--{if ($pic4)}-->pic_data.push({name:"<!--{$pic4name|escape:'html'}-->", line:"<!--{$line4|escape:'html'}-->", pic:"<!--{$pic4|escape:'html'}-->", pic_d:"<!--{$pic4d|escape:'html'}-->", anime:"<!--{$pic4a|escape:'html'}-->", pic_h:"<!--{$pic4h|escape:'html'}-->", pic_d_h:"<!--{$pic4dh|escape:'html'}-->"});<!--{/if}-->
| | { name: "平安夜小屋", file: "平安夜小屋.jpg" }, |
| <!--{if ($pic5)}-->pic_data.push({name:"<!--{$pic5name|escape:'html'}-->", line:"<!--{$line5|escape:'html'}-->", pic:"<!--{$pic5|escape:'html'}-->", pic_d:"<!--{$pic5d|escape:'html'}-->", anime:"<!--{$pic5a|escape:'html'}-->", pic_h:"<!--{$pic5h|escape:'html'}-->", pic_d_h:"<!--{$pic5dh|escape:'html'}-->"});<!--{/if}-->
| | { name: "春节酒吧", file: "春节酒吧.jpg" }, |
| <!--{if ($pic6)}-->pic_data.push({name:"<!--{$pic6name|escape:'html'}-->", line:"<!--{$line6|escape:'html'}-->", pic:"<!--{$pic6|escape:'html'}-->", pic_d:"<!--{$pic6d|escape:'html'}-->", anime:"<!--{$pic6a|escape:'html'}-->", pic_h:"<!--{$pic6h|escape:'html'}-->", pic_d_h:"<!--{$pic6dh|escape:'html'}-->"});<!--{/if}-->
| | { name: "教堂", file: "教堂.jpg" }, |
| <!--{if ($pic7)}-->pic_data.push({name:"<!--{$pic7name|escape:'html'}-->", line:"<!--{$line7|escape:'html'}-->", pic:"<!--{$pic7|escape:'html'}-->", pic_d:"<!--{$pic7d|escape:'html'}-->", anime:"<!--{$pic7a|escape:'html'}-->", pic_h:"<!--{$pic7h|escape:'html'}-->", pic_d_h:"<!--{$pic7dh|escape:'html'}-->"});<!--{/if}-->
| | { name: "温馨咖啡厅", file: "温馨咖啡厅.jpg" }, |
| <!--{if ($pic8)}-->pic_data.push({name:"<!--{$pic8name|escape:'html'}-->", line:"<!--{$line8|escape:'html'}-->", pic:"<!--{$pic8|escape:'html'}-->", pic_d:"<!--{$pic8d|escape:'html'}-->", anime:"<!--{$pic8a|escape:'html'}-->", pic_h:"<!--{$pic8h|escape:'html'}-->", pic_d_h:"<!--{$pic8dh|escape:'html'}-->"});<!--{/if}-->
| | { name: "花火之夏", file: "花火之夏.jpg" }, |
| <!--{if ($pic9)}-->pic_data.push({name:"<!--{$pic9name|escape:'html'}-->", line:"<!--{$line9|escape:'html'}-->", pic:"<!--{$pic9|escape:'html'}-->", pic_d:"<!--{$pic9d|escape:'html'}-->", anime:"<!--{$pic9a|escape:'html'}-->", pic_h:"<!--{$pic9h|escape:'html'}-->", pic_d_h:"<!--{$pic9dh|escape:'html'}-->"});<!--{/if}-->
| | { name: "盛夏海滩", file: "盛夏海滩.jpg" }, |
| <!--{if ($pic10)}-->pic_data.push({name:"<!--{$pic10name|escape:'html'}-->", line:"<!--{$line10|escape:'html'}-->", pic:"<!--{$pic10|escape:'html'}-->", pic_d:"<!--{$pic10d|escape:'html'}-->", anime:"<!--{$pic10a|escape:'html'}-->", pic_h:"<!--{$pic10h|escape:'html'}-->", pic_d_h:"<!--{$pic10dh|escape:'html'}-->"});<!--{/if}-->
| | { name: "月圆人长久", file: "月圆人长久.jpg" }, |
| <!--{if ($pic11)}-->pic_data.push({name:"<!--{$pic11name|escape:'html'}-->", line:"<!--{$line11|escape:'html'}-->", pic:"<!--{$pic11|escape:'html'}-->", pic_d:"<!--{$pic11d|escape:'html'}-->", anime:"<!--{$pic11a|escape:'html'}-->", pic_h:"<!--{$pic11h|escape:'html'}-->", pic_d_h:"<!--{$pic11dh|escape:'html'}-->"});<!--{/if}-->
| | { name: "幸存者的万圣节", file: "幸存者的万圣节.jpg" }, |
| <!--{if ($pic12)}-->pic_data.push({name:"<!--{$pic12name|escape:'html'}-->", line:"<!--{$line12|escape:'html'}-->", pic:"<!--{$pic12|escape:'html'}-->", pic_d:"<!--{$pic12d|escape:'html'}-->", anime:"<!--{$pic12a|escape:'html'}-->", pic_h:"<!--{$pic12h|escape:'html'}-->", pic_d_h:"<!--{$pic12dh|escape:'html'}-->"});<!--{/if}-->
| | { name: "冬幕将至", file: "冬幕将至.jpg" }, |
| | { name: "逢魔之刻", file: "逢魔之刻.jpg" }, |
| | { name: "幻梦花海", file: "幻梦花海.jpg" }, |
| | { name: "闲庭雪情", file: "闲庭雪情.jpg" }, |
| | { name: "落暮之城", file: "落暮之城.jpg" }, |
| | { name: "夕晖湖畔", file: "夕晖湖畔.jpg" }, |
| | { name: "星夜之庭", file: "星夜之庭.jpg" }, |
| | { name: "昼光之庭", file: "昼光之庭.jpg" }, |
| | { name: "芙洛拉花径", file: "芙洛拉花径.jpg" }, |
| | { name: "藏身处", file: "藏身处.jpg" }, |
| | { name: "迷幻梦境", file: "迷幻梦境.jpg" }, |
| | { name: "风吟", file: "风吟.jpg" }, |
| | { name: "午后静室", file: "午后静室.jpg" }, |
| | { name: "鹫羽大厅", file: "鹫羽大厅.jpg" }, |
| | { name: "月下庆宴", file: "月下庆宴.jpg" } |
| | ]; |
|
| |
|
| var homepic = [
| | function getImgUrl(filename, fallbackSrc, callback) { |
| | | var api = (window.mw && mw.Api) ? new mw.Api() : null; |
| ];
| | if (api) { |
| ar initial_scale = ($("#dollPicContain").width()< $("#dollPicContain").height()) ? (1.5 * $("#dollPicContain").width() / $("#dollPicContain").height()) : 1.5;
| | api.get({ |
| var initial_x = ($("#dollPicContain").width() - $("#dollPicContain").height() * initial_scale) / 2; | | action: 'query', |
| var initial_y = (initial_scale > 1) ? 0 : ($("#dollPicContain").height() * (1 - initial_scale) / 2);
| | prop: 'imageinfo', |
| const initial_para = {x: initial_x, y: initial_y, scale: initial_scale}
| | titles: 'File:' + filename, |
| var pic_position_before = {x: 0, y: 0};
| | iiprop: 'url' |
| var pic_position_after = {x: 0, y: 0};
| | }).done(function (data) { |
| var pic_position_change = {x: 0, y: 0};
| | var pages = data.query.pages; |
| var pic_move = {x: initial_para.x, y: initial_para.y};
| | for (var id in pages) { |
| var pic_on_dragging = false;
| | if (pages[id].imageinfo) { |
| var pic_scale = initial_para.scale;
| | callback(pages[id].imageinfo[0].url); |
| | return; |
| | } |
| | } |
| | fallback(); |
| | }).fail(fallback); |
| | } else { |
| | fallback(); |
| | } |
|
| |
|
| creat_doll_div();
| | function fallback() { |
| | if (!fallbackSrc) { callback(null); return; } |
|
| |
|
| function stop() {return false;}
| | callback('/wiki/Special:FilePath/' + encodeURIComponent(filename)); |
| document.getElementById("dollPicContain").oncontextmenu = stop;
| | } |
| | |
| | |
| function load_pics(){
| |
| for(i in pic_data){
| |
| var img = new Image();
| |
| $(img).attr({"src": pic_data[i]["pic"]});
| |
| var img_2 = new Image();
| |
| $(img_2).attr({"src": pic_data[i]["pic_d"]});
| |
| var img_3 = new Image();
| |
| $(img_3).attr({"src": pic_data[i]["pic_h"]}); | |
| var img_4 = new Image();
| |
| $(img_4).attr({"src": pic_data[i]["pic_d_h"]});
| |
| } | | } |
| }
| |
|
| |
|
| function creat_doll_div(){ | | function switchImage(container, filename, onDone) { |
| let html_text = `
| | container.classList.add('loading'); |
| <div id="dollPicDiv"> | | var mainWrap = container.querySelector('.gf-main-img'); |
| <div id="dollPicBg"><\/div>
| | var oldImg = container.querySelector('img'); |
| <img id="dollPicImg" src=${pic_data[posit]["pic"]} \/>
| | var fallback = oldImg ? oldImg.src : null; |
| <div id="dollControlBtn">
| |
| <div id="dollDragBtn" class="dollPicBtn" state="off"><\/div>
| |
| <div id="dollPicPositionRe" class="dollPicBtn"><\/div>
| |
| <div id="dollPicDownload" class="dollPicBtn">
| |
| <a target="_blank" href=${pic_data[0]["pic"]} \/>
| |
| <\/div>
| |
| <div id="dollPicExpand" class="dollPicBtn" state="off"><\/div>
| |
| <\/div>
| |
| <div id="dollLineDiv"><div id="dollLineName">${dollname}<\/div>${(dollvoice.length > 5) ? `<div id="dollLineVoice">[ ▶ ]<\/div>` : ``}<div id="dollLineWord">${pic_data[0]["line"]}<\/div>
| |
| <\/div>
| |
| <\/div>`;
| |
|
| |
|
| $("#dollPicContain").append(html_text);
| | getImgUrl(filename, fallback, function (url) { |
| pic_position_reset(0);
| | if (!url) { container.classList.remove('loading'); if (onDone) onDone(); return; } |
| // switch skins need this button
| |
| let skin_btn_text = `<div id="dollSkinBtnDiv">`;
| |
|
| |
| for(i in pic_data){
| |
| if(i == posit) skin_btn_text += `<div class="dollSkinBtn skinChosen" index="${i}" >${pic_data[i]["name"]}`;
| |
| else skin_btn_text += `<div class="dollSkinBtn" index="${i}" >${pic_data[i]["name"]}`;
| |
|
| |
|
| if(Number(pic_data[i]["anime"]) == 0) skin_btn_text += `<\/div>`;
| | var preload = new Image(); |
| else if(Number(pic_data[i]["anime"]) == 1) skin_btn_text += `<div class="dollSkinAnimeL"><\/div><\/div>`;
| | preload.onload = function () { |
| else if(Number(pic_data[i]["anime"]) == 2) skin_btn_text += `<div class="dollSkinAnimeA"><\/div><\/div>`;
| | if (mainWrap) { |
| | mainWrap.innerHTML = ''; |
| | var img = document.createElement('img'); |
| | img.src = url; |
| | mainWrap.appendChild(img); |
| | } else { |
| | mainWrap = document.createElement('div'); |
| | mainWrap.className = 'gf-main-img'; |
| | var img = document.createElement('img'); |
| | img.src = url; |
| | mainWrap.appendChild(img); |
| | container.insertBefore(mainWrap, container.firstChild); |
| | } |
| | container.classList.remove('loading'); |
| | if (onDone) onDone(); |
| | }; |
| | preload.onerror = function () { |
| | container.classList.remove('loading'); |
| | if (onDone) onDone(); |
| | }; |
| | preload.src = url; |
| | }); |
| } | | } |
|
| |
|
| skin_btn_text += `<div id="dollSkinBtnSpace"><\/div>`; | | function initBox(box) { |
| skin_btn_text+=`<div id="dollSkinSwitchBtnDestroy" class="dollSkinSwitchBtn" dict="Normal-Destroy" state="Normal">
| | if (box.dataset.ready) return; |
| <div class="dollSkinSwitchBtnSlide"><\/div>
| | box.dataset.ready = '1'; |
| <div id="dollSkinSwitchNormal" class="dollSkinSwitchBtnL">正常<\/div>
| |
| <div id="dollSkinSwitchDestroy" class="dollSkinSwitchBtnR">重创<\/div>
| |
| <\/div>`;
| |
|
| |
|
| if(pic_data[0]["pic_h"]){
| | var leftPanel = box.querySelector('.gf-left-panel'); |
| skin_btn_text+=`<div id="dollSkinSwitchBtnHexie" class="dollSkinSwitchBtn" dict="Formal-Hexie" state="Formal"> | | var container = box.querySelector('.gf-image-container'); |
| <div class="dollSkinSwitchBtnSlide"><\/div>
| | var overlay = box.querySelector('.gf-switcher-overlay'); |
| <div id="dollSkinSwitchFormal" class="dollSkinSwitchBtnL">正式<\/div>
| | var toggle = box.querySelector('.gf-switcher-toggle'); |
| <div id="dollSkinSwitchHexie" class="dollSkinSwitchBtnR">和谐<\/div>
| | var viewBtn = box.querySelector('.gf-view-original'); |
| <\/div>`;
| | var groupBtns = box.querySelectorAll('.gf-group-btn'); |
| skin_btn_text += `<\/div>`; | | var variantLists= box.querySelectorAll('.gf-variant-list'); |
| } else skin_btn_text += `<\/div>`; | |
|
| |
| $("#dollPicDiv").append(skin_btn_text);
| |
| skin_switch_btn_event("#dollSkinSwitchBtnHexie");
| |
| skin_btn_size();
| |
|
| |
|
| // creat the select to offer changing home background options
| | var selector = document.createElement('select'); |
| let select_text = `<select id="dollHomePic" style="display:none;"><\/select><div id="dollHomeDiv" class="dollPicBtn" state="off"><\/div>`;
| | selector.className = 'gf-bg-selector'; |
| $("#dollPicDiv").append(select_text);
| | bgList.forEach(function (bg) { |
| for(i in homepic){
| | var opt = document.createElement('option'); |
| let option_text = `<option value=${homepic[i].pic}>${homepic[i].name}<\/option>`; | | opt.value = '/wiki/Special:FilePath/' + encodeURIComponent(bg.file); |
| $("#dollHomePic").append(option_text); | | opt.innerText = bg.name; |
| }
| | selector.appendChild(opt); |
| | }); |
| | container.appendChild(selector); |
| | selector.onclick = function (e) { e.stopPropagation(); }; |
| | selector.onchange = function () { |
| | leftPanel.style.backgroundImage = "url('" + this.value + "')"; |
| | }; |
|
| |
|
| $("#dollHomePic").change(function(){ $("#dollPicBg").css({"background-image": "url(" + this.value + ")"}); });
| | if (toggle) { |
| } | | toggle.onclick = function () { overlay.classList.toggle('collapsed'); }; |
| | } |
|
| |
|
| // if there is lots of skin, make it smaller to contain them all in the div.
| | function getActiveVariant() { |
| function skin_btn_size(){ | | return box.querySelector('.gf-switch-btn.active'); |
| if(pic_data.length >= 8 && $("#dollPicExpand").attr("state") == "off"){
| | } |
| let long = (16 - pic_data.length)< 2 ? 2 : 16 - pic_data.length;
| |
| let margin_long = (30 - ((pic_data.length - 6) > 10 ? 10 : (pic_data.length - 6)) * 3);
| |
| $(".dollSkinBtn").css({"padding": long + "px 2px", "margin": long + "px 0px"});
| |
| $("#dollSkinSwitchBtn").css({"margin-top": margin_long + "px"}); | |
| }
| |
| } | |
|
| |
|
| // the skin btn are so tight and ugly. undo.
| | groupBtns.forEach(function (gbtn) { |
| function un_skin_btn_size(){ | | gbtn.onclick = function () { |
| if(pic_data.length<= 13){
| | var gid = gbtn.dataset.group; |
| $(".dollSkinBtn").css({"padding": "", "margin": ""});
| |
| $("#dollSkinSwitchBtn").css({"margin-top": ""});
| |
| }
| |
| }
| |
|
| |
|
| // show dollHomePic select show or hide @click
| | groupBtns.forEach(function (b) { b.classList.remove('active'); }); |
| $("#dollHomeDiv").click(function(){
| | gbtn.classList.add('active'); |
| if($(this).attr("state") == "off"){
| |
| $(this).attr("state", "on");
| |
| $(this).css({"background-image": "url(/images/9/97/Home_hide.png)"});
| |
| $(this).prev("#dollHomePic").fadeIn(50);
| |
| $(this).prev("#dollHomePic").animate({"width": "150px", "right": "50px"}, 200);
| |
| } else {
| |
| $(this).attr("state", "off");
| |
| $(this).css({"background-image": "url(/images/0/03/Home_show.png)"});
| |
| $(this).prev("#dollHomePic").fadeOut(150);
| |
| $(this).prev("#dollHomePic").animate({"width": "40px", "right": "10px"}, 200);
| |
| }
| |
| });
| |
|
| |
|
| // play voice
| | variantLists.forEach(function (vl) { |
| if(dollvoice.length > 5){ | | if (vl.dataset.group === gid) { |
| var voice_jp = new Audio;
| | vl.classList.remove('collapsed'); |
| voice_jp.setAttribute("src", dollvoice);
| | } else { |
| voice_jp.setAttribute("controls", "controls");
| | vl.classList.add('collapsed'); |
| voice_jp.setAttribute("preload", "preload");
| | } |
|
| | }); |
| $("#dollLineVoice").click(function(){
| |
| voice_jp.currentTime = 0;
| |
| voice_jp.play();
| |
| });
| |
| }
| |
|
| |
|
| // skin chose button @click
| | var targetList = box.querySelector('.gf-variant-list[data-group="' + gid + '"]'); |
| $(".dollSkinBtn").click(function(){
| | if (!targetList) return; |
| if(!firstload) load_pics();
| | var firstBtn = targetList.querySelector('.gf-switch-btn'); |
| $(".dollSkinBtn").removeClass("skinChosen");
| | if (!firstBtn) return; |
| $(this).addClass("skinChosen");
| |
|
| |
| if($(this).text().indexOf("默认立绘") != -1 || $(this).text().indexOf("心智升级") != -1) $("#dollLineVoice").show();
| |
| else $("#dollLineVoice").hide();
| |
|
| |
|
| let index = Number($(this).attr("index"));
| | box.querySelectorAll('.gf-switch-btn').forEach(function (b) { b.classList.remove('active'); }); |
|
| | firstBtn.classList.add('active'); |
| $("#dollLineWord").stop().fadeOut(90);
| |
| setTimeout(() => { $("#dollLineWord").html(pic_data[index]["line"]); }, 95);
| |
| setTimeout(() => { $("#dollLineWord").stop().fadeIn(100); }, 100);
| |
|
| |
| $("#dollSkinSwitchBtnHexie").remove();
| |
| if(pic_data[index]["pic_h"]){
| |
| skin_btn_text =`<div id="dollSkinSwitchBtnHexie" class="dollSkinSwitchBtn" dict="Formal-Hexie" state="Formal">
| |
| <div class="dollSkinSwitchBtnSlide"><\/div>
| |
| <div id="dollSkinSwitchFormal" class="dollSkinSwitchBtnL">正式<\/div>
| |
| <div id="dollSkinSwitchHexie" class="dollSkinSwitchBtnR">和谐<\/div>
| |
| <\/div>`;
| |
| $("#dollSkinBtnDiv").append(skin_btn_text);
| |
| skin_switch_btn_event("#dollSkinSwitchBtnHexie");
| |
| skin_btn_size();
| |
| }
| |
|
| |
|
| doll_img_switch();
| | switchImage(container, firstBtn.dataset.filename); |
| });
| | }; |
| | | }); |
| // hexie/destroy skin chose button @click
| |
| function skin_switch_btn_event(target){
| |
| if(!target && !firstload) load_pics();
| |
| if(!target) target = ".dollSkinSwitchBtn";
| |
| $(target).click(function(){
| |
| let status = $(this).attr("dict").split("-");
| |
| | |
| if($(this).attr("state") == status[0]){
| |
| $(this).attr("state", status[1]);
| |
| $(this).children(".dollSkinSwitchBtnSlide").stop().animate({"right": "0px", "left": "50%"}, 300);
| |
| setTimeout(() => {
| |
| $(this).children(".dollSkinSwitchBtnL").css({"color": "#eaeaea"});
| |
| $(this).children(".dollSkinSwitchBtnR").css({"color": "#292929"});
| |
| }, 100);
| |
| } else {
| |
| $(this).attr("state", status[0]);
| |
| $(this).children(".dollSkinSwitchBtnSlide").stop().animate({"left": "0px", "right": "50%"}, 300);
| |
| setTimeout(() => {
| |
| $(this).children(".dollSkinSwitchBtnL").css({"color": "#292929"}, 300); | |
| $(this).children(".dollSkinSwitchBtnR").css({"color": "#eaeaea"}, 300);
| |
| }, 100); | |
| } | |
|
| |
| doll_img_switch();
| |
| });
| |
| }
| |
| skin_switch_btn_event("#dollSkinSwitchBtnDestroy");
| |
| | |
| // doll img switch function
| |
| function doll_img_switch(){
| |
| let index = Number($($(".skinChosen")[0]).attr("index"));
| |
| | |
| let hex_state = "Formal";
| |
| if($("#dollSkinSwitchBtnHexie")) hex_state = $("#dollSkinSwitchBtnHexie").attr("state");
| |
| let des_state = $("#dollSkinSwitchBtnDestroy").attr("state");
| |
| | |
| let target = {"pic": pic_data[index]["pic"], "pic_d": pic_data[index]["pic_d"]};
| |
| if(hex_state == "Hexie") target = {"pic": pic_data[index]["pic_h"], "pic_d": pic_data[index]["pic_d_h"]};
| |
|
| |
| let target_src = target["pic"];
| |
| if(des_state == "Destroy") target_src = target["pic_d"];
| |
|
| |
|
| $("#dollPicDownload").children("a").attr("href", target_src);
| | box.querySelectorAll('.gf-switch-btn').forEach(function (vbtn) { |
| $("#dollPicImg").stop().fadeOut(190);
| | vbtn.onclick = function (e) { |
| setTimeout(() => { $("#dollPicImg").attr("src", ""); $("#dollPicImg").attr("src", target_src); }, 195);
| | e.stopPropagation(); |
| setTimeout(() => { $("#dollPicImg").stop().fadeIn(200); }, 200);
| | if (vbtn.classList.contains('active')) return; |
| }
| |
|
| |
|
| $("#dollPicImg").click(function(){ $("#dollDragBtn").click();});
| | box.querySelectorAll('.gf-switch-btn').forEach(function (b) { b.classList.remove('active'); }); |
| // drag and scale mode switch button @click
| | vbtn.classList.add('active'); |
| $("#dollDragBtn").click(function(){
| |
| if($(this).attr("state") == "off"){
| |
| $(this).attr("state", "on");
| |
| $(this).css("background-image", "url(/images/a/ad/IconDollDigoutUn.png)");
| |
| $("#dollPicImg").css("cursor", "crosshair");
| |
| $("#dollPicBg").css("cursor", "crosshair");
| |
| $("#dollPicImg").unbind("click");
| |
| // animation for hiding buttons
| |
| $("#dollSkinBtnDiv").stop().animate({"left": "-200px"}, 500);
| |
| $("#dollLineDiv").stop().animate({"bottom": "-200px"}, 500);
| |
| if($("#dollHomeDiv").attr("state") == "on") $("#dollHomeDiv").click();
| |
| | |
| $("#dollPicDiv").mousedown(function(event){
| |
| pic_on_dragging = true;
| |
| pic_position_before.x = event.clientX;
| |
| pic_position_before.y = event.clientY;
| |
|
| |
| pic_position_change.x = 0
| |
| pic_position_change.y = 0
| |
| });
| |
| $("#dollPicDiv").mousemove(function(event){
| |
| if(pic_on_dragging){
| |
| pic_position_after.x = event.clientX;
| |
| pic_position_after.y = event.clientY;
| |
| pic_move.x += pic_position_after.x - pic_position_before.x;
| |
| pic_move.y += pic_position_after.y - pic_position_before.y;
| |
| pic_position_change.x += pic_position_after.x - pic_position_before.x;
| |
| pic_position_change.y += pic_position_after.y - pic_position_before.y;
| |
| pic_position_before.x = pic_position_after.x;
| |
| pic_position_before.y = pic_position_after.y;
| |
|
| |
|
| $("#dollPicImg").css("top", String(pic_move.y) + "px"); | | switchImage(container, vbtn.dataset.filename); |
| $("#dollPicImg").css("left", String(pic_move.x) + "px");
| | }; |
| } | |
| });
| |
| $("#dollPicDiv").mouseup(function(){
| |
| pic_on_dragging = false;
| |
| }); | | }); |
|
| |
|
| // this for click and trigger the dragbtn | | if (viewBtn) { |
| $("#dollPicImg").click(function(){
| | viewBtn.onclick = function (e) { |
| if(pic_position_change.x == 0 && pic_position_change.y == 0 && $("#dollDragBtn").attr("state") == "on") $("#dollDragBtn").click(); | | e.stopPropagation(); |
| pic_position_change.x = 0
| | var active = getActiveVariant(); |
| pic_position_change.y = 0
| | if (!active) return; |
| });
| | var filename = active.dataset.filename; |
|
| | if (window.mw) { |
| if(document.querySelector("#dollPicDiv").addEventListener){
| | window.open( |
| document.querySelector("#dollPicDiv").addEventListener('wheel', doll_pic_scale);
| | mw.config.get('wgArticlePath').replace('$1', 'File:' + filename), |
| | '_blank' |
| | ); |
| | } |
| | }; |
| } | | } |
| } else {
| |
| $(this).attr("state", "off");
| |
| $(this).css("background-image", "url(/images/7/7d/IconDollDigout.png)");
| |
| if($("#dollPicExpand").attr("state") == "off") $("body").css("overflow", "auto");
| |
| $("#dollPicImg").css("cursor", "auto");
| |
| $("#dollPicBg").css("cursor", "auto");
| |
|
| |
| // animation for hiding buttons
| |
| if(window.innerWidth<= 600) $("#dollSkinBtnDiv").stop().animate({"left": "2px"}, 500);
| |
| else $("#dollSkinBtnDiv").stop().animate({"left": "15px"}, 500);
| |
| $("#dollHomePic").stop().animate({"right": "2px"}, 500);
| |
| $("#dollLineDiv").stop().animate({"bottom": "20px"}, 500);
| |
|
| |
| document.querySelector("#dollPicDiv").removeEventListener("wheel", doll_pic_scale);
| |
| $("#dollPicDiv").unbind("mousedown").unbind("mousemove").unbind("mouseup");
| |
| setTimeout(function(){
| |
| $("#dollPicImg").click(function(){ $("#dollDragBtn").click();});
| |
| }, 100);
| |
| } | | } |
| });
| |
|
| |
|
| // for a easy and feasible way to remove eventListener @mousewheel
| | function injectStyles() { |
| function doll_pic_scale(event){ | | var style = document.createElement('style'); |
| event.preventDefault();
| | style.textContent = [ |
| var box = document.querySelector("#dollPicImg").getBoundingClientRect();
| | '.gf-switcher-list::-webkit-scrollbar { display: none; }', |
| event.wheelDelta = event.wheelDelta ? event.wheelDelta : (event.deltalY * (-40));
| | '.gf-switcher-list { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; }' |
| if (event.wheelDelta > 0) {
| | ].join('\n'); |
| pic_scale += 0.1;
| | document.head.appendChild(style); |
| if(pic_scale >= 10) pic_scale = 10;
| |
| parament = pic_scale / (pic_scale - 0.1) - 1;
| |
| pic_move["x"] = pic_move["x"] - (event.clientX - box.left) * parament;
| |
| pic_move["y"] = pic_move["y"] - (event.clientY - box.top) * parament;
| |
| } else {
| |
| pic_scale -= 0.1; | |
| if(pic_scale<= 0.2) pic_scale = 0.2;
| |
| parament = pic_scale / (pic_scale + 0.1) - 1;
| |
| pic_move["x"] = pic_move["x"] - (event.clientX - box.left) * parament; | |
| pic_move["y"] = pic_move["y"] - (event.clientY - box.top) * parament;
| |
| } | | } |
|
| |
|
| $("#dollPicImg").css("top", String(pic_move["y"]) + "px"); | | function initAll() { |
| $("#dollPicImg").css("left", String(pic_move["x"]) + "px");
| | injectStyles(); |
| $("#dollPicImg").css("height", String(100 * pic_scale) + "%");
| | document.querySelectorAll('.gf-infobox-new').forEach(initBox); |
| }
| |
| | |
| // reset the position of pic, and paramas reinitial (different between expanded or not) @click
| |
| $("#dollPicPositionRe").click(function(){pic_position_reset(100)});
| |
| | |
| | |
| // to move the pic to the right position, creat a function
| |
| function pic_position_reset(time){
| |
| if($("#dollPicExpand").attr("state") == "off"){
| |
| let target_width = ($("#dollPicContain").width()< 200) ? window.innerWidth - 20 : $("#dollPicContain").width(); | |
| let initial_scale = (target_width< $("#dollPicContain").height()) ? (1.5 *target_width / $("#dollPicContain").height()) : 1.5; | |
| let initial_x = (target_width - $("#dollPicContain").height() * initial_scale) / 2;
| |
| let initial_y = (initial_scale > 1) ? 0 : ($("#dollPicContain").height() * (1 - initial_scale) / 2);
| |
| pic_move = {x: initial_x, y: initial_y};
| |
| pic_scale = initial_scale;
| |
| } else {
| |
| pic_scale = (window.innerWidth< window.innerHeight) ? (window.innerWidth / window.innerHeight) : 1;
| |
| pic_move.x = (pic_scale< 1) ? 0 : (window.innerWidth - window.innerHeight) / 2;
| |
| pic_move.y = (pic_scale == 1) ? 0 : (window.innerHeight - window.innerWidth) / 2;
| |
| } | | } |
| pic_position_before = {x: 0, y: 0};
| |
| pic_position_after = {x: 0, y: 0};
| |
|
| |
| $("#dollPicImg").stop().animate({
| |
| "top": String(pic_move["y"]) + "px",
| |
| "left": String(pic_move["x"]) + "px",
| |
| "height": String(100 * pic_scale) + "%"
| |
| }, time);
| |
| }
| |
|
| |
|
| // to expand the dollpicdiv or unexpand, and other measures @click
| | setTimeout(initAll, 300); |
| $("#dollPicExpand").click(function(){
| | })(); |
| if($(this).attr("state") == "off"){
| | </script> |
| $(this).attr({"state": "on"});
| |
| $(this).css("background-image", "url(/images/e/e1/IconDollExpandUn.png)");
| |
| expand_function();
| |
| } else { | |
| $(this).attr("state", "off");
| |
| $(this).css("background-image", "url(/images/f/f6/IconDollExpand.png)");
| |
| $('#content').css('grid-template-areas', '');
| |
| $('.mw-indicators.mw-body-content').css('display', '');
| |
| | |
| $("#dollPicDiv").css({"position": "relative", "border": "", "z-index":""});
| |
| $("#dollPicDiv").stop().animate({"height": $("#dollPicContain").height() + "px", "width": $("#dollPicContain").width() + "px"}, 450);
| |
| | |
| $("#dollPicPositionRe").click();
| |
| $("#dollPicImg").stop().animate({
| |
| "left": initial_para.x + "px",
| |
| "top": initial_para.y + "px",
| |
| "height": String(100 * initial_para.scale) + "%"}, 450);
| |
| | |
| setTimeout(function(){
| |
| $("#mw-navigation").fadeIn(200)
| |
| $(".comment-replybox").fadeIn(200)
| |
| $("body").css({"overflow": "auto"});
| |
| $(".backToTop").css({"right": ""});
| |
| }, 400);
| |
| | |
| $("#dollPicPositionRe").click();
| |
| setTimeout(() => { skin_btn_size();}, 450);
| |
| }
| |
| });
| |
| | |
| function expand_function(){
| |
| // some gfwiki'ui is really disgusting, although it's joking, but i need to hide them
| |
| $("#mw-navigation").hide();
| |
| $(".comment-replybox").hide();
| |
| $("body").css({"overflow": "hidden"});
| |
| $(".backToTop").css({"right": "-500px"});
| |
| // 隐藏#content的其他子元素以兼容固定H1和TOC的新布局
| |
| $('#content').css('grid-template-areas', '"bc"');
| |
| $('.mw-indicators.mw-body-content').css('display', 'none');
| |
| | |
| // main commands to control the div and pic moving
| |
| $("#dollPicDiv").css({"position": "fixed", "left": "0px", "top": "0px", "border": "none", "z-index":"100"});
| |
| $("#dollPicDiv").stop().animate({"width": window.innerWidth + "px", "height": window.innerHeight + "px"}, 600);
| |
| | |
| // although it's not very good, but i made it anyway
| |
| var scale = (window.innerWidth< window.innerHeight) ? (window.innerWidth / window.innerHeight) : 1;
| |
| var move_x = (scale< 1) ? 0 : (window.innerWidth - window.innerHeight) / 2;
| |
| var move_y = (scale== 1) ? 0 : (window.innerHeight - window.innerWidth) / 2;
| |
| $("#dollPicPositionRe").click();
| |
| $("#dollPicImg").stop().animate({ "left": move_x + "px", "top": move_y + "px", "height": String(100 * scale) + "%"}, 600);
| |
| | |
| setTimeout(() => { un_skin_btn_size();}, 600);
| |
| }
| |
| | |
| // if the size of window changed , trigger this
| |
| $(window).resize(function() {
| |
| if($("#dollPicExpand").attr("state") == "on"){
| |
| expand_function();
| |
| }
| |
| });
| |
| }])</script></includeonly><noinclude>{{#widget:DollPage/Pic}}</noinclude>
| |
<script>
(function () {
var bgList = [
{ name: "图鉴背景", file: "图鉴背景.jpg" },
{ name: "默认背景", file: "默认背景.jpg" },
{ name: "临时作战室", file: "临时作战室.jpg" },
{ name: "荒街涂鸦", file: "荒街涂鸦.jpg" },
{ name: "旧日都市", file: "旧日都市.jpg" },
{ name: "平安夜一角", file: "平安夜一角.jpg" },
{ name: "平安夜小屋", file: "平安夜小屋.jpg" },
{ name: "春节酒吧", file: "春节酒吧.jpg" },
{ name: "教堂", file: "教堂.jpg" },
{ name: "温馨咖啡厅", file: "温馨咖啡厅.jpg" },
{ name: "花火之夏", file: "花火之夏.jpg" },
{ name: "盛夏海滩", file: "盛夏海滩.jpg" },
{ name: "月圆人长久", file: "月圆人长久.jpg" },
{ name: "幸存者的万圣节", file: "幸存者的万圣节.jpg" },
{ name: "冬幕将至", file: "冬幕将至.jpg" },
{ name: "逢魔之刻", file: "逢魔之刻.jpg" },
{ name: "幻梦花海", file: "幻梦花海.jpg" },
{ name: "闲庭雪情", file: "闲庭雪情.jpg" },
{ name: "落暮之城", file: "落暮之城.jpg" },
{ name: "夕晖湖畔", file: "夕晖湖畔.jpg" },
{ name: "星夜之庭", file: "星夜之庭.jpg" },
{ name: "昼光之庭", file: "昼光之庭.jpg" },
{ name: "芙洛拉花径", file: "芙洛拉花径.jpg" },
{ name: "藏身处", file: "藏身处.jpg" },
{ name: "迷幻梦境", file: "迷幻梦境.jpg" },
{ name: "风吟", file: "风吟.jpg" },
{ name: "午后静室", file: "午后静室.jpg" },
{ name: "鹫羽大厅", file: "鹫羽大厅.jpg" },
{ name: "月下庆宴", file: "月下庆宴.jpg" }
];
function getImgUrl(filename, fallbackSrc, callback) {
var api = (window.mw && mw.Api) ? new mw.Api() : null;
if (api) {
api.get({
action: 'query',
prop: 'imageinfo',
titles: 'File:' + filename,
iiprop: 'url'
}).done(function (data) {
var pages = data.query.pages;
for (var id in pages) {
if (pages[id].imageinfo) {
callback(pages[id].imageinfo[0].url);
return;
}
}
fallback();
}).fail(fallback);
} else {
fallback();
}
function fallback() {
if (!fallbackSrc) { callback(null); return; }
callback('/wiki/Special:FilePath/' + encodeURIComponent(filename));
}
}
function switchImage(container, filename, onDone) {
container.classList.add('loading');
var mainWrap = container.querySelector('.gf-main-img');
var oldImg = container.querySelector('img');
var fallback = oldImg ? oldImg.src : null;
getImgUrl(filename, fallback, function (url) {
if (!url) { container.classList.remove('loading'); if (onDone) onDone(); return; }
var preload = new Image();
preload.onload = function () {
if (mainWrap) {
mainWrap.innerHTML = ;
var img = document.createElement('img');
img.src = url;
mainWrap.appendChild(img);
} else {
mainWrap = document.createElement('div');
mainWrap.className = 'gf-main-img';
var img = document.createElement('img');
img.src = url;
mainWrap.appendChild(img);
container.insertBefore(mainWrap, container.firstChild);
}
container.classList.remove('loading');
if (onDone) onDone();
};
preload.onerror = function () {
container.classList.remove('loading');
if (onDone) onDone();
};
preload.src = url;
});
}
function initBox(box) {
if (box.dataset.ready) return;
box.dataset.ready = '1';
var leftPanel = box.querySelector('.gf-left-panel');
var container = box.querySelector('.gf-image-container');
var overlay = box.querySelector('.gf-switcher-overlay');
var toggle = box.querySelector('.gf-switcher-toggle');
var viewBtn = box.querySelector('.gf-view-original');
var groupBtns = box.querySelectorAll('.gf-group-btn');
var variantLists= box.querySelectorAll('.gf-variant-list');
var selector = document.createElement('select');
selector.className = 'gf-bg-selector';
bgList.forEach(function (bg) {
var opt = document.createElement('option');
opt.value = '/wiki/Special:FilePath/' + encodeURIComponent(bg.file);
opt.innerText = bg.name;
selector.appendChild(opt);
});
container.appendChild(selector);
selector.onclick = function (e) { e.stopPropagation(); };
selector.onchange = function () {
leftPanel.style.backgroundImage = "url('" + this.value + "')";
};
if (toggle) {
toggle.onclick = function () { overlay.classList.toggle('collapsed'); };
}
function getActiveVariant() {
return box.querySelector('.gf-switch-btn.active');
}
groupBtns.forEach(function (gbtn) {
gbtn.onclick = function () {
var gid = gbtn.dataset.group;
groupBtns.forEach(function (b) { b.classList.remove('active'); });
gbtn.classList.add('active');
variantLists.forEach(function (vl) {
if (vl.dataset.group === gid) {
vl.classList.remove('collapsed');
} else {
vl.classList.add('collapsed');
}
});
var targetList = box.querySelector('.gf-variant-list[data-group="' + gid + '"]');
if (!targetList) return;
var firstBtn = targetList.querySelector('.gf-switch-btn');
if (!firstBtn) return;
box.querySelectorAll('.gf-switch-btn').forEach(function (b) { b.classList.remove('active'); });
firstBtn.classList.add('active');
switchImage(container, firstBtn.dataset.filename);
};
});
box.querySelectorAll('.gf-switch-btn').forEach(function (vbtn) {
vbtn.onclick = function (e) {
e.stopPropagation();
if (vbtn.classList.contains('active')) return;
box.querySelectorAll('.gf-switch-btn').forEach(function (b) { b.classList.remove('active'); });
vbtn.classList.add('active');
switchImage(container, vbtn.dataset.filename);
};
});
if (viewBtn) {
viewBtn.onclick = function (e) {
e.stopPropagation();
var active = getActiveVariant();
if (!active) return;
var filename = active.dataset.filename;
if (window.mw) {
window.open(
mw.config.get('wgArticlePath').replace('$1', 'File:' + filename),
'_blank'
);
}
};
}
}
function injectStyles() {
var style = document.createElement('style');
style.textContent = [
'.gf-switcher-list::-webkit-scrollbar { display: none; }',
'.gf-switcher-list { scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch; }'
].join('\n');
document.head.appendChild(style);
}
function initAll() {
injectStyles();
document.querySelectorAll('.gf-infobox-new').forEach(initBox);
}
setTimeout(initAll, 300);
})();
</script>