63 lines
1.8 KiB
JavaScript
63 lines
1.8 KiB
JavaScript
|
// parseUri 1.2.2
|
||
|
// (c) Steven Levithan <stevenlevithan.com>
|
||
|
// MIT License
|
||
|
// http://blog.stevenlevithan.com/archives/parseuri
|
||
|
function parseUri (str) {
|
||
|
var o = parseUri.options,
|
||
|
m = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
|
||
|
uri = {},
|
||
|
i = 14;
|
||
|
|
||
|
while (i--) uri[o.key[i]] = m[i] || "";
|
||
|
|
||
|
uri[o.q.name] = {};
|
||
|
uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
|
||
|
if ($1) uri[o.q.name][$1] = $2;
|
||
|
});
|
||
|
|
||
|
return uri;
|
||
|
};
|
||
|
|
||
|
parseUri.options = {
|
||
|
strictMode: false,
|
||
|
key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
|
||
|
q: {
|
||
|
name: "queryKey",
|
||
|
parser: /(?:^|&)([^&=]*)=?([^&]*)/g
|
||
|
},
|
||
|
parser: {
|
||
|
strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
|
||
|
loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
|
||
|
}
|
||
|
};
|
||
|
|
||
|
function generate_password()
|
||
|
{
|
||
|
// symbols 32 - 47 / 58 - 64 / 91 - 96 / 123 - 126
|
||
|
// numbers 48 - 57
|
||
|
// upper 65 - 90
|
||
|
// lower 97 - 122
|
||
|
var symbols = new Array(40, 47, 48, 57, 65, 90, 97, 122, 123, 126);
|
||
|
// var symbols = new Array(32, 47, 58, 64, 91, 96, 123, 126, 48, 57, 65, 90, 97, 122);
|
||
|
|
||
|
field = document.getElementById("new_password");
|
||
|
|
||
|
var res = "";
|
||
|
//for(i=0; i<16; i++)
|
||
|
while (res.length < 16)
|
||
|
{
|
||
|
a = Math.round(Math.random() * (symbols.length/2) * 2);
|
||
|
diff = symbols[a+1] - symbols[a];
|
||
|
r = Math.round(Math.random()*diff);
|
||
|
if (isNaN(r+symbols[a]))
|
||
|
continue;
|
||
|
res += String.fromCharCode(r + symbols[a]);
|
||
|
}
|
||
|
|
||
|
field.value = res;
|
||
|
}
|
||
|
|
||
|
function url_domain(data) {
|
||
|
var uri = parseUri(data)
|
||
|
return uri['host'];
|
||
|
}
|