faunus 发表于 2008-10-10 23:54:53

具体点的在这里

function showSearchResult(o){
        if(!Fempty(o.err)){
                showErr(-3);
                return;
        }
        if(!Fempty(o.errno)){
                showErr(o.errno);
                return;
        }
        var totalPage=o.property.total_page_count;
        if(totalPage==0){
                showErr(-2);
                return;
        }

        var curPage=o.page;
        if(Fempty(curPage)) curPage=1;
        if(curPage>totalPage) curPage=totalPage;
        startPage=((curPage<=3)?1:(curPage-3));
        endPage=startPage+9;
        endPage=(endPage>totalPage?totalPage:endPage);
        var prePage=((curPage-1)>0?(curPage-1):1);
        var nextPage=((curPage+1)>totalPage?totalPage:(curPage+1));
        Fid('search_list').innerHTML='数据加载中...';
        var data=o.data;
        var tpl=new Ftemplate(Fid('tpl_user_list').innerHTML);
        tpl.setBlock('','list','lists');
        tpl.setBlock('','page','pages');
        tpl.setVar('total_count',o.property.total_count);
        tpl.setVar('online_count',o.property.online_count);
        tpl.setVar('prePage',prePage);
        tpl.setVar('nextPage',nextPage);
        for(var i=0; i<data.length; i++){

                if(i>9) break;
                var tmp=data;
                tmp.smallurl='src="'+tmp.smallurl+'"';
                tmp.onlineurl=((tmp.online>0)?'<img alt="在线" src="http://imgcache.qq.com/QzonePortal_v2/city_v2/img/online_nowave.gif"/>' : '');
                tmp.yellowurl=((tmp.yellow==1 && tmp.yellow_level>0)?'<a class="vip_lv_'+tmp.yellow_level+'" title="黄钻等级:'+tmp.yellow_level+'" target="_blank" href="http://vip.qzone.qq.com"><strong>黄钻等级:'+tmp.yellow_level+'</strong></a>':'');
                if(tmp.state3<3){
                        tmp['stateVideo']='';
                       
                }else{
                        tmp['stateVideo']='<a href="http://city.qzone.qq.com/html/faq_8.html" target="_blank"><img src="http://imgcache.qq.com/QzonePortal_v2/img/city/video_validate.gif" alt="通过视频验证"/></a>';
                }
                tmp['sex_chn']=(tmp.sex==0?'女':'男');
                tmp['height_chn']=getHeight(tmp.height,'未填写');
                tmp['weight_chn']=getWeight(tmp.weight,'未填写');
                tmp['edu_chn']=getEdu(tmp.edu,'未填写');
                tmp['intent_chn']=getIntent(tmp.intent,'未填写');
                tmp['emotion_chn']=getEmotion(tmp.emotion,'未填写');
                tmp['job_chn']=getJobName(tmp.job,'未填写');
                tmp['title']=getDarenTitleStr(tmp.cate,'未填写');
                tmp['city_chn']=FgetLocationName(tmp.city,'未填写');

                tmp['sProv']=11;
                tmp['sCity']=1100;
                var city=tmp.city+'';
                if(!Fempty(city) && city.length==6){
                        tmp['sProv']=city.substr(0,2);
                        tmp['sCity']=city.substr(0,4);
                        tmp['sProv']=parseInt(tmp['sProv']);
                        /*if(tmp['sProv']==99)
                        {
                                //alert('目前不支持海外的国家的搜索.');
                                tmp['sProv']=11;
                                tmp['sCity']=1100;
                        }*/
                }
                tmp['age']=getAge(tmp.birthday);
                tpl.setBlockVars('list',tmp);
                tpl.parseBlock('list');
        }
        for(var i=startPage;i<=endPage;i++)
        {
                var tmp=(i==curPage)?'<a href="javascript:goPage('+i+')" class="thispage">'+i+'</a>':'<a href="javascript:goPage('+i+')">'+i+'</a>';
                tpl.setBlockVar('page','pageNum',tmp);
                tpl.parseBlock('page');
        }
        tpl.parse();
        tpl.show('search_list');

}
===
function loadData(){
        var arg=((!Fempty(location.hash)&&location.hash!='#')?FgetHashURLArgs():FgetURLArgs());
        var act=(Fempty(arg.act)?'page':arg.act);
        if(act!='' && act!='birth' && act!='qq') act='page';
        var prov=parseInt(arg.province);
        if(prov==99) {
                Fid('search_list').innerHTML='<div class="status_box"><p><strong>目前不支持海外的国家的搜索。</strong></p></div>';
                return;
        }
        var city=parseInt(arg.city);
        var page=parseInt(arg.page);
        prov=(prov>0?prov:11);
        city=(city>0?city:0);
        page=(page>0?page:1);
        var sex=parseInt(arg.sex);
        sex=(sex>0?sex:0);
        var age=parseInt(arg.age);
                age=(age>=0?age:2);
        var sort=parseInt(arg.sort);
        if(isNaN(sort)) sort=0;
        var url='';
        if(act=='qq'){
                if (vaildateUin(arg.uin)){
                        url='http://city.qzone.qq.com/json.php?mod=search&act=qq&uin='+arg.uin+'&callback=showSearchResult';
                }else{
                        showErr(-1);
                }
        }else if(act=='birth'){
                var year=parseInt(arg.year);
                year=(year>0?year:0);
                var month=parseInt(arg.month);
                month=(month>0?month:0);
                var day=parseInt(arg.day);
                day=(day>0?day:0);        url='http://city.qzone.qq.com/json.php?mod=search&act=birth&province='+prov+'&city='+city+'&sex='+sex+'&sort='+sort+'&year='+year+'&month='+month+'&day='+day+'&page='+page+'&callback=showSearchResult';
        }else{        url='http://city.qzone.qq.com/json.php?mod=search&act=page&province='+prov+'&city='+city+'&age='+age+'&sex='+sex+'&sort='+sort+'&page='+page+'&callback=showSearchResult';
        }
        setRunTimeout(FsetValueOfRadio,1,'sex',sex);
        if(!Fempty(url)){
                FloadJS(url,'','');
        }
        FsetValuesOfSelect('province',prov,true);
        FsetValuesOfSelect('age',age,true);
        setSearchCity('province','city','',true);
        FsetValuesOfSelect('city',city,true);
}
===
function Ftemplate(tpl,dataObj,unknowns){
this.tpl=tpl;
this.result='';
this.dataObj=dataObj;
this.unknowns=(Fempty(unknowns)?'remove':unknowns);
this.blocks=new FhashMap();
this.vars=new FhashMap();}
Ftemplate.prototype.toString=function(){
this.dataToHTML(this.dataObj);
return this.result;}
Ftemplate.prototype.dataToHTML=function(data,node){
for(var key in data){
var arr=data;
arr=arr==undefined?'':arr;
if(Fis(arr,'array')){
if(Fempty(this.blocks.get(key))){
this.setBlock(Fempty(node)?'':node,key,'__'+key+'__');}
var len=arr.length;
for(var i=0;i<len;i++){
this.dataToHTML(arr,key);}}else{
if(Fempty(node)){
this.setVar(key,arr);}else{
this.setBlockVar(node,key,arr);}}}
if(!Fempty(node)){
this.parseBlock(node);}else{
this.parse();}}
Ftemplate.prototype.setData=function(dataObj){
this.dataObj=dataObj;}
Ftemplate.prototype.setVar=function(tagName,tagVal,append){
var v=this.vars.get(tagName);
v=((!Fempty(v)&&(append==true))?(v+tagVal):tagVal);
this.vars.put(tagName,v,true);}
Ftemplate.prototype.setVars=function(obj,append){
for(key in obj){
this.setVar(key,obj,append);}}
Ftemplate.prototype.clearVar=function(tagName,tagVal){
this.vars.remove(tagName);}
Ftemplate.prototype.setBlockVar=function(blockName,tagName,tagVal){
this.blocks.get(blockName).vars.put(tagName,tagVal,true);}
Ftemplate.prototype.setBlockVars=function(blockName,obj){
for(key in obj)
this.blocks.get(blockName).vars.put(key,obj,true);}
Ftemplate.prototype.clearBlockAllVar=function(blockName){
var _vars=this.blocks.get(blockName).vars;
for(var k in _vars.data)_vars.data='';}
Ftemplate.prototype.clearBlockVar=function(blockName,tagName){
this.blocks.get(blockName).vars.data='';}
Ftemplate.prototype.setBlock=function(parent,blockName,targetVar){
var _parent=Fempty(parent)?this:this.blocks.get(parent);
var _tpl=this._getBlock(_parent.tpl,blockName);
_parent.tpl=this._blockReplace(_parent.tpl,blockName,targetVar);
this.blocks.put(blockName,{'parent':parent,'targetVar':targetVar,'tpl':_tpl,'vars':new FhashMap()});
_parent.vars.put(targetVar,"");}
Ftemplate.prototype._blockReplace=function(tpl,blockName,targetVar){
var _tpl='';
var r1=tpl.match((new RegExp("<!--(\\s)*BEGIN(\\s)+"+blockName+"(\\s)*-->","")));
var r2=tpl.match((new RegExp("<!--(\\s)*END(\\s)+"+blockName+"(\\s)*-->","")));
_tpl=tpl.substr(0,r1.index);
_tpl+='{'+targetVar+'}';
_tpl+=tpl.substr((r2.index+r2.length));
return _tpl;}
Ftemplate.prototype._getBlock=function(tpl,blockName){
var r1=tpl.match((new RegExp("<!--(\\s)*BEGIN(\\s)+"+blockName+"(\\s)*-->","")));
var r2=tpl.match((new RegExp("<!--(\\s)*END(\\s)+"+blockName+"(\\s)*-->","")));
r1LastIndex=r1.index+r1.length;
return tpl.substr(r1LastIndex,(r2.index-r1LastIndex));}
Ftemplate.prototype.parse=function(){
this.result=this.tpl;
for(key in this.vars.data){
this.result=this.result.replace((new RegExp('\\{'+key+'\\}','ig')),(''+this.vars.data).replace(/\$/g,'$$$$'));}
return this.result;}
Ftemplate.prototype.parseBlock=function(tagName,append){
var block=this.blocks.get(tagName);
var _tpl=block.tpl;
for(key in block.vars.data){
_tpl=_tpl.replace((new RegExp('\\{'+key+'\\}','ig')),(''+block.vars.data).replace(/\$/g,'$$$$'));}
var _vars=((Fempty(block.parent))?this.vars:this.blocks.get(block.parent).vars);
var v=_vars.get(block.targetVar);
append=(Fempty(append)?true:append);
v=((!Fempty(v)&&append==true)?(v+_tpl):_tpl);
_vars.put(block.targetVar,v,true);
this.clearBlockAllVar(tagName);
return v;}
Ftemplate.prototype.parseBlocks=function(tagName,data,append){
if(!isArray(data)){
if(data==undefined)return;
this.setBlockVars(tagName,data);
this.parseBlock(tagName,append);
return;}
for(var i=0;i<data.length;i++){
if(data==undefined)continue;
this.setBlockVars(tagName,data);
this.parseBlock(tagName,append);}}
Ftemplate.prototype.show=function(id,append){
var obj=Fid(id);
if(!Fempty(this.dataObj)){
this.dataToHTML(this.dataObj);}
obj.innerHTML=((append!=true)?this.result:(obj.innerHTML+this.result));}
function cityLoginForm(){
window.top.qq_login_form(15000102,'http://city.qzone.qq.com/html/login_state.htm','','mask_iframe');}
function cityLoginForm2(){
window.top.qq_login_form(15000102);}

chenfy 发表于 2008-10-11 07:50:39

唉,看一条一条去分析是挺有意思的,可是现在却看不懂

54clz 发表于 2008-10-11 08:33:02

原帖由 冲锋火车头 于 2008-10-10 15:47 发表 http://bbs.locoy.com/images/common/back.gif
楼上的4个车厢怎么来的啊 我都混了1年了 才1个车厢

我混了两年啦   注册时间 2006-9-15

54clz 发表于 2008-10-11 08:39:22

非常感谢各位热心的朋友 !!!!!!!!!!!!

54clz 发表于 2008-10-11 08:46:49

原帖由 faunus 于 2008-10-10 23:52 发表 http://bbs.locoy.com/images/common/back.gif
用到标准函数库
http://imgcache.qq.com/qzone/city/js/newCity.js?20080715
重点函数
function Ftemplate(tpl,dataObj,unknowns);



faunus 很高手,讲了很多,谢谢!
现在还不怎么看得懂,收藏慢慢研究

AUTOIT不大熟
看来只能用VB写个小程序模拟键盘操作然后入库了就是效率低点


再次感谢!

faunus 发表于 2008-10-13 23:35:54

原帖由 54clz 于 2008-10-11 08:46 发表 http://bbs.locoy.com/images/common/back.gif




faunus 很高手,讲了很多,谢谢!
现在还不怎么看得懂,收藏慢慢研究

AUTOIT不大熟
看来只能用VB写个小程序模拟键盘操作然后入库了就是效率低点


再次感谢!

己解决,详见:
http://bbs.locoy.com/spider-31011-1-1.html
VB写个小程序模拟键盘,不如用AUTOIT,模拟上网和键盘是他的强项。
页: 1 [2]
查看完整版本: 什么技术呀 查看源码看不到要采的列表内容的 热心的朋友看看