b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame^] | 1 | (function ($) { |
| 2 | |
| 3 | $.fn.objPinPuk = function (InIt) { |
| 4 | |
| 5 | var gpinpukubusobjname = "sim"; |
| 6 | var glastpinattempts; |
| 7 | var glastpukattempts; |
| 8 | var pinattempts; |
| 9 | var pinstatus ; |
| 10 | var simstatus ; |
| 11 | var pukattempts; |
| 12 | var pinenabled; |
| 13 | |
| 14 | LoadWebPage("//192.168.1.1/html/internet/pin_puk.html"); |
| 15 | |
| 16 | this.onLoad = function () { |
| 17 | |
| 18 | Refresh(); |
| 19 | var pinpukMap = new Map(); |
| 20 | var retXml = PostXml(gpinpukubusobjname, "get_sim_status", pinpukMap); |
| 21 | |
| 22 | if( $(retXml).find("setting_response").text()=="OK"){ |
| 23 | |
| 24 | pinattempts = $(retXml).find("pin_attempts").text(); |
| 25 | pinstatus = $(retXml).find("pin_status").text(); //<!--0: unkown 1: detected 2: need pin 3: need puk 5: ready--> |
| 26 | simstatus = $(retXml).find("sim_status").text(); //0: sim absent 1:sim present 2: sim error 3: unknown error |
| 27 | pukattempts = $(retXml).find("puk_attempts").text(); |
| 28 | pinenabled = $(retXml).find("pin_enabled").text(); |
| 29 | glastpinattempts = pinattempts; |
| 30 | glastpukattempts = pukattempts; |
| 31 | |
| 32 | }else{ |
| 33 | |
| 34 | showMsgBox(jQuery.i18n.prop("lFailedWithUnkown"),jQuery.i18n.prop("lPINResponseError")); |
| 35 | |
| 36 | } |
| 37 | |
| 38 | |
| 39 | document.getElementById("vPinAttmepts").innerHTML = jQuery.i18n.prop("lt_pinAttempts")+" "+pinattempts; |
| 40 | document.getElementById("vPukAttmepts").innerHTML = jQuery.i18n.prop("lt_pukAttempts")+" "+pukattempts; |
| 41 | |
| 42 | if(simstatus != "1") { |
| 43 | showAlert("lUnknownNoSIM"); |
| 44 | } |
| 45 | |
| 46 | |
| 47 | if(pinattempts == "0" && pukattempts == "0") { |
| 48 | showAlert("lPukExhausted"); |
| 49 | } |
| 50 | |
| 51 | |
| 52 | if(pinstatus == "3" && pukattempts != "0") { |
| 53 | showAlert("lPinExhausted"); |
| 54 | document.getElementById("PinPukAttempts").style.display="block"; |
| 55 | document.getElementById("ResetPinUsingPuk").style.display="block"; |
| 56 | } |
| 57 | |
| 58 | |
| 59 | if(pinstatus == "2"&&pinattempts!="0") { |
| 60 | document.getElementById("PinPukAttempts").style.display="block"; |
| 61 | document.getElementById("ProvidePin").style.display="block"; |
| 62 | |
| 63 | |
| 64 | } |
| 65 | |
| 66 | |
| 67 | if(pinstatus == "5") { |
| 68 | document.getElementById("PinPukAttempts").style.display="block"; |
| 69 | document.getElementById("EnableDisablePin").style.display="block"; |
| 70 | if(pinenabled == "0") { |
| 71 | document.getElementById("lt_EnableDisablePin").innerHTML=jQuery.i18n.prop("lt_EnablePin"); |
| 72 | document.getElementById("btUpdate1").value = jQuery.i18n.prop("lt_EnablePin"); |
| 73 | } else { |
| 74 | document.getElementById("lt_EnableDisablePin").innerHTML=jQuery.i18n.prop("lt_DisablePin"); |
| 75 | document.getElementById("btUpdate1").value = jQuery.i18n.prop("lt_DisablePin"); |
| 76 | document.getElementById("ChangePin").style.display="block"; |
| 77 | |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | LocalAllElement(); |
| 82 | |
| 83 | } |
| 84 | |
| 85 | function Refresh(){ |
| 86 | document.getElementById("ResetPinUsingPuk").style.display="none"; |
| 87 | document.getElementById("ProvidePin").style.display="none"; |
| 88 | document.getElementById("PinPukAttempts").style.display="none"; |
| 89 | document.getElementById("EnableDisablePin").style.display="none"; |
| 90 | document.getElementById("ChangePin").style.display="none"; |
| 91 | } |
| 92 | |
| 93 | |
| 94 | this._ProvidePin = function() { |
| 95 | |
| 96 | |
| 97 | var pin = document.getElementById('txtPin').value; |
| 98 | if(! validate_pin(pin)) { |
| 99 | document.getElementById('lAlertError').innerHTML= jQuery.i18n.prop("linvalidPin"); |
| 100 | return; |
| 101 | } |
| 102 | |
| 103 | var pinpukMap = new Map(); |
| 104 | pinpukMap.put("RGW/sim/pin_puk/pin", pin); |
| 105 | |
| 106 | var retXml = PostXml(gpinpukubusobjname, "provide_pin", pinpukMap); |
| 107 | if( $(retXml).find("setting_response").text()=="ERROR"){ |
| 108 | |
| 109 | if(glastpinattempts>$(retXml).find("pin_attempts").text()){ |
| 110 | showMsgBox(jQuery.i18n.prop("lPINResponseError"),jQuery.i18n.prop("lIncorrectPin")); |
| 111 | } |
| 112 | else{ |
| 113 | showMsgBox(jQuery.i18n.prop("lFailedWithUnkown"),jQuery.i18n.prop("lPINResponseError")); |
| 114 | } |
| 115 | |
| 116 | }else{ |
| 117 | |
| 118 | g_objContent.onLoad(); |
| 119 | } |
| 120 | |
| 121 | } |
| 122 | |
| 123 | this._resetPinUsingPuk = function() { |
| 124 | |
| 125 | |
| 126 | var puk = document.getElementById('txtPuk0').value; |
| 127 | var new_pin = document.getElementById('txtNewPin0').value; |
| 128 | |
| 129 | if(! validate_puk(puk)) { |
| 130 | document.getElementById('lAlertError0').innerHTML= jQuery.i18n.prop("linvalidPuk"); |
| 131 | return; |
| 132 | } |
| 133 | |
| 134 | if(! validate_pin(new_pin)) { |
| 135 | document.getElementById('lAlertError0').innerHTML= jQuery.i18n.prop("linvalidPuk"); |
| 136 | return; |
| 137 | } |
| 138 | var pinpukMap = new Map(); |
| 139 | pinpukMap.put("RGW/sim/pin_puk/puk", puk); |
| 140 | pinpukMap.put("RGW/sim/pin_puk/new_pin", new_pin); |
| 141 | |
| 142 | var retXml = PostXml(gpinpukubusobjname, "reset_pin_using_puk", pinpukMap); |
| 143 | if( $(retXml).find("setting_response").text()=="ERROR"){ |
| 144 | |
| 145 | if(glastpukattempts>$(retXml).find("puk_attempts").text()){ |
| 146 | document.getElementById('lAlertError0').innerHTML= jQuery.i18n.prop("lIncorrectPuk"); |
| 147 | return; |
| 148 | } |
| 149 | else{ |
| 150 | showMsgBox(jQuery.i18n.prop("lFailedWithUnkown"),jQuery.i18n.prop("lPINResponseError")); |
| 151 | } |
| 152 | |
| 153 | |
| 154 | }else{ |
| 155 | |
| 156 | g_objContent.onLoad(); |
| 157 | } |
| 158 | } |
| 159 | |
| 160 | this._EnableDisablePin = function() { |
| 161 | var pinpukMap = new Map(); |
| 162 | var usbubusmethod; |
| 163 | var pin = document.getElementById('txtPin1').value; |
| 164 | |
| 165 | if(! validate_pin(pin)) { |
| 166 | document.getElementById('lAlertError1').innerHTML= jQuery.i18n.prop("linvalidPin"); |
| 167 | return; |
| 168 | } |
| 169 | |
| 170 | pinpukMap.put("RGW/sim/pin_puk/pin", pin); |
| 171 | |
| 172 | if("1"==pinenabled){ |
| 173 | |
| 174 | usbubusmethod = "disable_pin"; |
| 175 | } |
| 176 | else{ |
| 177 | |
| 178 | usbubusmethod = "enable_pin"; |
| 179 | } |
| 180 | |
| 181 | |
| 182 | var retXml = PostXml(gpinpukubusobjname, usbubusmethod, pinpukMap); |
| 183 | if( $(retXml).find("setting_response").text()=="ERROR"){ |
| 184 | |
| 185 | if(glastpinattempts>$(retXml).find("pin_attempts").text()){ |
| 186 | document.getElementById('lAlertError1').innerHTML= jQuery.i18n.prop("lIncorrectPin"); |
| 187 | return; |
| 188 | } |
| 189 | else{ |
| 190 | showMsgBox(jQuery.i18n.prop("lPINResponseError"),jQuery.i18n.prop("lFailedWithUnkown")); |
| 191 | } |
| 192 | |
| 193 | |
| 194 | }else{ |
| 195 | |
| 196 | g_objContent.onLoad(); |
| 197 | } |
| 198 | |
| 199 | } |
| 200 | |
| 201 | this._ChangePin = function() { |
| 202 | |
| 203 | var pin = document.getElementById('txtPin2').value; |
| 204 | var new_pin = document.getElementById('txtNewPin2').value; |
| 205 | |
| 206 | if(! validate_pin(pin)) { |
| 207 | document.getElementById('lAlertError2').innerHTML= jQuery.i18n.prop("linvalidPin"); |
| 208 | return; |
| 209 | } |
| 210 | |
| 211 | if(! validate_pin(new_pin)) { |
| 212 | document.getElementById('lAlertError2').innerHTML= jQuery.i18n.prop("linvalidPin"); |
| 213 | return; |
| 214 | } |
| 215 | |
| 216 | if(pin == new_pin) { |
| 217 | document.getElementById('lAlertError2').innerHTML= jQuery.i18n.prop("lNewPinSameWithOld"); |
| 218 | return; |
| 219 | } |
| 220 | |
| 221 | var pinpukMap = new Map(); |
| 222 | pinpukMap.put("RGW/sim/pin_puk/pin", pin); |
| 223 | pinpukMap.put("RGW/sim/pin_puk/new_pin", new_pin); |
| 224 | |
| 225 | var retXml = PostXml(gpinpukubusobjname, "change_pin", pinpukMap); |
| 226 | if( $(retXml).find("setting_response").text()=="ERROR"){ |
| 227 | |
| 228 | if(glastpinattempts>$(retXml).find("pin_attempts").text()){ |
| 229 | document.getElementById('lAlertError2').innerHTML= jQuery.i18n.prop("lIncorrectPin"); |
| 230 | return; |
| 231 | } |
| 232 | else{ |
| 233 | showMsgBox(jQuery.i18n.prop("lPINResponseError"),jQuery.i18n.prop("lFailedWithUnkown")); |
| 234 | } |
| 235 | |
| 236 | }else{ |
| 237 | |
| 238 | g_objContent.onLoad(); |
| 239 | } |
| 240 | |
| 241 | } |
| 242 | return this.each(function () { |
| 243 | }); |
| 244 | } |
| 245 | })(jQuery); |
| 246 | |
| 247 | function ProvidePin() { |
| 248 | g_objContent._ProvidePin(); |
| 249 | } |
| 250 | function resetPinUsingPuk() { |
| 251 | g_objContent._resetPinUsingPuk(); |
| 252 | } |
| 253 | |
| 254 | function EnableDisablePin() { |
| 255 | g_objContent._EnableDisablePin(); |
| 256 | } |
| 257 | |
| 258 | function ChangePin() { |
| 259 | g_objContent._ChangePin(); |
| 260 | } |
| 261 | |
| 262 | |
| 263 | |
| 264 | function clearAlertError() |
| 265 | { |
| 266 | $("#lAlertError").text(""); |
| 267 | } |
| 268 | function clearAlertError0() |
| 269 | { |
| 270 | $("#lAlertError0").text(""); |
| 271 | } |
| 272 | |
| 273 | function clearAlertError1() |
| 274 | { |
| 275 | $("#lAlertError1").text(""); |
| 276 | } |
| 277 | |
| 278 | function clearAlertError2() |
| 279 | { |
| 280 | $("#lAlertError2").text(""); |
| 281 | } |