Widget:BilibiliVideo:修订间差异

H萌娘,万物皆可H的百科全书!
跳到导航 跳到搜索
imported>=海豚=
无编辑摘要
imported>=海豚=
无编辑摘要
第195行: 第195行:
    const converter = new Converter();
    const converter = new Converter();
    if (mw.config.get("skin") === "minerva") {
    if (mw.config.get("skin") === "minerva") {
      $(".bilibili-video-container:not(.bilibili-video-initialized)").each(function () {
      $(".bilibili-video-container:not(.bilibili-video-initialized)").each((_, ele) => {
        const element = $(this),
        const element = $(ele),
          dataset = this.dataset;
          dataset = ele.dataset;
        element.addClass("bilibili-video-initialized");
        element.addClass("bilibili-video-initialized");
        const _id = dataset.id,
        const _id = dataset.id,
第229行: 第229行:
            temp.add(_id);
            temp.add(_id);
          }
          }
          return this.outerHTML = "<i>id错误</i>";
          return ele.outerHTML = "<i>id错误</i>";
        }
        }
        $.ajax({
        $.ajax({
第309行: 第309行:
          const h = container.outerHeight(true);
          const h = container.outerHeight(true);
          let t = 0;
          let t = 0;
          container.children().each(function () {
          container.children().each((_, ele) => {
            t += $(this).outerHeight(true);
            t += $(ele).outerHeight(true);
          });
          });
          target.css("max-height", `calc(100% - ${parseInt(t - h + 2 - (Number.EPSILON || EPSILON))}px)`);
          target.css("max-height", `calc(100% - ${parseInt(t - h + 2 - (Number.EPSILON || EPSILON))}px)`);
        };
        };
      const run = () => {
      const run = () => {
        $(".bilibili-video-container:not(.exec)").addClass("exec").each(function () {
        $(".bilibili-video-container:not(.exec)").addClass("exec").each((_, ele) => {
          const dataset = this.dataset,
          const dataset = ele.dataset,
            _id = dataset.id,
            _id = dataset.id,
            id = _id.replace(/^[ab]v/i, ""),
            id = _id.replace(/^[ab]v/i, ""),
            selfbox = $(this);
            selfbox = $(ele);
          let prefix;
          let prefix;
          let decode = null;
          let decode = null;
第341行: 第341行:
              temp.add(_id);
              temp.add(_id);
            }
            }
            return this.outerHTML = "<i>id错误</i>";
            return ele.outerHTML = "<i>id错误</i>";
          }
          }
          let page = parseInt(+(dataset.page || 1));
          let page = parseInt(+(dataset.page || 1));
第347行: 第347行:
          const pagename = dataset.pagename;
          const pagename = dataset.pagename;
          const title = dataset.title;
          const title = dataset.title;
          const height = cssLengthUnitValidator(dataset.height, "441px", (isValidated) => isValidated || $(this).removeAttr("data-height"));
          const height = cssLengthUnitValidator(dataset.height, "441px", (isValidated) => isValidated || selfbox.removeAttr("data-height"));
          const width = cssLengthUnitValidator(dataset.width, "665px", (isValidated) => isValidated || $(this).removeAttr("data-width"));
          const width = cssLengthUnitValidator(dataset.width, "665px", (isValidated) => isValidated || selfbox.removeAttr("data-width"));
          const maxHeight = cssLengthUnitValidator(dataset.maxHeight, undefined, (isValidated) => isValidated || $(this).removeAttr("data-max-height"));
          const maxHeight = cssLengthUnitValidator(dataset.maxHeight, undefined, (isValidated) => isValidated || selfbox.removeAttr("data-max-height"));
          const maxWidth = cssLengthUnitValidator(dataset.maxWidth, undefined, (isValidated) => isValidated || $(this).removeAttr("data-max-width"));
          const maxWidth = cssLengthUnitValidator(dataset.maxWidth, undefined, (isValidated) => isValidated || selfbox.removeAttr("data-max-width"));
          const subtitle = dataset.subtitle === "true" ? true : false;
          const subtitle = dataset.subtitle === "true" ? true : false;
          const t = parseInt(dataset.t);
          const t = parseInt(dataset.t);
          const tIsInvalid = isNaN(t) || t <= 0;
          const tIsInvalid = isNaN(t) || t <= 0;
          const iframeContainer = $(this).find(".bilibili-iframe-container");
          const iframeContainer = selfbox.find(".bilibili-iframe-container");
          const title_text = $("<a/>").attr("rel", "nofollow noreferrer noopener").addClass("external text").attr({
          const title_text = $("<a/>").attr("rel", "nofollow noreferrer noopener").addClass("external text").attr({
            href: `https://www.bilibili.com/video/${prefix.href}${id}?p=${page}${tIsInvalid ? "" : `&t=${t}`}`,
            href: `https://www.bilibili.com/video/${prefix.href}${id}?p=${page}${tIsInvalid ? "" : `&t=${t}`}`,
            target: "_blank",
            target: "_blank",
          }).prependTo($(this).find(".bilibili-title"));
          }).prependTo(selfbox.find(".bilibili-title"));
          const iframe = $("<iframe/>").attr({
          const iframe = $("<iframe/>").attr({
            frameborder: 0,
            frameborder: 0,
第426行: 第426行:
              },
              },
            });
            });
          }, 137);
          }, 13);
          //toggle
          //toggle
          selfbox.find(".bilibili-toggle").on("click", function () {
          selfbox.find(".bilibili-toggle").on("click", (_, ele) => {
           const self = $(ele);
            selfbox.width(iframeContainer.outerWidth(true));
            selfbox.width(iframeContainer.outerWidth(true));
            selfbox.toggleClass("onshow");
            selfbox.toggleClass("onshow");
            iframeContainer.toggle();
            iframeContainer.toggle();
            if ($(this).text() === "显示视频") {
            if (self.text() === "显示视频") {
              $(this).text("隐藏视频");
              self.text("隐藏视频");
              $(window).resize();
              $(window).resize();
            } else {
            } else {
              $(this).text("显示视频");
              self.text("显示视频");
              selfbox.removeAttr("style");
              selfbox.removeAttr("style");
            }
            }
          });
          });
          selfbox.find(".bilibili-widescreen").on("click", function () {
          selfbox.find(".bilibili-widescreen").on("click", (_, ele) => {
           const self = $(ele);
            if (selfbox.is(":not(.onshow)")) { return; }
            if (selfbox.is(":not(.onshow)")) { return; }
            if (selfbox.is(".widescreen")) {
            if (selfbox.is(".widescreen")) {
              selfbox.removeClass("widescreen");
              selfbox.removeClass("widescreen");
              $(this).text("显示宽屏");
              self.text("显示宽屏");
              recallWH(iframeContainer);
              recallWH(iframeContainer);
              recallWH(iframe);
              recallWH(iframe);
第450行: 第452行:
            } else {
            } else {
              selfbox.addClass("widescreen");
              selfbox.addClass("widescreen");
              $(this).text("退出宽屏");
              self.text("退出宽屏");
              rememberWH(selfbox);
              rememberWH(selfbox);
              selfbox.css("width", selfbox.parent().width() > Math.min(911, global_element.width()) ? "73%" : "100%"); //可以看见按钮的最小宽度 665 的 1/0.73 倍
              selfbox.css("width", selfbox.parent().width() > Math.min(911, global_element.width()) ? "73%" : "100%"); //可以看见按钮的最小宽度 665 的 1/0.73 倍
第464行: 第466行:
        });
        });
      };
      };
      run();
      $(run);
      mw.hook("wikipage.content").fire(run);
      mw.hook("wikipage.content").add(run);
      $(window).on("load", run);
      $(window).on("load", run);
      $(window).on("resize", () => {
      $(window).on("resize", () => {
        $(".bilibili-video-container.onshow.widescreen").each(function () {
        $(".bilibili-video-container.onshow.widescreen").each((_, ele) => {
          const selfbox = $(this);
          const selfbox = $(ele);
          selfbox.css("width", selfbox.parent().width() > Math.min(911, global_element.width()) ? "73%" : "100%");
          selfbox.css("width", selfbox.parent().width() > Math.min(911, global_element.width()) ? "73%" : "100%");
          setTureHeight(selfbox);
          setTureHeight(selfbox);

2020年7月2日 (四) 09:25的版本

名称: Bilibili视频插件
作者: 加大号的猫
修订: Boxsnake
重修订: AnnAngela
H5版再修订:
新H5版又修订:
移动版支持: XYZ指示物
版权协定: MIT
发布日期:

2012年6月29日第一版发布;
2015年2月6日更新;
2016年11月29日更新更多细节;
2017年4月10日更新至H5版(感谢众多dalao的debug_(:зゝ∠)_);
2020年01月27日更新至新版H5播放器。

发布地址: https://zh.moegirl.org.cn/Widget:BilibiliVideo && https://zh.moegirl.org.cn/Template:BilibiliVideo
注意事项: 如有问题,请联系作者。

本Widget不能单独使用,请使用{{BilibiliVideo}}!