Halil Han BADEM
kodların tamamı bu hocam
`var browsertype = 1; //浏览器类型
function KeyDownHandler(){
if (event.keyCode == 13){
event.returnValue=false;
event.cancel = true;
$("#btnsub").get(0).click();
}
}
function VersionCheck(obj)
{
var MSG = obj.msg;
if(window.console){
console.log(MSG);
}
}
//插件初始化完成回调
function pluginLoaded()
{
Activex = $_id("AntsNetActiveX");
if(Activex)
{
if(window.console)
{
console.log("pluginLoaded OK");
}
}
}
LOGIN = (function(){
return {
d : {},
ToString : function(){
/var str = '{';
str += '"ip":"'+this.d.ip+'",';
str += '"username":"'+this.d.username+'",';
str += '"pwd":"'+this.d.psw+'"';
str+='}';/
return JSON.stringify({
"ip":this.d.ip,
"username": this.d.username,
"pwd":this.psw
});
},
InitInterface : function(){
if (navigator.appName == 'Netscape'){
var language = navigator.language;}else{
var language = navigator.browserLanguage;}
langset = getCookie("s_Language");
browsertype = getCookie("s_browsertype");
if(langset == nulllangset == ""langset=="undefined"langset==0langset==1)
{
if (language.indexOf('zh') > -1) {langset = "zh_cn.js";}
if (language.indexOf('en') > -1) {langset = "en_gb.js";}
if(langset == ""){langset = "en_gb.js";}
SetCookie("s_Language",langset);
}
InitiaLanguage(langset);
SetCbbList($("#seLang").get(0),langset);
if(browsertype == null||browsertype == ""||browsertype=="undefined")
{
var u = navigator.userAgent;
if(u.indexOf('Trident')>0)
{
browsertype = 1;
//SetCbbList($("#setype").get(0),1);
$("#setype").val(1);
embedPlugin.embedSWF(document.getElementById("OCXAnts"),"AntsNetActiveX","100%","100%",{
"onload":"pluginLoaded",
"TYPE":"PREVIEW",
"CHNUM":1,
"VERSION":"8.0.0.0"
});
}
else if(u.indexOf('Firefox')>0)
{
browsertype = 1;
//SetCbbList($("#setype").get(0),1);
$("#setype").val(1);
embedPlugin.embedSWF(document.getElementById("OCXAnts"),"AntsNetActiveX","100%","100%",{
"onload":"pluginLoaded",
"TYPE":"PREVIEW",
"CHNUM":1,
"VERSION":"8.0.0.0"
});
}
else
{
browsertype = 2;
$("#setype").val(2);
$("#OCXAnts").html("");
$("#download").hide();
$_id("setype").options.remove(0);
}
}
else
{
//SetCbbList($("#setype").get(0),browsertype);
$("#setype").val(browsertype);
if(browsertype == 1)
{
embedPlugin.embedSWF(document.getElementById("OCXAnts"),"AntsNetActiveX","100%","100%",{
"onload":"pluginLoaded",
"TYPE":"PREVIEW",
"CHNUM":1,
"VERSION":"8.0.0.0"
});
}
else
{
$("#OCXAnts").html("");
// $("#download").css('display','none');
$("#download").hide();
}
}
if($("#txtusername").val() == ""){$('#txtusername').val(username);}
if($("#txtpassword").val() == ""){$('#txtpassword').val(psw);}
if($("#txtPort").val() == ""){$('#txtPort').val(port);}
if($("#txtusername").val() == ""){ $("#txtusername").val("admin");}
if($("#txtPort").val() == ""){ $("#txtPort").val("5050");}
LOGIN.CheckActivex();
//$('#imgwt').css({"display": "none"});
//$('#LinkAddress').css({"display": "none"});
},
CheckActivex : function(){
if(browsertype != 1){return true;}
Activex = $("#AntsNetActiveX");
if(Activex.get(0).DoInit != null)
{
// $("#download").css('display','none');
$("#download").hide();
return true;
}
else
{
$("#download").show();
document.getElementById("LinkAddress").click();
//$("#download").css('display','block');
}
return false;
},
ChangeLanguage : function(value){
SetCookie("s_Language", value);
InitiaLanguage(value);
},
ChangeBrowser : function(value){
browsertype = value;
SetCookie("s_browsertype", value);
if(value == 1)
{
embedPlugin.embedSWF(document.getElementById("OCXAnts"),"AntsNetActiveX","100%","100%",{
"onload":"pluginLoaded",
"TYPE":"PREVIEW",
"CHNUM":1,
"VERSION":"8.0.0.0"
});
}
else
{
$("#OCXAnts").get(0).innerHTML = "";
$("#download").hide();
//$("#download").css('display','none');
}
},
HandleLogin : function(){
if(browsertype==1)
{
Activex = $("#AntsNetActiveX");
if(Activex.get(0).DoInit == null)
{
if(browsertype == null||browsertype == ""||browsertype=="undefined")
{
var u = navigator.userAgent;
if(u.indexOf('Trident')>0)
{
browsertype = 1;
//SetCbbList($("#setype").get(0),1);
$("#setype").val(1);
embedPlugin.embedSWF(document.getElementById("OCXAnts"),"AntsNetActiveX","100%","100%",{
"onload":"pluginLoaded",
"TYPE":"PREVIEW",
"CHNUM":1,
"VERSION":"8.0.0.0"
});
}
else
{
browsertype = 2;
$("#setype").val(2);
$("#OCXAnts").html("");
$("#download").hide();
$_id("setype").options.remove(0);
}
}
else
{
//SetCbbList($("#setype").get(0),browsertype);
$("#setype").val(browsertype);
if(browsertype == 1)
{
embedPlugin.embedSWF(document.getElementById("OCXAnts"),"AntsNetActiveX","100%","100%",{
"onload":"pluginLoaded",
"TYPE":"PREVIEW",
"CHNUM":1,
"VERSION":"8.0.0.0"
});
}
else
{
$("#OCXAnts").html("");
// $("#download").css('display','none');
$("#download").hide();
}
}
}
}
if(!LOGIN.CheckActivex()){alert(g_login_13);return;}
var browserType = $("#setype").val();
SetCookie("s_browsertype", browserType);
if( browserType == 1) //IE浏览器
{
Activex = $("#AntsNetActiveX");
if(Activex.get(0).DoInit == null)
{
//$("#download").css('display','block');
alert(g_login_13);
return;
}
}
var langObj = $("#seLang");
SetCookie("s_Language", langObj.val());
var u = navigator.userAgent;
var addstr = GetUrlAddress();
if(addstr.length > 0)
{
$('#txtipaddress').val(addstr);
}
if($("#txtusername").val().length == 0)
{
alert(g_login_10);
$("#txtusername").focus();
return false;
}
LOGIN.d.username = $('#txtusername').val();
LOGIN.d.psw = $('#txtpassword').val();
LOGIN.d.ip = $('#txtipaddress').val();
//限制default用户
if(LOGIN.d.username.toUpperCase() =="DEFAULT")
{
alert(g_login_5);
return false;
}
$.ajax({
type: "POST",
contentType: "application/json",
url: LOGIN.uri,
data: JSON.stringify({
"param":{
"ip":this.d.ip,
"username": this.d.username,
"pwd":this.d.psw
}
}),
//timeout: 5000, //超时时间:30秒
dataType: 'json',
error: function(XMLHttpRequest, textStatus, errorThrown){
//TODO: 处理status, http status code,超时 408
// 注意:如果发生了错误,错误信息(第二个参数)除了得到null之外,还可能
//是"timeout", "error", "notmodified" 和 "parsererror"。
},
success: function(result) {
// TODO: check result
var dt = [];
dt = result;
if(dt.result == 0)
{
//处理cookie
SetCookie("s_ip", LOGIN.d.ip);
SetCookie("s_username", LOGIN.d.username);
SetCookie("s_psw", LOGIN.d.psw);
SetCookie("s_channum", dt.data[0]);
SetCookie("s_type", dt.data[1]);
SetCookie("s_httpport", dt.data[2]);
SetCookie("s_port", dt.data[3]);
SetCookie("s_sn", dt.data[4]);
SetCookie("s_alarmnum", dt.data[5]);
SetCookie("s_ipcchannum", dt.data[6]);
SetCookie("s_rtspport", dt.data[7]);
SetCookie("s_rtmpport", dt.data[8]);
window.location.href ="index.asp";
}
else
{
alert(g_login_5);
return;
}
}
});
}
};
}());
window.onload = function(){
LOGIN.uri = addstr+"//goform//frmUserLogin";
LOGIN.InitInterface();
$('#seLang').bind('change',function(){
LOGIN.ChangeLanguage($(this).val());
});
$('#setype').bind('change',function(){
LOGIN.ChangeBrowser($(this).val());
});
$('#btnsub').bind('click',function(){
LOGIN.HandleLogin();
});
};`