-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhkid-check.html
136 lines (133 loc) · 4.79 KB
/
hkid-check.html
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="third-party/bootstrap-3.3.0/css/bootstrap.min.css">
<script type="text/javascript" src="third-party/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="third-party/angular.min.js"></script>
<script type="text/javascript" src="third-party/bootstrap-3.3.0/js/bootstrap.min.js"></script>
<script type="text/javascript" src="hkid.checker.js"></script>
<script>
app.controller('HKIDController', ['$scope', '$rootScope', function ($scope, $rootScope) {
$scope.hkidData = {};
$scope.directiveScopeDict = {};
$scope.directiveCtrlDict = {};
$scope.EventListener = function(scope, iElement, iAttrs, controller){
var prgmID = scope.programId;
var tagName = iElement[0].tagName;
if($scope.directiveScopeDict[tagName] == null || typeof($scope.directiveScopeDict[tagName]) == "undefined"){
$scope.directiveScopeDict[tagName] = scope;
$scope.directiveCtrlDict[tagName] = controller;
}
//http://api.jquery.com/Types/#Event
//The standard events in the Document Object Model are:
// blur, focus, load, resize, scroll, unload, beforeunload,
// click, dblclick, mousedown, mouseup, mousemove, mouseover, mouseout, mouseenter, mouseleave,
// change, select, submit, keydown, keypress, and keyup.
iElement.ready(function() {
})
}
}]);
</script>
</head>
<body ng-app="myApp">
<div ng-controller="HKIDController as hkidCtrl" class="form-horizontal" style="max-width: 1080px; margin-left: 20px; margin-top: 20px;">
<hkid ng-model="hkidData">
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">HKID</label>
<div class="col-sm-4">
<textarea class="form-control" ng-model="hkidData.recordList" rows="5" cols="20" placeholder="place your hkid here, brackets are not necessary"></textarea>
</div>
<label class="col-sm-2 control-label">Sample data
<p class="form-control-static">
<pre>Z538325(1)
A891353(9)
E585468(0)</pre>
</p>
</label>
</div>
<div class="clearfix"></div>
<div class="form-group">
<label class="col-sm-2 control-label">Pass</label>
<div class="col-sm-10">
<p class="form-control-static">
{{hkidData.resultCount.pass}} / {{hkidData.resultSet.length}}
</p>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Invalid</label>
<div class="col-sm-10">
<p class="form-control-static">
{{hkidData.resultCount.fail}} / {{hkidData.resultSet.length}}
</p>
</div>
</div>
<div class="form-group">
<div class="col-sm-3"><label class="col-sm-12 control-label">Invalid type: </label></div>
<label class="col-sm-2 control-label">length or format</label>
<div class="col-sm-1">
<p class="form-control-static">{{hkidData.resultCount.fail_in_format}}</p>
</div>
<label class="col-sm-2 control-label">fail in validation</label>
<div class="col-sm-1">
<p class="form-control-static">{{hkidData.resultCount.fail_in_validation}}</p>
</div>
<label class="col-sm-2 control-label">Duplicated HKID {{hkidData.duplicatedHKID.length}}</label>
<div class="col-sm-1">
<p class="form-control-static">{{hkidData.duplicatedHKID}}</p>
</div>
</div>
<div class="clearfix"></div>
<div class="form-group has-feedback">
<div class="col-sm-6 col-sm-offset-2">
<input type="text" name="searchInCreate" class="input-sm form-control" ng-model="searchInCreate">
<span class="glyphicon glyphicon-search form-control-feedback" aria-hidden="true"></span>
</div>
<div class="col-sm-3">
<select class="input-sm form-control" ng-model="searchInCreate">
<option>OK!!</option>
<option>Invalid</option>
<option>Invalid length</option>
<option>Fail in algorithm validation</option>
<option>Duplicated</option>
</select>
</div>
</div>
<table class="table table-striped table-hover">
<thead>
<tr>
<th>HKID</th>
<th>Check Digit</th>
<th>Validation algorithm</th>
<th>Pass</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in hkidData.resultSet | filter:searchInCreate" ng-class="{success:row.pass.status, warning:!row.pass.status}">
<td>{{row.hkid}}</td>
<td>{{row.digit}}</td>
<td><pre>{{row.formula}}</pre></td>
<td>
{{row.pass.message}}
</td>
</tr>
</tbody>
</table>
</hkid>
</div>
<div class="form-group">
<div class="col-sm-12">
Author: Keith Poon<br>
Date: 2014-12-05<br>
Reference: <a href="http://hknothingblog.blogspot.hk/2013/01/javascript-to-validate-hkid-number.html">Javascript to validate HKID number</a><br>Usage<br>
<ol>
<li>Paste the HKID to the textarea</li>
<li>The validation result will come out</li>
</ol>
Log: <br>
Update: rewrite the angular validation into a directive, 20171219, Keith<br>
Add: age: 4 hours, 20151205-15:52 written by Keith
</div>
</div>
</body>