|
2 | 2 | <html> |
3 | 3 | <head> |
4 | 4 | <meta charset="UTF-8" /> |
5 | | - <title>UID2 Hashing Tool</title> |
| 5 | + <title>${IDENTITY_NAME} Hashing Tool</title> |
6 | 6 | <link rel="stylesheet" type="text/css" href="./app.css" /> |
7 | | - <link rel="shortcut icon" href="/img/favicon.ico" /> |
8 | | - <script src="./uid2-sdk-3.3.0.js"></script> |
| 7 | + <script src="${UID_JS_SDK_URL}"></script> |
9 | 8 | <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> |
10 | 9 | </head> |
11 | 10 | <script> |
12 | | - console.log('Initializing example.'); |
| 11 | + console.log('Initializing ${IDENTITY_NAME} Hashing Tool.'); |
| 12 | + |
| 13 | + // __uid2 for UID2 SDK, __euid for EUID SDK |
| 14 | + const sdkName = '${UID_JS_SDK_NAME}'; |
| 15 | + |
| 16 | + // Helper object is named __uid2Helper or __euidHelper based on SDK |
| 17 | + function getHelper() { |
| 18 | + return window[sdkName + 'Helper']; |
| 19 | + } |
13 | 20 |
|
14 | 21 | async function updateGuiElements(normalizedInput, inputType) { |
15 | 22 | console.log('Updating displayed values.'); |
| 23 | + const helper = getHelper(); |
16 | 24 |
|
17 | | - if (normalizedInput) { |
18 | | - const hashedValue = await window.__uid2Helper.hashIdentifier(normalizedInput); |
| 25 | + if (normalizedInput && helper) { |
| 26 | + const hashedValue = await helper.hashIdentifier(normalizedInput); |
19 | 27 | $('#hashed').text(hashedValue); |
20 | | - const encodedValue = await window.__uid2Helper.hashAndEncodeIdentifier(normalizedInput); |
| 28 | + const encodedValue = await helper.hashAndEncodeIdentifier(normalizedInput); |
21 | 29 | $('#base64_encoded').text(encodedValue); |
22 | 30 | } |
23 | 31 | else { |
|
73 | 81 | $('.alert').hide(); |
74 | 82 | const inputValue = $('#input_value').val(); |
75 | 83 | const inputType = document.querySelector('input[name="toggle_input_type"]:checked').value; |
| 84 | + const helper = getHelper(); |
76 | 85 | let normalizedInput = undefined; |
| 86 | + |
| 87 | + if (!helper) { |
| 88 | + console.error('SDK helper not loaded yet'); |
| 89 | + return; |
| 90 | + } |
| 91 | + |
77 | 92 | if (inputType == "mobile") { |
78 | | - const isNormalizedPhone = window.__uid2Helper.isNormalizedPhone(inputValue) |
| 93 | + const isNormalizedPhone = helper.isNormalizedPhone(inputValue) |
79 | 94 | if (isNormalizedPhone) { |
80 | 95 | normalizedInput = inputValue; |
81 | 96 | } |
82 | 97 | } |
83 | 98 | if (inputType === "email") { |
84 | | - normalizedInput = window.__uid2Helper.normalizeEmail(inputValue); |
| 99 | + normalizedInput = helper.normalizeEmail(inputValue); |
85 | 100 | $('#normalization_value').text(normalizedInput); |
86 | 101 | } |
87 | 102 | updateGuiElements(normalizedInput, inputType); |
|
91 | 106 |
|
92 | 107 | </script> |
93 | 108 | <body> |
94 | | - <h1>UID2 Hashing Tool</h1> |
| 109 | + <h1>${IDENTITY_NAME} Hashing Tool</h1> |
95 | 110 | <p class="intro"> |
96 | 111 | Use this tool to verify that your own implementation is normalizing and |
97 | 112 | encoding correctly. Choose Email or Phone Number, then type or paste the |
98 | 113 | value and click Enter. <br><br> |
99 | 114 | <b>NOTE:</b> Normalize phone numbers before using the tool. |
100 | | - For details and examples, see <a href="https://unifiedid.com/docs/getting-started/gs-normalization-encoding">Normalization and Encoding</a>. |
| 115 | + For details and examples, see <a href="${DOCS_BASE_URL}/getting-started/gs-normalization-encoding" target="_blank">Normalization and Encoding</a>. |
101 | 116 | </p> |
102 | 117 |
|
103 | 118 | <input type="radio" id="toggle_email" name="toggle_input_type" value="email" onclick="handleRadioClick(this)" checked> |
|
0 commit comments