1 |
window.onload = function () { |
2 |
document.getElementById ('SUBMIT').onclick = function () { |
3 |
var uri_re = /^(([^:\/?#]+):)?(\/\/([^\/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/; |
4 |
var original_uri = document.getElementById ('INPUT-URI').value; |
5 |
if (original_uri.match (uri_re)) { |
6 |
setValue ('RESULT-URI-SCHEME', RegExp.$2, RegExp.$1); |
7 |
setValue ('RESULT-URI-AUTHORITY', RegExp.$4, RegExp.$3); |
8 |
setValue ('RESULT-URI-PATH', RegExp.$5, true); |
9 |
setValue ('RESULT-URI-QUERY', RegExp.$7, RegExp.$6); |
10 |
setValue ('RESULT-URI-FRAGMENT', RegExp.$9, RegExp.$8); |
11 |
} |
12 |
}; |
13 |
}; |
14 |
|
15 |
function setValue (elID, val, isNonNull) { |
16 |
var el = document.getElementById (elID); |
17 |
if (!isNonNull) { |
18 |
el.innerHTML = '−'; |
19 |
} else { |
20 |
el.innerHTML = ''; |
21 |
var code = document.createElement ('code'); |
22 |
code.setAttribute ('class', 'URI'); |
23 |
code.appendChild (document.createTextNode (val)); |
24 |
el.appendChild (code); |
25 |
} |
26 |
} |