user search url parsing
by John Allan
HTML
<select name="_show">
<option value="all">All</option>
</select>
JavaScript
var module, pathname, view;
module = {};
module.private = {};
pathname = "/agents/group/engineering";
module.private.getDeepLinkView = function (pathname) {
var obj, pathArray;
obj = {
'_show': null,
'_type': null,
'subject': null,
};
pathArray = pathname.split('/');
queryObj = {};
//get type
obj._type = queryObj._type || pathArray[2];
//get subject
obj.subject = queryObj.subject || pathArray[3];
//get _show
if (obj._type === 'group' ||
obj._type === 'firm' ||
obj._type === 'location') {
obj._show = 'all';
}
return obj;
};
view = module.private.getDeepLinkView(pathname);
console.log(view);