telecom js
telecom项目
var G = {
html: {content:"<tr><td height='10'></td></tr><tr><td ><a href='#' class='listtitle_g' >在<span class='listtitle_o'>网络时代</span>信息是堵不住的</a><span id='sen_datetime' class='text'> [2011-07-27 16:00:23]</span></td> </tr> <tr> <td id='sen_content' class='text'><span class='text_o'>网络</span>使得信息</td></tr> <tr><td ><a href='#' class='listtitle_s'>http://roll.sohu.com/20110625/n311663518.shtml</a></td></tr><tr><td height='8' ></td> </tr> <tr> <td height='1' bgcolor='#cecece' ></td> </tr>"
},
cgi: {
telecom_query : "http://222.68.223.242/telecom/cgi/telecom_query.php"
}
};
$(document).ready(function()
{
//alert(conditions.tiezhi[or]);
xmlstart();
initialize();
page_load();
})
$(function() {
$( ".input02" ).datepicker();
$( ".input02" ).datepicker( "option", "dateFormat", "yy-mm-dd");
});
$(document).keypress(function(e){ //页码回车
var curKey = e.which;
if(curKey == 13)
{
var pagestr;
if($('#num_table_buttom .input').val() == "")
{
pagestr = $('#num_table .input').val();
}
else
{
pagestr = $('#num_table_buttom .input').val();
}
var page_num = parseInt(pagestr);
page.gopage(page_num);
}
})
function page_load()
{
hotsearch(G.cgi.telecom_query+"?key=&area=&type=inquiries&company=&entity=&timename=&page=1");
}
function content_draw(json)
{
$("#datetabel").html("");
var i ;
for(i = 0; i < json.feedback.length; i++)
{
$("#datetabel").append(G.html.content);
}
for(i = 0; i < json.feedback.length; i++)
{
$('#datetabel .listtitle_g:eq('+ i +')').html(getString(json.feedback[i].sen_title, 20));
$('#datetabel .listtitle_g:eq('+ i +')').attr("href",json.feedback[i].sen_url);
$('#datetabel #sen_datetime:eq('+ i +')').html( " ["+json.feedback[i].sen_datetime+"]");
$('#datetabel #sen_content:eq('+ i +')').html(getString(json.feedback[i].sen_sen, 50));
$('#datetabel .listtitle_s:eq('+ i +')').html(json.feedback[i].sen_url);
}
}
function telecom_callback(json)
{
if(json.feedback.length > 0)
{
content_draw(json);
page.set(json.info_total_page);
}
}
function hotsearch(index)
{
gScriptObj = document.createElement("script");
gScriptObj.setAttribute("type", "text/javascript");
gScriptObj.setAttribute("charset", "utf-8");
gScriptObj.setAttribute("src", index); //index为ajax需要访问的url地址
headObj = document.getElementsByTagName("head").item(0);
headObj.appendChild(gScriptObj);
}
function initialize() {
var latlng = new google.maps.LatLng(31.2, 121.4);
var myOptions = {
zoom: 8,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var marker = new google.maps.Marker({
position: latlng,
map: map,
title:"Hello World!"
});
}
function getString(s,n){
var count = 0;
var i = 0;
while(count < n && i < s.length)
{
if(s.charCodeAt(i) > 255)
{
count++;
}
i++;
}
var ins = String.fromCharCode(160);
ins = new RegExp(ins, "g");
s = s.replace(ins, "");
return s.substring(0,i);
}
function xmlstart()
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
//sortname = encodeURI(sortname);
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
//sortname = encodeURI(sortname);
}
}
var page = { //右方页码标签类
page: 1,
start: 1,
lens: 8,
end: 12,
sl: 1,
max: 100,
html: { pre:"<td><a href='javascript:void(0)'><img src='images/right003.gif' border='0' hspace='8' onclick='page.prepage()'></a></td>",
num:"<td background='images/right005.gif' width='19' height='19' align='center' class='page_range'><a href='javascript:void(0)' class='right006'>4</a></td>",
space:"<td width='3'></td>",
sl:"<td width='18'>...</td> ",
next:" <td><a href='javascript:void(0)'><img src='images/right002.gif' border='0' hspace='5' onclick='page.nextpage()'></a></td><td width='42' class='page_count'>共12页</td><td>到 <input name='Input' type='text' value='' class='input' onclick='this.value='';focus()' style='width:20px; height:12px;'/>页</td>"
// next:" <td><a href='javascript:void(0)'><img src='images/right002.gif' border='0' hspace='5' onclick='page.nextpage()'></a></td><td width='42'>共12页</td><td>到 <input name='Input' type='text' value='' class='page_inputs' onclick='this.value='';focus()' id='' style='width:20px; height:12px;'/>页</td>"
},
gopage: function(page)
{
if(this.can_fanye(page))
{
this.search(page);
}
},
prepage: function()
{
this.search(this.page - 1 );
},
nextpage: function()
{
this.search(this.page + 1 );
},
search: function(page)
{
if(this.can_fanye(page))
{
this.page = page;
hotsearch(G.cgi.telecom_query+"?key=&area=&type=inquiries&company=&entity=&timename=&page="+page);
}
},
can_fanye: function(page)
{
if(page >= 1 && page <= this.max)
{
return 1;
}
else
{
return 0;
}
},
value: function(max) //根据输入赋值
{
this.max = max;
if((this.page < this.start))
{
this.start = this.page;
this.sl = 1;
return;
}
if((this.page > (this.start + this.lens - 1)))
{
this.start = this.page;
}
if((this.start + 11) >= this.max)
{
this.start = this.max - this.lens;
this.sl = 0;
}
else
{
this.sl = 1;
if(this.page < this.start)
{
this.start = this.page;
}
if(this.page > (this.start + this.lens - 1))
{
this.start = this.page;
}
}
},
draw: function() //批量画页码
{
$('#num_table').html(this.html.pre);
var i = 0;
for(i = 0; i <= (this.lens - 1); i++)
{
$('#num_table').append(this.html.num);
$('#num_table').append(this.html.space);
}
if(this.sl == 1)
{
$('#num_table').append(this.html.sl);
}
$('#num_table').append(this.html.num);
$('#num_table').append(this.html.space);
$('#num_table').append(this.html.next);
$('#num_table_buttom').html($('#num_table').html());
},
set_num: function(table_id) //写页码信息
{
var i = 0;
for(i = 0; i <= (this.start + this.lens - 2); i++)
{
$('#'+ table_id +' .page_range:eq('+ i +') a').html(this.start + i );
}
if(this.sl)
{
$('#'+ table_id +' .page_range:eq('+ i +') a').html(this.start + i + 3 );
}
else
{
$('#'+ table_id +' .page_range:eq('+ i +') a').html(this.start + i + 1 );
}
$('#'+ table_id +' .page_count').html("共"+ this.max +"页");
//$('.page_range:eq(1)').attr("background", "images/right004.gif");
$('#'+ table_id +' .page_range:eq('+ (this.page - this.start) +')').attr("background", "images/right004.gif");
$('#'+ table_id +' .page_range a').each(function( i){
$(this).click(function(){
var num = parseInt($('#'+ table_id +' .page_range:eq('+ i +') a').html());
//alert(num);
page.gopage(num);
});
});
},
set: function(max)
{
this.value(max);
this.draw();
this.set_num("num_table");
this.set_num("num_table_buttom");
}
};
var conditions = {
tiezhi: {"不限": "",
"咨询": "inquiries",
"投诉": "complaints",
"其他": "other"
}
};
var company = {
name: "Microsoft",
product: "softwares",
chairman: {name: "Bill Gates", age: 53, Married: true},
employees: [{name: "Angel", age: 26, Married: false},
{name: "Hanson", age: 32, Marred: true}],
readme: function() {document.write(this.name + " product " + this.product);}
};
完