summaryrefslogtreecommitdiff
path: root/httemplate/elements/change_password.html
blob: 068d7d73ce129058577d5c4bdd8d7154f4e00088 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<STYLE>
.passwordbox {
  border: 1px solid #7e0079;
  padding: 2px;
  position: absolute;
  font-size: 80%;
  background-color: #ffffff;
  display: none;
}
</STYLE>
% if (!$opt{'no_label_display'}) {
<A ID="<%$pre%>link" HREF="javascript:void(0)" onclick="<%$pre%>toggle(true)">(<% emt( $change_title ) %>)</A>
% }
<DIV ID="<%$pre%>div" CLASS="passwordbox">
% if (!$opt{'noformtag'}) {
  <FORM ID="<%$pre%>form" METHOD="POST" ACTION="<%$fsurl%>misc/process/change-password.html" onsubmit="return <%$pre%>checkPasswordValidation()">
% }

    <% $change_id_input %>
    <INPUT TYPE="text" ID="<%$pre%>password" NAME="<% $opt{'pre_pwd_field_label'} %>password" VALUE="<% $curr_value |h%>">
    <& /elements/random_pass.html, $pre.'password', 'randomize', $change_button_id &>
% if (!$opt{'noformtag'}) {
    <INPUT TYPE="submit" ID="<%$change_button_id%>" VALUE="change" disabled="disabled">
% } else {
    <INPUT TYPE="button" ID="<%$change_button_id%>" VALUE="change" onclick="<%$pre%>toggle(false)" disabled="disabled">
%}
    <INPUT TYPE="button" ID="<%$pre%>cancel_button" VALUE="cancel" onclick="<%$pre%>toggle(false, true)">

    <DIV ID="<%$pre%>password_result" STYLE="font-size: smaller"></DIV>
    <& '/elements/validate_password.html', 
         'fieldid'    => $pre.'password',
         'svcnum'     => $svcnum,
         'contactnum' => $opt{'contact_num'},
         'submitid'   => $change_button_id,
    &>

% if (!$opt{'noformtag'}) {
  </FORM>
% }

</DIV>
<SCRIPT TYPE="text/javascript">
function <%$pre%>toggle(toggle, clear) {
  if (clear) {
    document.getElementById('<%$pre%>password').value = '';
    document.getElementById('<%$pre%>password_result').innerHTML = '';
    document.getElementById('<%$change_button_id%>').disabled = true;
  }
  document.getElementById('<%$pre%>div').style.display =
    toggle ? 'inline-block' : 'none';
% if (!$opt{'no_label_display'}) {
  document.getElementById('<%$pre%>link').style.display =
    toggle ? 'none' : 'inline';
% }
}

function <%$pre%>checkPasswordValidation(resultId)  {
  var validationResult = document.getElementById('<%$pre%>password_result').innerHTML;
  if (validationResult.match(/Password valid!/)) {
    return true;
  }
  else {
    return false;
  }
}
</SCRIPT>
<%init>
my %opt = @_;

my $curr_value = $opt{'curr_value'} || '';
my $change_title = $opt{'label'} || 'change';
my $svcnum;
my $change_id_input = '';
my $pre = 'changepw';

if ($opt{'svc_acct'}) {
  my $svc_acct = $opt{'svc_acct'};
  $change_id_input = '<INPUT TYPE="hidden" NAME="'.$opt{'pre_pwd_field_label'}.'svcnum" VALUE="' . $svc_acct->svcnum . '">';
  $pre .= $svc_acct->svcnum . '_';
  $svcnum = $svc_acct->svcnum;
}
elsif ($opt{'contact_num'}) {
  $change_id_input = '
    <INPUT TYPE="hidden" NAME="contactnum" VALUE="' . $opt{'contact_num'} . '">
    <INPUT TYPE="hidden" NAME="custnum" VALUE="' . $opt{'custnum'} . '">
  ';
  $pre .= $opt{'pre_pwd_field_label'};
}

my $change_button_id = $pre.'change_button';

 my $error = $cgi->param($pre.'error');
</%init>