define(function (require, exports, module) { function e() { } var a, t, i, n, o, r; a = require("common"), t = require("translator"), i = require("dialog"), n = require("utils"), r = require("isapi/device"), o = { ok: t.getValue("TestSuccess"), "connect server fail": t.getValue("ConnectServerFail"), "no nas directory": t.getValue("NoNasDirectory"), "no permission": t.getValue("NoNasPermission"), "no dns": t.getValue("NoDns"), "no gateway": t.getValue("NoGateway"), "password error": t.getValue("PasswordError"), "exchange server fail": t.getValue("ExchangeServerFail"), "create directory failed": t.getValue("CreateDirectoryFail"), "no write permission": t.getValue("NoWritePermission"), "port error": t.getValue("portError"), "user or password error": t.getValue("loginError"), "no storage pool": t.getValue("StoragePoolError"), "storage pool full": t.getValue("StoragePoolFull"), "unknown error": t.getValue("UnknownError") }, e.prototype = { saveState: function (e, a, o) { var s = this; (void 0 === a || null === a) && (a = ""); var l = !1, c = "", u = ""; if (4 == e.readyState) if (200 == e.status || 403 == e.status || 400 == e.status || 503 == e.status || 500 == e.status) { var d = e.responseXML, m = n.nodeValue(d, "statusCode"), p = n.nodeValue(d, "subStatusCode"); if ("1" == m) u = 1 === o ? a + t.getValue("deleteSuccess") : 2 === o ? a + t.getValue("restoreSucceeded") : a + t.getValue("saveSucceeded"); else if ("2" == m) u = "noMemory" === p ? a + t.getValue("deviceBusy") : "serviceUnavailable" === p ? a + t.getValue("deviceBusy") : "upgrading" === p ? a + t.getValue("deviceBusy") : "deviceBusy" === p ? a + t.getValue("deviceBusy") : "reConnectIpc" === p ? a + t.getValue("switchANR") : a + t.getValue("deviceBusy"); else if ("3" == m) u = "28181Uninitialized" === p ? a + t.getValue("param28181Uninitialized") : a + t.getValue("deviceError"); else if ("4" == m) "notSupport" === p ? u = a + t.getValue("notSupport") : "lowPrivilege" === p ? u = a + t.getValue("noPermission") : "badAuthorization" === p ? u = a + t.getValue("userPwdError") : "methodNotAllowed" === p ? u = a + t.getValue("methodError") : "notSetHdiskRedund" === p ? u = a + t.getValue("requiredOneRWHDD") : "invalidOperation" === p ? u = a + t.getValue("invalidOperation") : "ptzOccupiedPriority" === p ? u = a + t.getValue("ptzOccupiedPriority") : "TransparentMutexPTZ485" === p ? u = a + t.getValue("transparentMutexPTZ485") : "highFrame1080PMutexSMDNoiseReduceWDROrCorridor" === p ? (l = !0, u = a + t.getValue("mutexHighFrame"), c = p) : "SMDNoiseReduceWDROrCorridorMutexHighFrame1080P" === p ? (l = !0, u = a + t.getValue("mutexSMDNoiseReduceWDROrCorridor"), c = p) : "highFrame720PMutexWDROrCorridor" === p ? (l = !0, u = a + t.getValue("mutexHighFrame"), c = p) : "WDROrCorridorMutexHighFrame720" === p ? (l = !0, u = a + t.getValue("mutexWDROrCorridor"), c = p) : "WDRMutexDDSOrDehaze" === p ? (l = !0, u = a + t.getValue("mutexWDRDDSOrDeHaze"), c = p) : "DDSOrdehazeMutexWDR" === p ? (l = !0, u = a + t.getValue("mutexDDSorDeHaze"), c = p) : "HLCMutexWDROrDehaze" === p ? (l = !0, u = a + t.getValue("mutexHLC"), c = p) : "WDROrDehazeMutexHLC" === p ? (l = !0, u = a + t.getValue("mutexWDROrDeHaze"), c = p) : "highFrame1080PMutexWDROrCorridor" === p ? (l = !0, u = a + t.getValue("mutexHighFrame"), c = p) : "WDROrCorridorMutexHighFrame1080P" === p ? (l = !0, u = a + t.getValue("mutexWDROrCorridor"), c = p) : "imageFlipMutexHighFrame1080P" === p ? (l = !0, u = a + t.getValue("mutexImageFlip"), c = p) : "highFrame1080PMutexImageFlip" === p ? (l = !0, u = a + t.getValue("mutexHighFrame"), c = p) : "MutexWithHighFrame1080P" === p ? (l = !0, u = a + t.getValue("mutexHighFrame"), c = p) : "MutexWithWDR" === p ? (l = !0, u = a + t.getValue("mutexWDR"), c = p) : "MutexWithSMD" === p ? (l = !0, u = a + t.getValue("mutexSMD"), c = p) : "MutexWithPDC" === p ? (l = !0, u = r.m_oDeviceCapa.bSupportPeopleCount.bSptObjCount ? a + t.getValue("mutexCount") : a + t.getValue("mutexPDC")) : "MutexWithLensDistortionCorrection" === p ? (l = !0, u = a + t.getValue("mutexLensCorrection"), c = p) : "MutexWithVehicleDetection" === p || "MutexWithHVTVehicleDetection" === p ? (l = !0, u = a + t.getValue("mutexVehicleDetect"), c = p) : "MutexWithStream3" === p ? (l = !0, u = a + t.getValue("mutexVehicleDetect"), c = p) : "MutexWithFaceDetection" == p ? (l = !0, u = a + t.getValue("mutexFace"), c = p) : "invalidDisplayParameterSwitch" === p ? (l = !0, u = a + t.getValue("mutexDisplayParameterSwitch"), c = p) : "MutexWithDualVCAAndSMD" === p ? (l = !0, u = a + t.getValue("mutexWithDualVCAAndSMD"), c = p) : "MutexWithEIS" === p ? (l = !0, u = a + t.getValue("MutexWithEIS"), c = p) : "MutexWithCoord" === p ? (l = !0, u = a + t.getValue("MutexWithCoorid"), c = p) : u = "invalidDayNightScheduledSwitch" === p ? a + t.getValue("invalidDayNightScheduledSwitch") : a + t.getValue("setParamFailed"); else if ("5" == m) u = a + t.getValue("paramError"); else if ("6" == m) u = "badParameters" === p ? a + t.getValue("paramError") : "badHostAddress" === p ? a + t.getValue("ipAddrError") : "badXmlContent" === p ? a + t.getValue("paramError") : "badIPv4Address" === p ? a + t.getValue("ipAddrError") : "badIPv6Address" === p ? a + t.getValue("ipAddrError") : "conflictIPv4Address" === p ? a + t.getValue("ipAddrConflicted") : "conflictIPv6Address" === p ? a + t.getValue("ipAddrConflicted") : "badDomainName" === p ? a + t.getValue("domainError") : "connectSreverFail" === p ? a + t.getValue("communicationFailed") : "conflictDomainName" === p ? a + t.getValue("domainConflicted") : "badPort" === p ? a + t.getValue("portConflict") : "portError" === p ? a + t.getValue("invalidPort") : "badNetMask" === p ? a + t.getValue("subnetMaskError") : "badVersion" === p ? a + t.getValue("versionMismatch") : "badDevType" === p ? a + t.getValue("modelMismatch") : "badLanguage" === p ? a + t.getValue("lanMismatch") : "invalidChannel" === p ? a + t.getValue("confirmCamera") + " " + t.getValue("cameraExist") : "noAudioStream" === p ? a + t.getValue("confirmCamera") + " " + t.getValue("videoAndAudio") : "noRecAudio" === p ? a + t.getValue("confirmCamera") + " " + t.getValue("recordAudio") : "noAudio" === p ? a + t.getValue("confirmCamera") + " " + t.getValue("recordAudio") + ", " + t.getValue("videoAndAudio") : "mismatchedPassword" === p ? a + t.getValue("rwPswMismatch") : "SNMPv3PasswordNone" === p ? a + t.getValue("SNMPv3PasswordNone") : "unableCalibrate" === p ? a + t.getValue("unableCalibrate") : "pleaseCalibrate" === p ? a + t.getValue("pleaseCalibrate") : "SNMPv3NameDifferent" === p ? a + t.getValue("SNMPv3NameDifferent") : "SNMPv3PasswordNone" === p ? a + t.getValue("SNMPv3PasswordNone") : "unableCalibrate" === p ? a + t.getValue("unableCalibrate") : "pleaseCalibrate" === p ? a + t.getValue("pleaseCalibrate") : "SNMPv3NameDifferent" === p ? a + t.getValue("SNMPv3NameDifferent") : "illegalVerificationCode" === p ? t.getValue("modifyDefaultCodeTip") + " " + a : "lackVerificationCode" === p ? t.getValue("createDefaultCodeTip") + " " + a : a + t.getValue("paramError"); else { if ("7" == m) return u = "", i.confirm(t.getValue("rebootDeviceTip"), null, function () { s.toRestart() }), void 0; "51" == m && (u = "openSigNoOp" === p ? a + t.getValue("openSigNoOp") : a + t.getValue("paramError")) } "hasActivated" === p && (u = a + t.getValue("deviceActived")) } else u = a + t.getValue("invalidUrlOrHttp"), c = "error"; return "" != u && (l ? i.alert(u) : i.tip(u)), c }, getState: function (e) { if (4 == e.readyState) { var a = ""; if (403 == e.status || 400 == e.status || 503 == e.status || 500 == e.status) { var o = e.responseXML, r = n.nodeValue(o, "statusCode"), s = n.nodeValue(o, "subStatusCode"); a = "4" == r ? "notSupport" === s ? t.getValue("notSupport") : t.getValue("networkAbnormal") : "3" == r ? "28181Uninitialized" === s ? t.getValue("param28181Uninitialized") : t.getValue("networkAbnormal") : t.getValue("networkAbnormal") } else a = t.getValue("networkAbnormal"); i.alert(a) } }, restart: function () { var e = this; i.confirm(t.getValue("rebootDeviceTip"), null, function () { e.toRestart() }) }, toRestart: function () { var e = this, o = null; o = i.wait(null, t.getValue("rebooting")), WebSDK.WSDK_SetDeviceConfig(a.m_szHostName, "restart", null, { success: function (a, t, i) { "OK" == n.nodeValue(t, "statusString") ? setTimeout(function () { e.reconnect(o) }, 6e4) : (o.close(), e.saveState(i)) }, error: function (a, t, i) { o.close(), e.saveState(i) } }) }, reconnect: function (e) { var t = this, i = (new Date).getTime(); WebSDK.WSDK_GetDeviceConfig(a.m_szHostName, "login", {timeStamp: i}, { success: function () { e.close(), window.location.reload() }, error: function () { setTimeout(function () { t.reconnect(e) }, 5e3) } }) }, test: function (e, n, r) { var s = i.wait(null, t.getValue("Testing")), l = "", c = this, u = "POST"; "message" === e && (u = "PUT"), WebSDK.WSDK_SetDeviceConfig(a.m_szHostName, e, n, { processData: !1, data: r, type: u, success: function (e, a) { setTimeout(function () { s.close(), l = $(a).find("errorDescription").eq(0).text(), l ? o[l] !== void 0 ? i.tip(o[l]) : i.tip(t.getValue("UnknownError")) : i.tip(t.getValue("TestSuccess")) }, 2e3) }, error: function (e, a, n) { setTimeout(function () { s.close(), "timeout" === n.statusText ? i.tip(t.getValue("TestFailed")) : c.saveState(n) }, 2e3) } }) } }, module.exports = new e });