blob: 02f12b41efdb1d0e2d840ca13ae39761439a678f [file] [log] [blame]
var webdav_arrayTableDataAccount = new Array(0);
(function($) {
$.fn.objWebDavmanagement = function(InIt) {
this.onLoad = function(flag) {
LoadWebPage("//192.168.1.1/html/router/webdav_management.html");
document.getElementById("webdavSettingtitle").innerHTML = jQuery.i18n.prop("webdavSettingtitle");
document.getElementById("webdavmangementtitle").innerHTML = jQuery.i18n.prop("webdavmangementtitle");
document.getElementById("webdavSetting").value = jQuery.i18n.prop("webdavSetting");
document.getElementById("SDcardShareSettingInfoDlgTitle").innerHTML = jQuery.i18n.prop("SDcardShareSettingInfoDlgTitle");
//document.getElementById("setting_method").innerHTML = jQuery.i18n.prop("setting_method");
//document.getElementById("WebDavmode").innerHTML = jQuery.i18n.prop("WebDavmode");
//document.getElementById("Usbmode").innerHTML = jQuery.i18n.prop("Usbmode");
document.getElementById("setting_shared_enable").innerHTML = jQuery.i18n.prop("setting_shared_enable");
document.getElementById("shared_open").innerHTML = jQuery.i18n.prop("shared_open");
document.getElementById("shared_close").innerHTML = jQuery.i18n.prop("shared_close");
document.getElementById("setting_shared_mode").innerHTML = jQuery.i18n.prop("setting_shared_mode");
document.getElementById("read_mode_show").innerHTML = jQuery.i18n.prop("read_mode_show");
document.getElementById("readwrite_mode_show").innerHTML = jQuery.i18n.prop("readwrite_mode_show");
document.getElementById("webdav_lUsername").innerHTML = jQuery.i18n.prop("webdav_lUsername");
document.getElementById("webdav_lPassword").innerHTML = jQuery.i18n.prop("webdav_lPassword");
document.getElementById("webdav_lRePassword").innerHTML = jQuery.i18n.prop("webdav_lRePassword");
document.getElementById("setting_stcCancelView").innerHTML = jQuery.i18n.prop("btnModalCancle");
webdav_arrayTableDataAccount = new Array(0);
var indexAccount = 0;
var _router_username='';
var _router_password='';
var webdav_username_;
var webdav_password_;
var authority;
//GetWebDavManageInfo();
var retXml = PostXml("router","webdav_get_management_info");
var enable,shared_mode;
$(retXml).find("webdav_auth").each(function() {
webdav_username_ = decodeURIComponent($(this).find("username").text());
webdav_password_ = decodeURIComponent($(this).find("password").text());
authority = '1';
});
$(retXml).find("webdav_basic").each(function() {
enable = $(this).find("enable").text();
shared_mode = $(this).find("shared_mode").text();
});
// _router_username = decodeURIComponent($(this).find("webdav_username").text());
// _router_password = decodeURIComponent($(this).find("webdav_password").text());
//webdav_username_ = decodeURIComponent($(this).find("webdav_account_username").text());
//webdav_password_ = decodeURIComponent($(this).find("webdav_account_password").text());
webdav_arrayTableDataAccount[indexAccount] = new Array(3);
webdav_arrayTableDataAccount[indexAccount][0] = webdav_username_;
webdav_arrayTableDataAccount[indexAccount][1] = webdav_password_;
webdav_arrayTableDataAccount[indexAccount][2] = authority;
this.loadAccountTable(webdav_arrayTableDataAccount);
$("#webdavSetting").click(function() {
sm("webdavSettingDlg", 450, 150);
document.getElementById("lt_webdav_setting_btnSave").value = jQuery.i18n.prop("lt_btnApply");
var retXml = PostXml("router","webdav_get_management_info");
var enable,shared_mode;
//$(retXml).find("webdav_auth").each(function() {
// webdav_username_ = decodeURIComponent($(this).find("username").text());
// webdav_password_ = decodeURIComponent($(this).find("password").text());
// authority = '1';
//});
$(retXml).find("webdav_basic").each(function() {
enable = $(this).find("enable").text();
if(enable=="on")
{
WebdavSharedEnable=1;
$("#WebDavSharedClose").attr("checked", false);
$("#WebDavSharedOpen").attr("checked", true);
}
else
{
WebdavSharedEnable=0
$("#WebDavSharedClose").attr("checked", true);
$("#WebDavSharedOpen").attr("checked", false);
}
shared_mode = $(this).find("shared_mode").text();
if(shared_mode=="read_only")
{
WebdavSharedMode=1;
$("#readwrite_mode").attr("checked", false);
$("#read_mode").attr("checked", true);
}
else
{
WebdavSharedMode=0;
$("#readwrite_mode").attr("checked", true);
$("#read_mode").attr("checked", false);
}
});
//var xml = getData('webdav_management');
//$(xml).find("webdav_user_management").each(function() {
// var usb_flag=$(this).find("webdav_enable").text();
// if(usb_flag=="1")
// {
// WebdavUsbMode=1;
// $("#UsbSta").attr("checked", false);
// $("#WebDavSta").attr("checked", true);
// }
// else
// {
// WebdavUsbMode=0;
// $("#UsbSta").attr("checked", true);
// $("#WebDavSta").attr("checked", false);
// }
// });
$("#lt_webdav_setting_btnSave").click(function() {
//var itemIndex = 0;
//mapData = null;
//mapData = new Array();
//mapData = putMapElement(mapData, "RGW/webdav_user_management/webdav_enable", WebdavUsbMode, itemIndex++);
//if (mapData.length > 0) {
// webdav_postXML('webdav_management', g_objXML.getXMLDocToString(g_objXML.createXML(mapData)));
//}
var webdav_ConfigMap = new Map();
var curConfigMap = new Map();
//configMap.put("RGW/wireless/wifi_if_24G/switch","off");
//curConfigMap.put("RGW/webdav_set_management_info/webdav_auth/username","admin");
//curConfigMap.put("RGW/webdav_set_management_info/webdav_auth/password","admin");
if(WebdavSharedEnable){
curConfigMap.put("RGW/webdav_basic/enable","on");
}
else{
curConfigMap.put("RGW/webdav_basic/enable","off");
}
if(WebdavSharedMode){
curConfigMap.put("RGW/webdav_basic/shared_mode","read_only");
}
else{
curConfigMap.put("RGW/webdav_basic/shared_mode","read_write");
}
var configMap = curConfigMap.getChange(webdav_ConfigMap);
PostXml("router","webdav_set_basic_info",configMap);
hm();
});
});
}
this.loadAccountTable = function (arrayTableData){
var tableUserAccount = document.getElementById('tableUserAccount');
var tBodytable = tableUserAccount.getElementsByTagName('tbody')[0];
clearTabaleRows('tableUserAccount');
if (arrayTableData.length == 0) {
var row1 = tBodytable.insertRow(0);
var rowCol1 = row1.insertCell(0);
rowCol1.colSpan = 3;
rowCol1.innerHTML = jQuery.i18n.prop("tableNoData");
} else {
for (var i = 0; i < arrayTableData.length; i++) {
var arrayTableDataRow = arrayTableData[i];
var row = tBodytable.insertRow(-1);
var AccountNameCol = row.insertCell(0);
var AuthorityCol = row.insertCell(1);
// var removeCol = row.insertCell(2);
var _name = decodeURIComponent(arrayTableDataRow[0]);
AccountNameCol.innerHTML = "<a href='#' id ='table_username_link"+i+"' onclick='webdav_AccountClicked(" + i + ")'>" + _name + "</a>";
AuthorityCol.innerHTML = "<a href='#' id='table_remove_link"+i+"' onclick='webdav_deleteAccountItem(" + i + ")'>" +jQuery.i18n.prop("webdav_lEdit") + "</a>";
//if(arrayTableDataRow[2] == "1") {
// AuthorityCol.innerHTML = jQuery.i18n.prop("lStandard");
//} else
// AuthorityCol.innerHTML = jQuery.i18n.prop("lRestricted");
//removeCol.innerHTML = "<a href='#' id='table_remove_link"+i+"' onclick='webdav_deleteAccountItem(" + i + ")'>" +jQuery.i18n.prop("webdav_lEdit") + "</a>";
}
}
//Table.stripe(tableUserAccount, "alternate", "table-stripeclass");
}
this.getTableAccountDataRow = function(index) {
return webdav_arrayTableDataAccount[index];
}
this.postAccountItem = function(index, isDeleted, name, password, authority) {
var itemIndex = 0;
mapData = null;
mapData = new Array();
var login_username = encodeURIComponent(document.getElementById("tbrouter_username").value);
var login_password = encodeURIComponent(document.getElementById("tbrouter_password").value);
//edit or add
var item_name = encodeURIComponent(name);
var item_password = encodeURIComponent(password);
this.putMapElement("RGW/webdav_user_management/webdav_account_management/webdav_account_username", item_name, itemIndex++);
this.putMapElement("RGW/webdav_user_management/webdav_account_management/webdav_account_password", item_password, itemIndex++);
if (mapData.length > 0) {
postXML('webdav_management', g_objXML.getXMLDocToString(g_objXML.createXML(mapData)));
}
}
this.putMapElement = function(xpath, value, index) {
mapData[index] = new Array(2);
mapData[index][0] = xpath;
mapData[index][1] = value;
}
this.onPostSuccess = function() {
this.onLoad(true);
}
this.setXMLName = function(_xmlname) {
xmlName = _xmlname;
}
return this;
}
})(jQuery);
function webdavsetSdcardShareModeOK()
{
sm("PleaseWait",150,100);
$("#lPleaseWait").text(jQuery.i18n.prop("h1PleaseWait"));
setTimeout('logOut()',6000); //Ö¸¶¨5ÃëË¢ÐÂÒ»´Î
}
var WebdavSharedEnable=0;
var WebdavSharedMode=0;
function WebDav_shared_open_Setting()
{
$("#WebDavSharedOpen").attr("checked", true);
$("#WebDavSharedClose").attr("checked", false);
WebdavSharedEnable=1;
}
function WebDav_shared_close_Setting()
{
$("#WebDavSharedClose").attr("checked", true);
$("#WebDavSharedOpen").attr("checked", false);
WebdavSharedEnable=0;
}
function WebDav_shared_read_Setting()
{
$("#read_mode").attr("checked", true);
$("#readwrite_mode").attr("checked", false);
WebdavSharedMode=1;
}
function WebDav_shared_readwrite_Setting()
{
$("#readwrite_mode").attr("checked", true);
$("#read_mode").attr("checked", false);
WebdavSharedMode=0;
}
function webdav_localizeMBAccount() {
$("#webdav_h1AccountEdit").text(jQuery.i18n.prop("webdav_h1AccountEdit"));
document.getElementById("webdav_lAccountName").innerHTML = jQuery.i18n.prop("webdav_lUsername");
document.getElementById("webdav_lAccountPassword").innerHTML = jQuery.i18n.prop("webdav_lPassword");
document.getElementById("lReAccountPassword").innerHTML = jQuery.i18n.prop("lReAccountPassword");
document.getElementById("lAccountAuthority").innerHTML = jQuery.i18n.prop("lAccountAuthority");
document.getElementById("btnCancel").innerHTML = jQuery.i18n.prop("btnCancel");
//buttonLocaliztion(document.getElementById("btnOk").id);
}
function webdav_AccountClicked(index) {
sm("MBAccount_Popup", 450, 200);
webdav_localizeMBAccount();
var data = g_objContent.getTableAccountDataRow(index);
//var data=webdav_arrayTableDataAccount[index]
document.getElementById("webdav_txtAccountName").value = data[0];
document.getElementById("webdav_txtAccountPassword").value = data[1];
document.getElementById("webdav_txtReAccountPassword").value = decodeURIComponent(data[1]);
document.getElementById("AccountGroupSelect").value = data[2];
$("#AccountGroupSelect").attr("disabled",true);
bEditAccount = true; //edit
}
function webdav_btnOKClickedEditAccount() {
var AccountName, AccountPassword, AccountRePassword, AccountAuthority;
var webdav_ConfigMap = new Map();
AccountName = document.getElementById("webdav_txtAccountName").value;
AccountPassword = document.getElementById("webdav_txtAccountPassword").value;
AccountRePassword = document.getElementById("webdav_txtReAccountPassword").value;
AccountAuthority = document.getElementById("AccountGroupSelect").value;
if(!bEditAccount) { //add new account
for (var idx = 0; idx < _arrayTableDataAccount.length; ++idx) {
if (AccountName == _arrayTableDataAccount[idx][0]) {
document.getElementById('lTablePassErrorMes').style.display = 'block';
document.getElementById('lTablePassErrorMes').innerHTML = jQuery.i18n.prop('lAccountExist');
return;
}
}
}
if(document.getElementById('webdav_txtAccountPassword').value != document.getElementById('webdav_txtReAccountPassword').value) {
document.getElementById('lTablePassErrorMes').style.display = 'block';
document.getElementById('lTablePassErrorMes').innerHTML=jQuery.i18n.prop('lPassErrorMes');
document.getElementById("webdav_txtReAccountPassword").value = '';
} else {
document.getElementById('lTablePassErrorMes').style.display = 'none';
if(webdav_isValidAccountPage()) {
//document.getElementById('lTablePassErrorMes').style.display = 'none';
//g_objContent.postAccountItem(0,false, AccountName,AccountPassword,AccountAuthority);
var curConfigMap = new Map();
//configMap.put("RGW/wireless/wifi_if_24G/switch","off");
curConfigMap.put("RGW/webdav_auth/username",AccountName);
curConfigMap.put("RGW/webdav_auth/password",AccountPassword);
//curConfigMap.put("RGW/webdav_set_management_info/webdav_auth",AccountName);
var configMap = curConfigMap.getChange(webdav_ConfigMap);
PostXml("router","webdav_set_auth_info",configMap);
GetWebDavManageInfo();
}
hm();
}
}
function webdav_deleteAccountItem(index) {
webdav_AccountClicked(index);
}
function webdav_tablepasswordChanged() {
document.getElementById("webdav_txtReAccountPassword").value = '';
document.getElementById('lReAccountPassword').style.display = 'block';
document.getElementById('webdav_txtReAccountPassword').style.display = 'block';
}
function webdav_isValidAccountPage() {
if(!(textBoxMinLength("webdav_txtAccountName",4) && textBoxMinLength("webdav_txtAccountPassword",4))) {
document.getElementById('lTablePassErrorMes').style.display = 'block';
document.getElementById('lTablePassErrorMes').innerHTML = jQuery.i18n.prop('lminLengthError');
return false;
}
if(!(textBoxMaxLength("webdav_txtAccountName",20) && textBoxMaxLength("webdav_txtAccountPassword",20))) {
document.getElementById('lTablePassErrorMes').style.display = 'block';
document.getElementById('lTablePassErrorMes').innerHTML = jQuery.i18n.prop('lmaxLengthError');
return false;
}
if(!deviceNameValidation(document.getElementById('webdav_txtAccountName').value)) {
document.getElementById('lTablePassErrorMes').style.display = 'block';
document.getElementById('lTablePassErrorMes').innerHTML = jQuery.i18n.prop('ErrInvalidUserPass');
return false;
}
if(!deviceNameValidation(document.getElementById('webdav_txtAccountPassword').value)) {
document.getElementById('lTablePassErrorMes').style.display = 'block';
document.getElementById('lTablePassErrorMes').innerHTML = jQuery.i18n.prop('ErrInvalidUserPass');
return false;
}
return true;
}
function GetWebDavManageInfo() {
//var retXml = PostXml("embms","webdav_get_management_info");
//$(retXml).find("webdav_auth").each(function() {
// username = $(this).find("username").text();
// password = $(this).find("password").text();
//});
// $(retXml).find("webdav_basic").each(function() {
// enable = $(this).find("enable").text();
// shared_mode = $(this).find("shared_mode").text();
//});
var username,password,enable,shared_mode;
var indexAccount = 0;
var authority;
var retXml = PostXml("router","webdav_get_management_info");
var enable,shared_mode;
$(retXml).find("webdav_auth").each(function() {
username = decodeURIComponent($(this).find("username").text());
password = decodeURIComponent($(this).find("password").text());
authority = '1';
});
$(retXml).find("webdav_basic").each(function() {
enable = $(this).find("enable").text();
shared_mode = $(this).find("shared_mode").text();
});
webdav_arrayTableDataAccount[indexAccount] = new Array(3);
webdav_arrayTableDataAccount[indexAccount][0] = username;
webdav_arrayTableDataAccount[indexAccount][1] = password;
webdav_arrayTableDataAccount[indexAccount][2] = authority;
g_objContent.loadAccountTable(webdav_arrayTableDataAccount);
//GetWifiDetailedInfo();
//RefreshFreqBandData();
}
function GetWebDavPathInfo(path) {
var size;
var get_path_info;
var webdav_ConfigMap = new Map();
var curConfigMap = new Map();
curConfigMap.put("RGW/webdav_path/path",path);
var configMap = curConfigMap.getChange(webdav_ConfigMap);
var retXml = PostXml("router","webdav_get_path_info",configMap);
$(retXml).find("webdav_path").each(function() {
get_path_info = decodeURIComponent($(this).find("path").text());
});
size= parseInt(get_path_info);
return size;
}
function GetWebDavTimezoneInfo() {
//var size;
var value;
var webdav_ConfigMap = new Map();
var curConfigMap = new Map();
var timezone_info;
curConfigMap.put("RGW/webdav_path/path","/www/webdav");
var configMap = curConfigMap.getChange(webdav_ConfigMap);
var retXml = PostXml("router","webdav_get_path_info",configMap);
$(retXml).find("webdav_path").each(function() {
timezone_info = decodeURIComponent($(this).find("timezone").text());
});
/*
value=parseInt(timezone_info);
if(value>0){
timezone_hour =Math.floor(value/100);
}else
{
timezone_hour =Math.ceil(value/100);
}
timezone_min=value%100;
*/
}
function GMTToStr(time){
var date = new Date(time);
var Str=date.getFullYear() + '-' + (date.getMonth() + 1) + '-' +
date.getDate() + ' ' +
date.getHours() + ':' +
date.getMinutes() + ':' +
date.getSeconds();
return Str;
}
function WebDav_GetDate_By_DateStr(TimeDate)
{
return GMTToStr(TimeDate);
/*
var week=TimeDate.substr(0, 3);
var day=TimeDate.substr(5, 2);
var mon=TimeDate.substr(8, 3);
if(mon=="Jan") mon="01";
else if(mon=="Feb") mon="02";
else if(mon=="Mar") mon="03";
else if(mon=="Apr") mon="04";
else if(mon=="May") mon="05";
else if(mon=="Jun") mon="06";
else if(mon=="Jul") mon="07";
else if(mon=="Aug") mon="08";
else if(mon=="Sep") mon="09";
else if(mon=="Oct") mon="10";
else if(mon=="Nov") mon="11";
else if(mon=="Dec") mon="12";
var year=TimeDate.substr(12, 4);
var HMS=TimeDate.substr(17, 8);
var hour_str= HMS.substr(0, 2);
var min_str= HMS.substr(3, 2);
var sec_str= HMS.substr(6, 2);
var hour_value=parseInt(hour_str)+timezone_hour;
var min_value=parseInt(min_str)+timezone_min;
return year+"-"+mon+"-"+day+" "+hour_value.toString()+":"+min_value.toString()+":"+sec_str;
*/
}