网站技术
当前目录:首页 >> 新闻中心 >> 网站技术

品家网图片采集代码

发布人:卓伟软件
发布日期:2014-05-12 10:35:27
浏览次数:1369

/*

Author:jacky QQ:7092734 Email:jacky@d369.net

Site:http://www.d369.net

Version:1.0

*/

(function (w) {

   if (!AS || typeof AS == "undefined") var AS = new Object(); if (!AS.PJW || typeof AS.PJW == "undefined") AS.PJW = new Object(); if (!AS.PJW.CJ || typeof AS.PJW.CJ == "undefined") AS.PJW.CJ = new Object();

   AS.PJW.CJ = function () {

       this.limit = { width: 300, height: 300, count: 10 }; var self = this, _s = "19851006"; this.q = []; this.ID = "PJW_CJ_Containter_" + _s;

       this.ImageID = "PJW_CJ_Image_Containter_" + _s; this.bgID = "PJW_CJ_Background_Containter_" + _s; this.tID = "PJW_CJ_Title_Containter_" + _s;

       this.$ = function () { if (arguments.length == 0) return; var arg = arguments[0]; if (!this.isString(arg)) return arg; return document.getElementById ? document.getElementById(arg) : document.all[arg]; }

       this.$C = function () { return document.createElement(arguments[0]); }

       this.isString = function (s) { return Object.prototype.toString.call(s) === "[object String]"; }

       this.loadStyle = function (a, b) { var l = this.$C("style"); l.setAttribute("id", a || ""); l.setAttribute("type", "text/css"); l.setAttribute("media", "screen"); if (!!window.ActiveXObject) { l.styleSheet.cssText = b; } else { l.innerHTML = b; } return l; }

       this.WH = function () { return { width: Math.max(document.documentElement.clientWidth, document.body.clientWidth), height: Math.max(document.documentElement.clientHeight, document.body.clientHeight) }; }

       this.i = function (s, f) { var _Image = new Image(); _Image.src = s; f.call(_Image); }

       this.f = function () { var w = this.width, h = this.height, r = this.src, s = this.fileSize || 0, t = this.alt || ""; if (w > self.limit.width && h > self.limit.height) { self.q.push({ w: w, h: h, src: r, size: s, alt: t }); } }

       this.close = function () { if (this.$(this.ID)) this.$(this.ID).parentNode.removeChild(this.$(this.ID)); if (this.$(this.bgID)) this.$(this.bgID).parentNode.removeChild(this.$(this.bgID)); if (this.$("PinJiaWangShareScript")) this.$("PinJiaWangShareScript").parentNode.removeChild(this.$("PinJiaWangShareScript")); if (this.$("PJWStyleCss")) this.$("PJWStyleCss").parentNode.removeChild(this.$("PJWStyleCss")); }

       this.a = function (o) { var _a = this.$(this.ImageID).getElementsByTagName("a"); for (var i = 0; i < _a.length; i++) _a[i].className = (o.checked ? "selectOk" : ""); this.d(); }

       this.b = function () { var _a = this.$(this.ImageID).getElementsByTagName("a"); for (var i = 0; i < _a.length; i++) if (_a[i].className == "selectOk") { _a[i].className = ""; } else { _a[i].className = "selectOk"; }; this.d(); }

       this.c = function () {

           var _a = this.$(this.ImageID).getElementsByTagName("a"), q = []; for (var i = 0; i < _a.length; i++) if (_a[i].className == "selectOk" && q.length < this.limit.count) q.push("&u=" + encodeURIComponent(_a[i].getElementsByTagName("img")[0].src)); if (q.length == 0) { alert("请选择要收集的图."); return; }

           window.open("http://image.66880.com/API/cj/Default.aspx?s=g" + q.join(""), "66880.com_Share", "status=no,resizable=no,scrollbars=yes,personalbar=no,directories=no,location=no,toolbar=no,menubar=no,left=0,top=0");

       }

       this.d = function (o) { var _a = this.$(this.ImageID).getElementsByTagName("a"), _i = 0; for (var i = 0; i < _a.length; i++) if (_a[i].className == "selectOk") _i++; if (_i == 0) { this.$(this.tID).innerHTML = "请选择您要采集的图片(可多选)"; } else { if (_i > this.limit.count && o) { alert("对不起,最多可选择" + this.limit.count + "张图片采集."); o.className = ""; return; }; this.$(this.tID).innerHTML = "您已选择 <span style=\"color:#FF6600;font-size:14px;font-weight:bold;\">" + _i + "</span> 张图片"; } }

       this.t = function () { var host = w.location.host.toLowerCase(); if (host.indexOf(".66880.com") > -1) { MessageBox.alert("对不起,不能采集品家网本站的图片哦.", "", function (e) { }); return false; }; return true; }

       this.run = function () {

           if (!this.t()) return;

           if (!this.$("PJWStyleCss")) { var linkString = '.pjwcaiji{overflow:hidden;position:absolute;z-index:999999999;left:0px;top:0px;width:100%;margin:0px;padding:0px;background:#FFFFFF;}.pjwcaiji .headBg,.pjwcaiji .headBg .cj,.pjwcaiji .images ul li a:hover i,.pjwcaiji .images ul li .selectOk i,.pjwcaiji .head .qx{ background:url("http://image.66880.com/API/cj/_Images/cj.png") 0px 0px no-repeat;}.pjwcaiji .headBg{height:74px; background-position:0 0;background-repeat:repeat-x;}.pjwcaiji .head{ width:550px;height:54px; margin:0 auto; }.pjwcaiji ul,.pjwcaiji ul li{margin:0px;padding:0px;list-style:none;}.pjwcaiji .head ul li{ float:left; height:54px; line-height:54px;margin-right:15px;}.pjwcaiji .head ul li input{ margin-right:10px;}.pjwcaiji .head .cj{ background-position:0 -100px; height:37px; width:111px; display:block; position:relative;float:left; top:9px; cursor:pointer;border:0px;}.pjwcaiji .head .cj:hover{background-position:-130px -100px;}.pjwcaiji .images{width:100%;overflow:hidden;background:#FFFFFF;}.pjwcaiji .images ul li{ float:left; margin-left:10px; width:210px; height:210px;padding:1px;margin:3px;overflow:hidden;border:1px solid #CCCCCC; position:relative; z-index:2;}.pjwcaiji .images ul li a{display:block; height:210px;text-align:center; width:210px; overflow:hidden; float:left;  }.pjwcaiji .images ul li a:hover i{background-position:-110px -160px; height:42px; width:124px; display:block; position:absolute; left:40px; top:75px; z-index:10;}.pjwcaiji .images ul li a img{}.pjwcaiji .images ul li a span{ height:210px; width:210px; display:block; position:absolute; top:0; left:0;}.pjwcaiji .images ul li .selectOk i{background-position:0 -160px; height:52px; width:69px; position:absolute; left:75px; top:75px; z-index:5;}.pjwcaiji .images ul li .selectOk span{ background:#000000; opacity:0.1; filter:alpha(Opacity=10); display:block; float:left; height:210px; width:210px; z-index:4; position:absolute; top:0;}.pjwcaiji .images ul li  span{ width:210px; height:30px; display:block; text-align:center; color:#666666; font-size:14px; position:absolute; bottom:0;}.pjwcaiji .head .qx { background-position:0 -260px; height:37px;border:0px;margin-left:5px; width:74px; display:block; position:relative; top:9px; cursor:pointer; float:left;}.pjwcaiji .head .qx:hover{background-position:-170px -260px;}'; document.getElementsByTagName("head")[0].appendChild(this.loadStyle("PJWStyleCss", linkString)); }

           if (!this.$(this.ID)) { var WH = this.WH(), div = this.$C("div"); div.className = "pjwcaiji"; div.setAttribute("id", this.ID); div.innerHTML = '<div class="headBg"><div class="head"><ul><li id="' + this.tID + '">请选择您要采集的图片(可多选)</li><li><input name="a" id="a" type="checkbox" onclick="javascript:PJWCJ.a(this);"/><label for="a">全选</label></li><li><input name="b" id="b" type="checkbox" onclick="javascript:PJWCJ.b();"/><label for="b">反选</label></li></ul><input name="" type="button" class="cj" onclick="javascript:PJWCJ.c();"/><input name="" type="button" class="qx" onclick="javascript:PJWCJ.close();"/></div></div><div class="images" id="' + this.ImageID + '"></div>'; document.body.appendChild(div); }

           if (!this.$(this.bgID)) { var bg = this.$C("iframe"); bg.setAttribute("id", this.bgID); bg.setAttribute("width", "100%"); bg.setAttribute("height", WH.height); bg.setAttribute("scroll", "hidden"); bg.setAttribute("frameborder", "0"); bg.style.cssText = "z-index:999999998;position:absolute;top:0px;left:0px;background:(0,0,0,0.3)!important; opacity:0.3; filter:alpha(Opacity=30);"; bg.setAttribute("src", "http://image.66880.com/API/cj/bg.html"); document.body.appendChild(bg); }

           var ImageID = this.$(this.ImageID), ul = this.$C("ul"); ImageID.appendChild(ul), images = document.images; for (var i = 0; i < images.length; i++) this.i(images[i].src, this.f);

           for (var i = 0; i < this.q.length; i++) { var li = this.$C("li"), a = this.$C("a"), s = this.$C("span"), _w = 210, h = 210, b = this.q[i]; s.innerHTML = this.q[i].w + "*" + this.q[i].h + "px"; s.style = "background:(0,0,0,0.8)!important; opacity:0.8; filter:alpha(Opacity=80);color:#FFFFFF;background:#000000;line-height:30px;"; a.setAttribute("href", "javascript:;"); if (b.w / b.h >= _w / h) { if (b.w > _w) { h = (b.h * _w) / b.w; } else { _w = b.w; } } else { if (b.h > h) { _w = (b.w * h) / b.h; } else { h = b.h; } }; a.innerHTML = '<i></i><span></span><img src="' + this.q[i].src + '" alt="' + this.q[i].t + '" width="' + _w + '" height="' + h + '" />'; a.onclick = function () { if (this.className == "") { this.className = "selectOk"; } else { this.className = ""; }; self.d(this); }; li.appendChild(a); li.appendChild(s); ul.appendChild(li); }; w.scrollTo(0, 0);

       }

   }

   var PJWCJ = new AS.PJW.CJ(); PJWCJ.run(); if (!window.PJWCJ) window.PJWCJ = PJWCJ;

})(window);




Copyright © 2010 - 2015 Zhuovi. All Rights Reserved
联系电话:15837199978  E-Mail:service@zhuovi.com  在线QQ:点击这里给我发消息 点击这里给我发消息  备案号:豫ICP备14022191号
郑州网站建设 | 河南网站建设 | 郑州软件 | 河南软件 | 办公软件 | 移动短信 | 注册域名 | 虚拟空间,网站空间 | 群发短信 | 网站优化 | 网站推广 | 优化技术 | 郑州作网站 | 河南作网站
在线咨询 返回顶部