1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> |
---|
2 | <html> |
---|
3 | <head> |
---|
4 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> |
---|
5 | <link href="css/main.css" rel="stylesheet" media="screen" /> |
---|
6 | <script type="text/javascript"> |
---|
7 | |
---|
8 | function loadPins() { |
---|
9 | var pins = parent.document.getElementsByTagName("applet")[0].getPins(); |
---|
10 | for (var i = 0; i < pins.length; i++) { |
---|
11 | var link = document.createElement('a'); |
---|
12 | link.setAttribute('href', ''); |
---|
13 | link.setAttribute('class', 'pin'); |
---|
14 | var js = "return showPinDetails('"+pins[i].type+"','"+pins[i].id+"','"+pins[i].status+"','"+pins[i].index+"');"; |
---|
15 | link.setAttribute('onclick', js); |
---|
16 | link.appendChild(document.createTextNode(pins[i].label)); |
---|
17 | document.getElementById("pinList").appendChild(link); |
---|
18 | document.getElementById("pinList").appendChild(document.createElement('br')); |
---|
19 | } |
---|
20 | return false; |
---|
21 | } |
---|
22 | |
---|
23 | function showPinDetails(pinType, pinId, pinStatus, pinIndex) { |
---|
24 | document.getElementById("tipoPin").value = pinType; |
---|
25 | document.getElementById("codigoPin").value = pinId; |
---|
26 | document.getElementById("estadoPin").value = pinStatus; |
---|
27 | document.getElementById("indicePin").value = pinIndex; |
---|
28 | return false; |
---|
29 | } |
---|
30 | |
---|
31 | function verifyPin() { |
---|
32 | var pinIndex = document.getElementById("indicePin").value; |
---|
33 | if ((pinIndex != null) && (pinIndex.trim().length > 0)) { |
---|
34 | var pin = prompt("Introduza o PIN"); |
---|
35 | if (pin != null) { |
---|
36 | var attemptsLeft = parent.document.getElementsByTagName("applet")[0].verifyPin(pin, pinIndex); |
---|
37 | if (attemptsLeft == -1) { |
---|
38 | alert("Pin OK!"); |
---|
39 | } |
---|
40 | else { |
---|
41 | alert("Pin errado. Tentativas disponiveis : "+ attemptsLeft); |
---|
42 | } |
---|
43 | } |
---|
44 | } |
---|
45 | return false; |
---|
46 | } |
---|
47 | |
---|
48 | function changePin() { |
---|
49 | var pinIndex = document.getElementById("indicePin").value; |
---|
50 | if ((pinIndex != null) && (pinIndex.trim().length > 0)) { |
---|
51 | var oldPin = prompt("Introduza o PIN actual"); |
---|
52 | if (oldPin != null) { |
---|
53 | var newPin = prompt("Introduza o PIN novo"); |
---|
54 | if ((newPin != null) && (newPin.trim().length > 0)) { |
---|
55 | var newPinConfirmation = prompt("Confirme o PIN novo"); |
---|
56 | if (newPin != newPinConfirmation) { |
---|
57 | alert("Os dois PINs introduzidos são diferentes!"); |
---|
58 | } |
---|
59 | else { |
---|
60 | var attemptsLeft = parent.document.getElementsByTagName("applet")[0].changePin(oldPin, newPin, pinIndex); |
---|
61 | if (attemptsLeft == -1) { |
---|
62 | alert("Pin Alterado!"); |
---|
63 | } |
---|
64 | else { |
---|
65 | alert("Pin errado. Tentativas disponiveis : "+ attemptsLeft); |
---|
66 | } |
---|
67 | } |
---|
68 | } |
---|
69 | } |
---|
70 | } |
---|
71 | return false; |
---|
72 | } |
---|
73 | |
---|
74 | </script> |
---|
75 | </head> |
---|
76 | <body onload="return loadPins();"> |
---|
77 | <div id="content"> |
---|
78 | <div id="center_content"> |
---|
79 | <form action="" method=""> |
---|
80 | <div class="floatLeft setMarginRight"> |
---|
81 | <label id="pinListTitle">PINs</label></br> |
---|
82 | <div id="pinList"></div> |
---|
83 | </div> |
---|
84 | <div class="floatLeft"> |
---|
85 | <div class="floatLeft"> |
---|
86 | <label>Tipo de código PIN</label></br> |
---|
87 | <label class="gray">PIN Type</label></br> |
---|
88 | <input type="text" name="" value="" readonly="true" id="tipoPin"/> |
---|
89 | </div> |
---|
90 | <div class="floatLeft"> |
---|
91 | <label>Identificação do código PIN</label></br> |
---|
92 | <label class="gray">PIN Id</label></br> |
---|
93 | <input type="text" name="" value="" readonly="true" id="codigoPin"/> |
---|
94 | </div> |
---|
95 | <div class="clear"></div> |
---|
96 | <label>Estado do código PIN</label></br> |
---|
97 | <label class="gray">PIN Status</label></br> |
---|
98 | <input type="text" name="" value="" readonly="true" id="estadoPin"/> |
---|
99 | <input type="hidden" name="" value="" id="indicePin"/> |
---|
100 | <div class="setMarginTop"></div> |
---|
101 | <input type="submit" name="" value="Verificar código PIN" class="largeButton setMarginRight" onclick="return verifyPin();"/> |
---|
102 | <input type="submit" name="" value="Alterar código PIN" class="largeButton" onclick="return changePin();"/> |
---|
103 | </div> |
---|
104 | <div class="clear"></div> |
---|
105 | </form> |
---|
106 | </div> |
---|
107 | </div> |
---|
108 | </body> |
---|
109 | </html> |
---|