獲取資訊版本1

瓜瓜東西發表於2014-11-11
<%@ 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">
	var savenews = {
		flg : -1,
		type : [ {
			"id" : "1",
			"type" : "tech"
		}, {
			"id" : "2",
			"type" : "zhengzhi"
		}, {
			"id" : "3",
			"type" : "jingji"
		}, {
			"id" : "4",
			"type" : "shehui"
		}, {
			"id" : "5",
			"type" : "youxi"
		}, {
			"id" : "6",
			"type" : "car"
		}, {
			"id" : "7",
			"type" : "go"
		}, {
			"id" : "8",
			"type" : "lvyou"
		} ,{
			"id" : "9",
			"type":"zonghe"
		}],
		qq : {
			saveqq : function() {

			},
		},
		csdn : {
			data : {
				tech:[],
			},
			tech : function() {
				var tech = [];
				$(".content_info h4 a").each(function(i, v) {
					var msg = {
						"url" : "",
						"title" : ""
					};
					msg.url = $(this).attr("href");
					msg.title = $(this).html();
					tech.push(msg);
				});
				savenews.csdn.data.tech=tech;
			},
			match : function(type) {
				eval(type)();//此句需要測試
			},
			savecsdn : function(types) {
				var ts = types.split(",");
				if (ts instanceof Array) {
					for ( var t in ts) {
						for ( var i = 0; i < savenews.type.length; i++) {
							if (savenews.type[i].id == ts[t]) {
								savenews.csdn.match("savenews.csdn." + savenews.type[i].type);
								break;
							}
						}
					}
					;
				}
			},
		},
		zonghe:{//360page
			data :{
				youlike:[],
				netmanager:[],
				all:[],
			},
			savezonghe:function(types){
				var ts = types.split(",");
				if (ts instanceof Array) {
					for ( var t in ts) {
						for ( var i = 0; i < savenews.type.length; i++) {
							if (savenews.type[i].id == ts[t]) {
								savenews.csdn.match("savenews.zhonghe." + savenews.type[i].type);
								break;
							}
						}
					}
					;
				}
			},
			zonghe:function(){
				//add youlike
				var youlikes = [];
				$(".iguess-bd .item").each(function(){
					var youlike ={
						subtitle:{
							title:"",
							url:"",
						},
						details:[],
					};
					youlike.subtitle = $(this).find(".subtitle a").text();
					$(this).find(".inner li a").each(function(){
						var t = {
								url:"",
								title:""
							}
						var href = $(this).attr("href");
						var title = $(this).text();
						t.url = href;
						t.title = title;
						youlike.details.push(t);
					});
					youlikes.push(youlike);
				});
				savenews.zonghe.data.youlike = youlikes;
				
				//add 
				var alls = []
				
			},
		},
		savedata : function(flg, types) {
			switch (flg) {
				case 1: {
					savenews.qq.saveqq(types);
				}
				case 2: {
					savenews.csdn.savecsdn(types);
					var temp = {
						tech:[],	
					};
					temp.tech = savenews.csdn.data.tech;
					$("#data").val(savenews.csdn.data);
					/*  $.ajax({
						url:"/testsign/CsdnDataServlet",
						type:'post',
						dataType:"json",
						async:false,
						data:temp,
						success:function(data){
							alert("success");
						},
					});   */
					//此處沒有springmvc環境,所以沒有用
				}
				case 3:{
					savenews.zonghe.savezonghe(types);
				}
			}
			//兩種方法提交,下面這種需要跳轉頁面,效果不太好
		 	$("#myform").action="/testsign/CsdnDataServlet";
			$("form").submit();  
		},
	};

	var test = {
		varparam : function(m) {
			m();
		},
		varp : function() {
			alert("helloworld");
		},
		abc : function() {
			test.varparam('test.varp');
		},
	};

	$(document).ready(function() {
		$("#datasubmit").click(function() {
			savenews.savedata($("#source").val, $("#types").val());
		});
	});
</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')">
	</form>
</body>
</html>


 

相關文章