@opengovsg/mockpass 4.0.4 → 4.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengovsg/mockpass",
3
- "version": "4.0.4",
3
+ "version": "4.0.6",
4
4
  "description": "A mock SingPass/CorpPass server for dev purposes",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -390,6 +390,22 @@ function myTrim(x) {
390
390
  return x.replace(/(^[ \t]*\n)/gm, "");
391
391
  }
392
392
 
393
+ /**
394
+ * This method listens to changes in userID entry to redirect user when id is clicked
395
+ */
396
+ function redirectID() {
397
+ const idInput = document.getElementById("id-input");
398
+ const optionsList = document.getElementById("id-datalist");
399
+ let optionsMap = new Map();
400
+ for (let i=0; i<optionsList.options.length; i++) {
401
+ optionsMap.set(optionsList.options[i].value, optionsList.options[i].dataset.asserturl);
402
+ }
403
+ if (optionsMap.has(idInput.value)) {
404
+ const assertURL = optionsMap.get(idInput.value);
405
+ window.location.href = assertURL;
406
+ }
407
+ }
408
+
393
409
  /**
394
410
  * This is generic method called for onkeypress action.
395
411
  *
@@ -166,14 +166,12 @@
166
166
  <div class="login-label">Log in</div>
167
167
  <br>
168
168
  <div class="dropdown" style="width: 100%; ">
169
- <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" style="width: 100%; border: 2px solid #ccc; border-radius: 5px; background: white; color: rgb(42, 45, 51); text-align: left;">
170
- Select username
171
- </button>
172
- <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
169
+ <input id="id-input" list="id-datalist" class="btn btn-secondary dropdown-toggle" oninput="redirectID()" placeholder= "Select Username" style="width: 100%; border: 2px solid #ccc; border-radius: 5px; background: white; color: rgb(42, 45, 51); text-align: left;">
170
+ <datalist class="dropdown-menu" id="id-datalist" aria-labelledby="id-input" >
173
171
  {{#values}}
174
- <li><a href = "{{ assertURL }}">{{ id }}</a></li>
172
+ <option value="{{ id }}" data-asserturl="{{ assertURL }}">{{ id }}</option>
175
173
  {{/values}}
176
- </div>
174
+ </datalist>
177
175
  </div>
178
176
  </div>
179
177
  <div>