window.onload = function () {
  var A = navigator.userAgent;
  if (A.indexOf("Android") > -1 || A.indexOf("Linux") > -1) {
  } else {
    if (A.indexOf("iPhone") > -1) {
      $(window)
        .on("scroll.elasticity", function (B) {
          B.preventDefault();
        })
        .on("touchmove.elasticity", function (B) {
          B.preventDefault();
        });
    } else {
      if (A.indexOf("Windows Phone") > -1) {
      }
    }
  }
  initData();
};

function initData() {
  var D = 1;
  var B = 95;
  var C = 1;
  loading_img_url = new Array();
  // for (var A = 0; A <= B; A++) {
  //     loading_img_url.push("./image/00" + (A < 10 ? "0" + A : A) + ".jpg")
  // }
  const BASE_URL = "https://huijie-oss.oss-cn-shenzhen.aliyuncs.com/2023712";
  const target = document.querySelector(".page-cover-bottom");

  for (let i = 0; i <= 4; i++) {
    let imagePath = BASE_URL + "/" + i + ".jpg";
    loading_img_url.push(imagePath);
  }
  loading(D, B, C);
}
var date_start;
var date_end;
date_start = getNowFormatDate();
var loading_img_url = [];

function loading(G, B, E) {
  var D = 0;
  var A = loading_img_url.length;
  var F = new Image();
  F.src = loading_img_url[E];
  var C = loading_img_url[E];
  F.onerror = function () {
    D += (1 / A) * 100;
  };
  F.onload = function () {
    D += (1 / A) * 100;
    $(".number").html(parseInt(D) + "%");
    if (Math.round(D)) {
      date_end = getNowFormatDate();
      var I = date_end - date_start;
      $(function J() {
        $(".shade").hide();
        var K = "";
        K +=
          ' <div id="first" style="background:url(' +
          C +
          ') center top no-repeat;background-size:100%;position:relative;"></div>';
        $(".flipbook").append(K);
        var L = $(".graph").width();
        $(".flipbook-viewport").show();
      });

      function H() {
        var L = $(window).width();
        var K = $(window).height();
        $(".flipboox").width(L).height(K);
        $(window).resize(function () {
          L = $(window).width();
          K = $(window).height();
          $(".flipboox").width(L).height(K);
        });
        $(".flipbook").turn({
          width: L,
          height: K,
          elevation: 50,
          pages: B,
          display: "single",
          gradients: true,
          autoCenter: true,
          when: {
            turning: function (M, O, N) {
              if (O == 1) {
                $(".btnImg").css("display", "none");
                $(".mark").css("display", "block");
              } else {
                $(".btnImg").css("display", "block");
                $(".mark").css("display", "none");
              }
              if (O == A) {
                $(".nextPage").css("display", "none");
              } else {
                $(".nextPage").css("display", "block");
              }
            },
            turned: function (M, P, O) {
              var N = $(".flipbook").turn("pages");
              if (P == 1) {
                $(".return").css("display", "none");
                $(".btnImg").css("display", "none");
              } else {
                $(".return").css("display", "block");
                $(".btnImg").css("display", "block");
              }
              if (P == 2) {
                $(".catalog").css("display", "block");
              } else {
                $(".catalog").css("display", "none");
              }
            },
            missing: function (N, O) {
              if (O.length > loading_img_url.length - 1) {
                return;
              }
              for (var M = 0; M < O.length; M++) {
                addPage(O[M], $(this));
              }
            },
          },
        });
      }
      yepnope({
        test: Modernizr.csstransforms,
        yep: ["js/turn.js"],
        complete: H,
      });
    }
  };
}

function getNowFormatDate() {
  var F = new Date();
  var D = "";
  var A = "";
  var C = F.getMonth() + 1;
  var E = F.getDate();
  if (C >= 1 && C <= 9) {
    C = "0" + C;
  }
  if (E >= 0 && E <= 9) {
    E = "0" + E;
  }
  var B =
    F.getFullYear() +
    D +
    C +
    D +
    E +
    "" +
    F.getHours() +
    A +
    F.getMinutes() +
    A +
    F.getSeconds();
  return B;
}

function addPage(E, C) {
  console.log(E);
  var B = loading_img_url[E];
  if (!B) {
    return;
  }
  var A = "";
  if (E == 1) {
    A +=
      ' <div id="first"><img src=' +
      B +
      ' style="width: 100%;height: 100%;"/></div>';
  } else {
    if (E == length) {
      A +=
        ' <div id="end"><img src=' +
        B +
        ' style="width: 100%;height: 100%;"/></div>';
    } else {
      A += " <div><img src=" + B + ' style="width: 100%;height: 100%;"/></div>';
    }
  }
  if (!C.turn("hasPage", E)) {
    var D = $("<div />").html("");
    C.turn("addPage", D, E);
    D.html(A);
  }
}
