ifeng code relax jquery main page phone Version2

瓜瓜東西發表於2014-11-25


<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.9.1.js"></script>
<script type="text/javascript">
	//phone ifeng news
	
	var ifeng = {
		baseuri:"http://i.ifeng.com",
		date:"",
		simdata:[],//只顯示標題,就一個
		dataS:{
			type:"simple",
			date:"",
			news:[],
		},
		data:{
			date:"",
			type:"normal",
			types:[],
			loopimg:"",
			frontnews:[],
			tiyu:[],
			caijing:[],
		},
		wrap:function(){
			ifeng.init();
			ifeng.initLoopimg();
		},
		init:function(sip){
			if(sip){
				ifeng.initSimple();
				return;
			}
			ifeng.initDate(sip);
			ifeng.initTypes();
			ifeng.initDetails();
			ifeng.submit(sip);
		},
		initDate:function(sim){
			var d = new Date();
			ifeng.date = d.getFullYear()+""+(d.getMonth()+1)+""+d.getDate();  
			if(sim){
				ifeng.dataS.date=ifeng.date;
			}else{
				ifeng.data.date=ifeng.date;
			}
		},
		submit:function(sip){
			var d = "";
			if(sip){
				d = ifeng.dataS;
			}else{
				d = ifeng.data;
			}
			$.ajax({
				url:"/testsign/IFengShoujiServlet",
				type:'post',
				dataType:"json",
				async:false,
				data:d,
				success:function(data){
					alert("success");
				},
			});
		},
		initSimple:function(){
			$("ul.n-t-list li a").each(function(i,n){
				var t = {
						uri:"",
						title:"",
					}
					t.uri = ifeng.baseuri+$(this).attr("href");
					t.title = $(this).text();
					ifeng.dataS.news[i] = t;
			});
		},
		initTypes:function(){
			$("nav_2014 a").each(function(i,n){
				var t = {
					uri:"",
					title:"",
				};
				t.uri=ifeng.baseuri+$(this).attr("href");
				t.title = $(this).text();
				ifeng.data.types[i] = t;
			});
		},
		initDetails:function(){
			$("ul.n-t-list").each(function(i,n){
				switch (i){
					case 0:{
						$(this).find("li a").each(function(j,m){
							var t = {
								uri:"",
								title:"",
							}
							t.uri = ifeng.baseuri+$(this).attr("href");
							t.title = $(this).text();
							ifeng.data.frontnews[j] = t;
						});
						break;
					}
					case 1:{
						break;
					}
					case 2:{//tiyu
						$(this).find("li a").each(function(j,m){
							var t = {
								uri:"",
								title:"",
							}
							t.uri = ifeng.baseuri+$(this).attr("href");
							t.title = $(this).text();
							ifeng.data.tiyu[j] = t;
						});
						break;
					}
					case 7:{
						$(this).find("li a").each(function(j,m){
							var t = {
								uri:"",
								title:"",
							};
							t.uri = ifeng.baseuri+$(this).attr("href");
							t.title = $(this).text();
							ifeng.data.caijing[j] = t;
						});	
						break;
					}
				}
					
			});
		},
	};
</script>
</head>
<body>
	<form id="myform" name="myform" action="/testsign/CsdnDataServlet">
		<input type="hidden" id="source" value="${source}" /> 
		<input type="hidden" id="types" value="${types}" /> 
		<input type="hidden" id="data" name="data" value="" /> 
		<input type="button" id="test" value="測試語法" onclick="test.abc()"> 
		<input type="button" id="datasubmit" value="開始解析上傳">
		<input type="submit" id="mysubmit" value="提交" >
		<input type="button" id="testdata" value="測試資料csdn" onclick="savenews.savedata(2,'1')">
		<input type="button" id="testdata" value="測試資料zonghe" onclick="savenews.savedata(3,'9')">
		<input type="button" id="testdata" value="測試資料phoneifeng" onclick="ifeng.init()">
	</form>
</body>
</html>



package com.wj.service.news.shouji;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

 
public class IFeng implements Serializable{
    
    private String date;// 格式 20140512
    private String type; // normal,simple
    private List<HashMap<String, String>> hotNews =  new ArrayList<HashMap<String, String>>();
    private List<HashMap<String, String>> tiyu =  new ArrayList<HashMap<String, String>>();
    private List<HashMap<String, String>> yule =  new ArrayList<HashMap<String, String>>();
    
    
    public List<HashMap<String, String>> getHotNews() {
        return hotNews;
    }

    public List<HashMap<String, String>> getTiyu() {
        return tiyu;
    }

    public List<HashMap<String, String>> getYule() {
        return yule;
    }

    List<HashMap<String, String>> simData =
        new ArrayList<HashMap<String, String>>();
    
    public String getDate() {
        return date;
    }
    
    public void setDate(String date) {
        this.date = date;
    }
    
    public String getType() {
        return type;
    }
    
    public void setType(String type) {
        this.type = type;
    }
    
    public List<HashMap<String, String>> getSimData() {
        return simData;
    }
    
    public void init() {
        if (type != null && type == "simple") {
            
        }
        else {
        }
    }
    
    public void addSimData(HashMap map){
        simData.add(map);
    }
    
    public void addHotNews(HashMap map){
        hotNews.add(map);
    }
    public void addTiyuNews(HashMap map){
        tiyu.add(map);
    }
    public void addYuleNews(HashMap map){
        yule.add(map);
    }
}



public void seri(IFeng feng){
   try {
       ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("D:/serial/"+feng.getDate()+feng.getType()+".obj"));
            out.writeObject(feng);
            out.close();
   }
        catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
}


相關文章