PageSourceSearch

https://mabian.gov.cn/mbyzzzx/resource/js/power.js

js mabian.gov.cn collected 2026-10-02 21:57:41 UTC 23,474 bytes, 790 lines download raw bytes

1(function () {
2  function isMobile() {
3    var mobile = {
4      Android: function () {
5        return navigator.userAgent.match(/Android/i) ? true : false;
6      },
7      BlackBerry: function () {
8        return navigator.userAgent.match(/BlackBerry/i) ? true : false;
9      },
10      iOS: function () {
11        return navigator.userAgent.match(/iPhone|iPad|iPod/i) ? true : false;
12      },
13      Windows: function () {
14        return navigator.userAgent.match(/IEMobile/i) ? true : false;
15      },
16      any: function () {
17        return (
18          this.Android() || this.BlackBerry() || this.iOS() || this.Windows()
19        );
20      },
21    };
22    return mobile.any();
23  }
24
25  function createVideo(swfPath, src, width, height) {
26    return (
27      '<object type="application/x-shockwave-flash" name="powerPlayback" data="' +
28      swfPath +
29      '" width="' +
30      width +
31      '" height="' +
32      height +
33      '" id="powerPlayback" style="visibility: visible;">' +
34      '<param name="allowFullScreen" value="true">' +
35      '<param name="wmode" value="opaque">' +
36      '<param name="flashvars" value="src=' +
37      src +
38      '&amp;autoPlay=false&amp;title=2013&amp;breakPoint=0&amp;preroll=&amp;prerollSite=&amp;bannerImageUrl=&amp;bannerUrl=&amp;scaleMode=letterBox&amp;controlBarAutoHide=false&amp;streamType=liveOrRecorded&amp;javascriptCallbackFunction=onJavaScriptBridgeCreated">' +
39      "</object>"
40    );
41  }
42
43  function createWmvVideo(src, width, height) {
44    return (
45      '<object classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" id="WindowsMediaPlayer" ' +
46      'width="' +
47      width +
48      '" ' +
49      'height="' +
50      height +
51      '">' +
52      '<param name="URL" value="' +
53      src +
54      '">' +
55      "</object>"
56    );
57  }
58
59  function createIeTooltip(width, height) {
60    return (
61      '<div style="width:' +
62      width +
63      "px; height:" +
64      height +
65      'px; background-color:#000;">' +
66      '<p style="width: ' +
67      width +
68      "px;height: " +
69      height +
70      "px;line-height:" +
71      height +
72      'px; color:#fff; text-align:center;">请使用IE浏览器查看该视频</p></div>'
73    );
74  }
75
76  function isIe() {
77    //判断是否是IE浏览器。
78    return !!window.ActiveXObject || "ActiveXObject" in window;
79  }
80
81  function isWmv(src) {
82    //判断是否是 .wmv
83    return src.toLocaleLowerCase().indexOf(".wmv") > 0;
84  }
85
86  function isSwf(src) {
87    //判断是否是 .swf
88    return src.indexOf(".swf") > 0;
89  }
90
91  $(function () {
92    var videoSites = [
93      "player.youku.com",
94      "i7.imgs.letv.com",
95      "static.youku.com",
96      "share.vrs.sohu.com",
97      "player.ku6.com",
98      "player.pps.tv",
99      "static.video.qq.com",
100      "share.vrs.sohu.com",
101      "qzonestyle.gtimg.cn",
102    ];
103
104    function embedUrl(url) {
105      if (!isSwf(url)) {
106        return false;
107      }
108
109      var uri = url.replace(/\w+:\/\//gi, ""),
110        result = false;
111
112      $.each(videoSites, function (i, n) {
113        if (uri.startsWith(n)) {
114          result = true;
115          return false;
116        }
117      });
118
119      return result;
120    }
121
122    if (!isMobile()) {
123      //视频播放功能JS。
124      $("video.edui-upload-video").each(function () {
125        var $this = $(this),
126          width = $this.attr("width"),
127          height = $this.attr("height"),
128          src = $this.prop("src"),
129          swfPath = "/Content/_Common/Base/swf/PowerPlayback.swf",
130          video = "";
131        if (isIe() && isWmv(src)) {
132          video = createWmvVideo(src, width, height);
133        } else if (!isIe() && isWmv(src)) {
134          video = createIeTooltip(width, height);
135        } else {
136          video = createVideo(swfPath, src, width, height);
137        }
138        if (embedUrl(src)) {
139          $this.replaceWith(
140            $(
141              "<embed allowScriptAccess='always' allowFullScreen='true' mode='transparent' type='application/x-shockwave-flash'></embed>",
142            )
143              .attr("width", width)
144              .attr("height", height)
145              .attr("src", src),
146          );
147        } else {
148          $this.replaceWith($(video));
149        }
150      });
151
152      $("embed").each(function () {
153        var $this = $(this),
154          width = $this.attr("width"),
155          height = $this.attr("height"),
156          src = $this.prop("src"),
157          swfPath = "/Content/_Common/Base/swf/PowerPlayback.swf",
158          video = "";
159        if (isIe() && isWmv(src)) {
160          video = createWmvVideo(src, width, height);
161        } else if (!isIe() && isWmv(src)) {
162          video = createIeTooltip(width, height);
163        } else {
164          video = createVideo(swfPath, src, width, height);
165        }
166
167        if (!isSwf(src)) {
168          $this.replaceWith($(video));
169        }
170      });
171    } else {
172      $("video.edui-upload-video").show();
173    }
174  });
175
176  $(function () {
177    var powerplaybacks = $("div[data-power-ui='powerplayback']");
178    if (powerplaybacks.length > 0) {
179      $.getScript("/Content/_Common/Assets/Scripts/swfobject.js").done(
180        function () {
181          powerplaybacks.each(function () {
182            var src = $(this).attr("data-url");
183            var title = $(this).attr("data-title");
184            var height = $(this).attr("data-height");
185            var width = $(this).attr("data-width");
186            var autoPlay = $(this).attr("data-autoPlay");
187            var random = parseInt(Math.random() * (99999 - 10000 + 1) + 10000);
188            var id = "PowerPlay" + random;
189            $(this).attr("id", id);
190            var parameters = {
191              src: src,
192              autoPlay: autoPlay,
193              title: title,
194              controlBarAutoHide: "false",
195              scaleMode: "liveOrRecorded",
196            };
197            swfobject.embedSWF(
198              "/Content/_Common/Base/swf/PowerPlayback.swf",
199              id,
200              width,
201              height,
202              "10.1.0",
203              {},
204              parameters,
205              {
206                allowFullScreen: "true",
207                wmode: "opaque",
208              },
209              {
210                name: "powerPlayback",
211              },
212            );
213          });
214        },
215      );
216    }
217  });
218
219  //广告。
220  $(function () {
221    /**
222     * 广告漂浮版位。
223     */
224    function advertisementFloat(floatPositions) {
225      //var floatPositions = $("div[data-power-ui='advertisement_float']");
226      floatPositions.each(function () {
227        var width = $(this).data().width; //版位宽度
228        var height = $(this).data().height; //版位高度
229        //计算关闭按钮的位置
230        var close = $(this).children(".close");
231        switch ($(this).data().closeButtonPosition) {
232          case "UpperRight":
233            close.css("left", width - 20);
234            break;
235          case "LowerRight":
236            close.css("left", width - 20).css("top", height - 20);
237            break;
238          case "NoShow":
239            close.hide();
240            break;
241        }
242
243        //定时关闭版位
244        var time = $(this).data().stopTime;
245        if (time > 0) {
246          setTimeout(function () {
247            $(this).hide();
248          }, time * 1000);
249        }
250      });
251      return floatPositions;
252    }
253
254    var floatPositionsInfo = $("div[data-power-ui='advertisement_float']");
255    var floatPositions = advertisementFloat(floatPositionsInfo);
256    floatPositions.each(function () {
257      var floatPosition = $(this);
258      //计算版位的坐标
259      var ypos = positionCoordinate($(this));
260      //广告随滚动条滚动
261      if (floatPosition.data().enableScroll.toLowerCase() === "true") {
262        floatPosition.css("top", $(this).scrollTop() + ypos);
263        $(window).scroll(function () {
264          floatPosition.css("top", $(this).scrollTop() + ypos);
265        });
266      }
267    });
268
269    //浏览器窗口大小改变时
270    window.onresize = function () {
271      var floatPositionsInfo = $("div[data-power-ui='advertisement_float']");
272      var floatPositions = advertisementFloat(floatPositionsInfo);
273      floatPositions.each(function () {
274        var floatPosition = $(this);
275        //计算版位的坐标
276        var ypos = positionCoordinate($(this));
277        //广告随滚动条滚动
278        if (floatPosition.data().enableScroll.toLowerCase() === "true") {
279          $(window).scroll(function () {
280            floatPosition.css("top", $(this).scrollTop() + ypos);
281          });
282        }
283      });
284    };
285
286    //计算版位的坐标
287    function positionCoordinate(floatPosition) {
288      var xpos = 0;
289      var ypos = 0;
290      var width = floatPosition.data().width; //版位宽度
291      var height = floatPosition.data().height;
291 //版位高度
292      var availWidth = document.documentElement.clientWidth; //浏览器窗口可见宽度
293      var availHeight = document.documentElement.clientHeight; //浏览器窗口可见高度
294      var verticalMargin = floatPosition.data().verticalMargin / 100;
295      var horizontalMargin = floatPosition.data().horizontalMargin / 100;
296      switch (floatPosition.data().datumMark) {
297        case "UpperLeft":
298          xpos = availWidth * verticalMargin;
299          xpos = xpos === availWidth ? xpos - width : xpos;
300          ypos = availHeight * horizontalMargin;
301          ypos = ypos === availHeight ? ypos - height : ypos;
302          break;
303        case "LowerRight":
304          xpos = availWidth - width - availWidth * verticalMargin;
305          xpos = xpos < 0 ? 0 : xpos;
306          ypos = availHeight - height - availHeight * horizontalMargin;
307          ypos = ypos < 0 ? 0 : ypos;
308          break;
309        case "Middle":
310          var halfWidth = availWidth / 2;
311          var halfheight = availHeight / 2;
312          xpos = halfWidth + halfWidth * verticalMargin;
313          xpos = xpos === availWidth ? xpos - width : xpos;
314          ypos = halfheight + halfheight * horizontalMargin;
315          ypos = ypos === height ? ypos - height : ypos;
316          break;
317      }
318      floatPosition.css("z-index", 99).css("left", xpos);
319      return ypos;
320    }
321
322    /**
323     * 广告固定板块。
324     */
325    var fixedCount = 0,
326      $fixedList = $("div[data-power-ui='advertisement_fixed']"),
327      $fixedNumLinkList = $fixedList.find(".fixedCount a"),
328      fixedLength = $fixedNumLinkList.length;
329
330    function advertisementSiblings(element) {
331      var $element = $(element),
332        index = Number($element.text()) - 1;
333      $element.addClass("seld").siblings().removeClass("seld");
334      $fixedList
335        .find(".fixedPosition > a")
336        .eq(index)
337        .fadeIn(300)
338        .siblings()
339        .fadeOut(300);
340    }
341
342    function showAuto() {
343      fixedCount = fixedCount > fixedLength - 1 ? 0 : ++fixedCount;
344      advertisementSiblings($fixedNumLinkList.eq(fixedCount));
345    }
346
347    if (fixedLength) {
348      $fixedList.each(function (i, n) {
349        $(this).on("click", ".fixedCount a", function () {
350          advertisementSiblings(this);
351        });
352      });
353
354      var fixedCountTime = setInterval(showAuto, 2000);
355      $fixedList.hover(
356        function () {
357          clearInterval(fixedCountTime);
358        },
359        function () {
360          fixedCountTime = setInterval(showAuto, 2000);
361        },
362      );
363    }
364  });
365
366  // Ajax调用分部视图。
367  $(function () {
368    function getFunction(code, argNames) {
369      var fn = window,
370        parts = (code || "").split(".");
371
372      while (fn && parts.length) {
373        fn = fn[parts.shift()];
374      }
375
376      if (typeof fn === "function") {
377        return fn;
378      }
379
380      argNames.push(code);
381      return Function.constructor.apply(null, argNames);
382    }
383
384    function loadData($data, pageid) {
385      var url = $data.ajaxUrl;
386      if (pageid) {
387        url = url + "?pageid=" + pageid;
388      }
389      $.ajax({
390        url: url,
391        type: $data.ajaxMethod,
392        cache: !!$data.ajaxCache,
393        data: {
394          partialViewName: $data.ajaxPartialViewName,
395          parameters: JSON.stringify($data.ajaxParameter),
396        },
397        beforeSend: function (xhr) {
398          getFunction($data.ajaxBegin, ["xhr"]).apply(null, arguments);
399        },
400        complete: function () {
401          getFunction($data.ajaxComplete, ["xhr", "status"]).apply(
402            null,
403            arguments,
404          );
405        },
406        success: function (response, status, xhr) {
407          var fn = window,
408            parts = ($data.ajaxSuccess || "").split(".");
409          while (fn && parts.length) {
410            fn = fn[parts.shift()];
411          }
412          if (typeof fn === "function") {
413            getFunction($data.ajaxSuccess, ["response", "status", "xhr"]).apply(
414              null,
415              arguments,
416            );
417          } else {
418            if (response.page) {
419              $data.ajaxDataCount = response.page.DataCount;
420              $data.ajaxPageIndex = response.page.PageIndex;
421              $data.ajaxPageSize = response.page.PageSize;
422              $data.ajaxPagingUrl = response.page.PagingUrl;
423            }
424
425            $('[data-ajax-data="' + $data.ajaxId + '"]').each(function () {
426              $(this).trigger("ajaxControlHandler", [response, $data]);
427            });
428
429            var mode = ($data.ajaxMode || "").toUpperCase();
430            $($data.ajaxUpdate).each(function (i, update) {
431              var top;
432              switch (mode) {
433                case "BEFORE":
434                  top = update.firstChild;
435                  $("<div />")
436                    .html(response.html)
437                    .contents()
438                    .each(function () {
439                      update.insertBefore(this, top);
440                    });
441                  break;
442                case "AFTER":
443                  $("<div />")
444                    .html(response.html)
445                    .contents()
446                    .each(function () {
447                      update.appendChild(this);
448                    });
449                  break;
450                case "REPLACE-WITH":
451                  $(update).replaceWith(response.html);
452                  break;
453                default:
454                  $(update).html(response.html);
455                  break;
456              }
457            });
458          }
459        },
460        error: function (xhr, textStatus, errorThrown) {
461          getFunction($data.ajaxFailure, ["xhr", "status", "error"]).apply(
462            null,
463            arguments,
464          );
465        },
466      });
467    }
468
469    // ajaxpartial 初始化
470    $('[data-ui-type="ajaxpartial"]').each(function () {
471      var $data = $(this).data();
472      $data.ajaxLoadData = loadData;
473      loadData($data);
474    });
475
476    // ajaxbutton 初始化
477    function ajaxButtonControlHandler(response, $data) {
478      $('[data-ajax-data="' + $data.ajaxId + '"]').each(function () {
479        if (response.page.PageIndex >= response.page.PageCount) {
480          $(this).hide();
481        }
482      });
483    }
484
485    $('[data-ui-type="ajaxbutton"]').each(function () {
486      var $this = $(this);
487
488      function getData(element) {
489        var id = $(element).data().ajaxData;
490        var input = $("#" + id);
491        var $data = input.data();
492        var pageid = 1;
493        if ($data.ajaxPageIndex) {
494          pageid = $data.ajaxPageIndex + 1;
495        }
496        $data.ajaxLoadData($data, pageid);
497      }
498
499      $this.on("ajaxControlHandler", function (event, response, $data) {
500        ajaxButtonControlHandler(response, $data);
501      });
502
503      $this.on("click", function () {
504        getData(this);
505      });
506    });
507  });
508
509  //编辑器内的表格在前台展示时滚动条的显示
510  $(function () {
511    var contentwidth = $('[data-power-area="content"]').width();
512    if (contentwidth != null) {
513      $('[data-power-area="content"] table').wrap(
514        '<div class="ueditortable"></div>',
515      );
516      $(".ueditortable").css("width", contentwidth);
517      var ueditortables = $(".ueditortable");
518      $.each(ueditortables, function () {
519        var table = $(this).find("table")[0];
520        if (
521          table.clientWidth > contentwidth &&
522          table.clientHeight > contentwidth
523        ) {
524          $(this).css("height", contentwidth);
525        }
526      });
527
528      $(".ueditortable").hover(
529        function () {
530          var tablewidth = $(this).find("table")[0].offsetWidth;
531          if (
532            parseInt(tablewidth) > contentwidth &&
533            !$(this).hasClass("tablemask")
534          ) {
535            $(this).prepend(
536              '<p class="expandtable"><a id="fullScreen" title="全屏" href="javascript:;"><i class="fa fa-expand"></i></a></p>',
537            );
538          }
539        },
540        function () {
541          $(this).find(".expandtable").remove();
542        },
543      );
544
545      var $this = $(".ueditortable");
546      $(".ueditortable").on("click", ".expandtable", function () {
547        $this = $(this).parent();
548        fullscreenState();
549      });
550
551      $("body").on("click", ".compresstable", function () {
552        $this = $(this).parent();
553        fullscreenState();
554      });
555
556      $("body").on("click", ".newwindowtable", function () {
557        var b = window.open("");
558        var html = $(".newueditortable")
559          .find("table")
560          .css("text-align", " center")[0].outerHTML;
561        $(b.document.body).html(html + "<style>td { border: solid;}</style>");
562      });
563
564      document.onkeydown = function (ev) {
565        var oEvent = ev || event;
566        if (oEvent.keyCode == 27) {
567          if ($(".newueditortable").length > 0) {
568            fullscreenState();
569          }
570        }
571      };
572    }
573
574    function fullscreenState() {
575      if ($("div").hasClass("tablemask")) {
576        $(".tablemask").remove();
577        $(".newueditortable").remove();
578      } else {
579        $("body").prepend('<div class="tablemask"></div>');
580        $this.find(".expandtable").remove();
581        $("body").append(
582          '<div class="newueditortable">' + $this.html() + "</div>",
583        );
584
585        tablemargins();
586        $(".newueditortable").hover(
587          function () {
588            $(this).prepend(
589              '<div class="newclass"><p class="newwindowtable"><a href="javascript:;">打开新窗口表单</a></p><p class="compresstable"><a title="退出全屏" href="javascript:;"><i class="fa fa-compress"></i>&nbsp;退出全屏</a></p></div>',
590            );
591            $(".newclass").css("left", $(window).width() / 2.4);
592          },
593          function () {
594            $(this).find(".newclass").remove();
595          },
596        );
597
598        $(window).resize(function () {
599          tablemargins();
600        });
601      }
602    }
603
604    function tablemargins() {
605      if ($this.find("table").width() > $(window).width() / 1.1) {
606        $(".newueditortable").css("width", $(window).width() / 1.1);
607      } else {
608        $(".newueditortable").css("width", "");
609      }
610
611      $(".newueditortable").css(
612        "left",
613        ($(window).width() - $(".newueditortable").outerWidth()) / 2,
614      );
615      $(".newclass").css("left", $(window).width() / 2.4);
616      if ($this.find("table").height() > $(window).height() / 1.2) {
617        $(".newueditortable").css("height", $(window).height() / 1.2);
618      } else {
619        $(".newueditortable").css("height", "");
620      }
621    }
622  });
623
624  /**
625   * 渲染二维码
626   * @param {JQuery} $element 要渲染为二维码的jQuery实体。
627   */
628  function renderQrcode($element) {
629    var content = $element.data("content"),
630      size = $element.data("size");
631    if (!content) {
632      content = window.location.href;
633    }
634    content = encodeURI(content);
635    new QRCode($element.get(0), {
636      text: content,
637      width: size,
638      height: size,
639    });
640
641    //qrcode.makeCode();
642  }
643
644  $('[data-powertype="qrcode"]').each(function (i, n) {
645    renderQrcode($(n));
646  });
647
648  updateContentHits();
649
650  /**
651   * 更新内容的点击数。
652   * @returns {}
653   */
654  function updateContentHits() {
655    $("[data-power-hits-action]").each(function () {
656      var $element = $(this);
657      var mold = $element.data().powerHitsMold,
658        id = $element.data().powerHitsId;
659
660      $.post(
661        $element.data().powerHitsAction,
662        {
663          mold: mold,
664          id: id,
665        },
666        function (data) {
667          $element.text(data.hits);
668        },
669      );
670    });
671  }
672
673  //点击外链询问离开
674  /**
675   * 获取Host
676   * @param {string} url 地址。
677   */
678  function getHost(url) {
679    var host = "null";
680
681    if (typeof url == "undefined" || null == url) {
682      url = window.location.href;
683    }
684
685    //HTMLHyperlinkElementUtils.host 使用API来获取。
686    var anchor = document.createElement("a");
687    anchor.href = url;
688    if (anchor.hostname) {
689      return anchor.hostname;
690    }
691
692    var regex = /.*\:\/\/([^\/]*).*/;
693    var match = url.match(regex);
694    if (typeof match != "undefined" && null != match) {
695      host = match[1];
696    }
697    return host;
698  }
699
700  /**
701   * 点击外链询问离开
702   * @param {this对象} _this this对象。
703   * @param {string} type 类型"aLink"为a链接,"select"为select下拉。
704   */
705  function isExcelLink(_this, type) {
706    var o = $(_this);
707    var href = "";
708    var siteName = $("meta[name ='application-name']").attr("content");
709    if (type == "aLink") {
710      href = o.attr("href");
711    } else if (
712      type == "select" &&
713      _this.options[_this.selectedIndex].value != ""
714    ) {
715      href = _this.options[_this.selectedIndex].value;
716    }
717    var linkHost = getHost(href);
718
719    //设置白名单,excelLinkWhiteList是全局变量,如有需要请写到基础布局页里面。例excelLinkWhiteList = ["www.***.com"]
720    if (typeof excelLinkWhiteList == "undefined") {
721      excelLinkWhiteList = [];
722    }
723    if (
724      typeof href != "undefined" &&
725      linkHost != "null" &&
726      excelLinkWhiteList.indexOf(linkHost) < 0 &&
727      location.hostname.replace("www.", "") !=
728        linkHost.replace("www.", "").split(":")[0]
729    ) {
730      o.removeAttr("href");
731      var w = "480px";
732      var h = "170px";
733      if (window.screen.width < 768) {
734        w = "90%";
735        h = "170px";
736      }
737      var cf = layer.confirm(
738        '<div style="margin-top:30px; font-size:16px;">您访问的链接即将离开“马边彝族自治县人民政府”,</br>是否继续?</div>',
739        {
740          btn: ["继续访问", "放弃"],
741          title: false,
742          shade: 0.7,
743          area: [w, h],
744          shadeClose: true,
745          end: function () {
746            if (type == "aLink") {
747              o.attr("href", href);
748            }
749          },
750        },
751        function () {
752          if (type == "aLink") {
753            o.attr("href", href);
754          }
755          layer.close(cf);
756          window.open(href);
757        },
758        function () {
759          if (type == "aLink") {
760            o.attr("href", href);
761          }
762          layer.close(cf);
763        },
764      );
765    }
766  }
767  //列表页面侧边菜单选择
768  function slidermenu() {
769    var obj = $("#menu ul li");
770    var p = $("#menu").attr("v");
771    obj.each(function () {
772      var s = $(this).attr("v");
773      if (p == s) {
774        $(this).addClass("listactive").siblings("li").removeClass("listactive");
775      }
776    });
777  }
778  $(document).on("click", "a", function () {
779    isExcelLink(this, "aLink");
780  });
781  $(document).on("change", "select", function () {
782    isExcelLink(this, "select");
783  });
784
785  $(".m-listbd ul li:nth-child(5n)").css({
786    borderBottom: "1px dashed #ddd",
787    marginBottom: "10px",
788    paddingBottom: "10px",
789  });
790})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.