; (function ($, window, document, undefined) { $.getUrlParam = function (name) { var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); var r = window.location.search.substr(1).match(reg); if (r != null) return unescape(r[2]); return null; } $.extend($.fn, { GetPath: function () { var result = ""; try { a = b; } catch (e) { if (e.fileName) {//firefox result = e.fileName; } else if (e.sourceURL) {//safari result = e.sourceURL; } } if (!result) {//IE与chrome var scripts = document.getElementsByTagName("script"); var reg = /jquery.utils.js?/; for (var i = 0, n = scripts.length ; i < n ; i++) { var src = !!document.querySelector ? scripts[i].src : scripts[i].getAttribute("src", 4); if (src && reg.test(src)) { result = src; break; } } } return result; }, GetUrlParms: function () { var args = new Object(); var query = location.search.substring(1);//获取查询串 var pairs = query.split("&");//在逗号处断开 for (var i = 0; i < pairs.length; i++) { var pos = pairs[i].indexOf('=');//查找name=value if (pos == -1) continue;//如果没有找到就跳过 var argname = pairs[i].substring(0, pos);//提取name var value = pairs[i].substring(pos + 1);//提取value args[argname] = unescape(value);//存为属性 } return args; }, LoadAp: function (options) { var pobj = this; var _height = pobj.height(); if (_height == 0) { _height = GetClientHeight(0.9); } var divObj = $("<div style='text-align:center;vertical-align: middle;color: #01AEE5; " + pobj.width() + "px; height:" + _height + "px;line-height:" + _height + "px; font-weight:bold; font-size:20px; border:0px solid lightgray;overflow:hidden;'>正在载入图像...</div>"); this.css("background", "url("/img/aploading.gif") #151515 no-repeat center center"); this.css("display", "block;"); this.css("border", "0;"); this.append(divObj); var url = options.url; if (options.data) { url = url + "?"; jQuery.each(options.data, function (i, val) { url = url + i + "=" + val + "&"; }); if (url.endsWith("&")) { url = url.substr(0, url.length - 1); } } //var s = ""; //s += " 网页可见区域宽:" + document.body.clientWidth; //s += " 网页可见区域高:" + document.body.clientHeight; //s += " 网页可见区域宽:" + document.body.offsetWidth + " (包括边线和滚动条的宽)"; //s += " 网页可见区域高:" + document.body.offsetHeight + " (包括边线的宽)"; //s += " 网页正文全文宽:" + document.body.scrollWidth; //s += " 网页正文全文高:" + document.body.scrollHeight; //s += " 网页被卷去的高:" + document.body.scrollTop; //s += " 网页被卷去的左:" + document.body.scrollLeft; //s += " 网页正文部分上:" + window.screenTop; //s += " 网页正文部分左:" + window.screenLeft; //s += " 屏幕分辨率的高:" + window.screen.height; //s += " 屏幕分辨率的宽:" + window.screen.width; //s += " 屏幕可用工作区高度:" + window.screen.availHeight; //s += " 屏幕可用工作区宽度:" + window.screen.availWidth; //s += " 你的屏幕设置是 " + window.screen.colorDepth + " 位彩色"; //s += " 你的屏幕设置 " + window.screen.deviceXDPI + " 像素/英寸"; //alert(s) var iframe = $("<iframe></iframe>"); iframe.attr("id", "previewFrame" + Math.random()*10); iframe.attr("style", "100%; height:" + _height + "px; overflow:hidden; content:('正在载入图像...')"); iframe.css("background", "url("/img/aploading.gif") #151515 no-repeat center center"); iframe.css("display", "block;"); iframe.css("position", "absolute"); iframe.css("z-index", "-1"); iframe.attr("frameborder", "no"); iframe.attr("border", "0"); iframe.attr("marginwidth", "0"); iframe.attr("marginheight", "0"); iframe.attr("scrolling", "no"); iframe.attr("allowTransparency", "true"); iframe.attr("onload", function () { pobj.delay(2000); iframe.width(pobj.width()); pobj.replaceWith(iframe); //iframe.height(document.parentWindow.document.documentElement.clientHeight); }); iframe.attr("src", url); //if (iframe.attachEvent) { // iframe.attachEvent("onload", function () { // divObj.replaceWith(iframe); // }); //} else { // iframe.onload = function () { // divObj.replaceWith(iframe); // }; //} }, WmpPlay: function (options) { var that = $(this); var playerId = that.attr("id"); var objHtml = '<object id="' + playerId + '" style="z-index:-1" height="' + that.height() + '" width="' + that.width() + '" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6">'; objHtml += '<param NAME="AutoStart" VALUE="0">';// <!--是否自动播放--> objHtml += '<param NAME="Balance" VALUE="0">';// <!--调整左右声道平衡,同上面旧播放器代码--> objHtml += '<param name="enabled" value="0">';// <!--播放器是否可人为控制--> objHtml += '<param NAME="EnableContextMenu" VALUE="0">';// <!--是否启用上下文菜单 -1:启用 0:不启用--> objHtml += '<param NAME="url" value="' + options.url + '">';// <!--播放的文件地址--> objHtml += '<param NAME="PlayCount" VALUE="1">';// <!--播放次数控制,为整数--> objHtml += '<param name="rate" value="1">';// <!--播放速率控制,1为正常,允许小数,1.0-2.0--> objHtml += '<param name="currentPosition" value="10000">';// <!--控件设置:当前位置--> objHtml += '<param name="currentMarker" value="0">';// <!--控件设置:当前标记--> objHtml += '<param name="defaultFrame" value="">';// <!--显示默认框架--> objHtml += '<param name="invokeURLs" value="0">';// <!--脚本命令设置:是否调用URL--> objHtml += '<param name="baseURL" value="">';// <!--脚本命令设置:被调用的URL--> objHtml += '<param name="stretchToFit" value="0">';// <!--是否按比例伸展--> objHtml += '<param name="volume" value="50">';// <!--默认声音大小0%-100%,50则为50%--> objHtml += '<param name="mute" value="0">';// <!--是否静音--> objHtml += '<param name="uiMode" value="None">';// <!--播放器显示模式:Full显示全部;mini最简化;None不显示播放控制,只显示视频窗口;invisible全部不显示--> objHtml += '<param name="windowlessVideo" value>';// <!--如果是0可以允许全屏,否则只能在窗口中查看--> objHtml += '<param name="fullScreen" value="0">';// <!--开始播放是否自动全屏--> objHtml += '<param name="enableErrorDialogs" value="-1">';// <!--是否启用错误提示报告--> objHtml += '<param name="SAMIStyle" value>';// <!--SAMI样式--> objHtml += '<param name="SAMILang" value>';// <!--SAMI语言--> objHtml += '<param name="SAMIFilename" value>';// <!--字幕ID--> objHtml += '<embed src="' + options.url + '" allowfullscreen="false" quality="high" type="application/x-shockwave-flash" height="' + that.height() + '" width="' + that.width() + '"></embed>'; objHtml += '</object>'; objHtml += '<div class="play" style="cursor: pointer;" onclick="' + playerId + '.controls.play();"><img src="/images/jiantou.png" alt="" /></div>'; that.replaceWith(objHtml); var player = document.getElementById(playerId); var fn = function () { //定义一个函数,这个函数内部会定义我们的回调函数 function player::playstatechange(newstate) { switch (newstate) { case 1: //$(this).parent().find(".play").WmpPlay({ url: this.url }); //$(this).remove(); //alert("停止"); break; case 2: //alert("暂停"); break; case 3: //player.controls.pause(); //alert("正在播放"); break; case 4: //alert("4"); break; case 5: //alert("5"); break; case 6: //alert("正在缓冲..."); break; case 7: //alert("7"); break; case 8: //alert("8"); break; case 9: //alert("正在连接..."); break; case 10: //alert("准备就绪"); break; case 11: //alert("11"); break; default: //alert(""); } } }; fn(); //执行这个函数,也就是定义回调函数 //player.controls.play(); } }); $.extend({ //$.log('initializing...'); //调用 log: function (message) { var now = new Date(), y = now.getFullYear(), m = now.getMonth() + 1, //!JavaScript中月分是从0开始的 d = now.getDate(), h = now.getHours(), min = now.getMinutes(), s = now.getSeconds(), time = y + '/' + m + '/' + d + ' ' + h + ':' + min + ':' + s; console.log(time + ' My App: ' + message); } }) //插件 //在这里面,this指的是用jQuery选中的元素 //example :$('a'),则this=$('a') //$('a').myPlugin(); $.fn.myPlugin = function (options) { var defaults = { 'color': 'red', 'fontSize': '12px' }; var settings = $.extend({}, defaults, options);//将一个空对象做为第一个参数 return this.css({ 'color': settings.color, 'fontSize': settings.fontSize }); } //}(jQuery)); })(jQuery, window, document); (function ($) { $.fn.autoresize = function (option) { /** * 版本号 **/ this.version = "1.0"; var $this = $(this); var defaults = { "height": 1, "width": 0 }; var opts = $.extend(defaults, option); resize($this); function resize() { var $cur = $($this.get(0));//仅处理第一个 //设置高度 if (opts.height != 0) { var height = $(window).height(); if (opts.height < 0) { height = height + opts.height; if ($(window).height() - height + opts.height < 4 && $.browser.msie) { //解决IE的4像素问题,IE的应用可能有一些限制 $("html").css("overflow-y", "hidden"); } } else { if (opts.height > 1) { opts.height = 1; } height = $(window).height() * opts.height; if ($(window).height() - height < 4 && $.browser.msie) { //解决IE的4像素问题,IE的应用可能有一些限制 $("html").css("overflow-y", "hidden"); } } $cur.height(height); } //设置宽度 if (opts.width != 0) { var width = $(window).width(); if (opts.width < 0) { width = width + opts.width; } else { if (opts.width > 1) { opts.width = 1; } width = $(window).width() * opts.width; } $cur.width(width); } } $(window).resize(function () { resize(); }); } })(jQuery);