9 elgg.assertTypeOf =
function(type, val) {
10 if (typeof val !== type) {
11 throw new TypeError(
"Expecting param of " +
12 arguments.caller +
"to be a(n) " + type +
"." +
13 " Was actually a(n) " + typeof val +
".");
30 elgg.normalize_url =
function(url) {
32 elgg.assertTypeOf(
'string', url);
34 function validate(url) {
35 url =
elgg.parse_url(url);
37 url.scheme = url.scheme.toLowerCase();
39 if (url.scheme ==
'http' || url.scheme ==
'https') {
44 if (!(
new RegExp(
"^([a-zA-Z0-9][a-zA-Z0-9\\-\\.]*)$",
"i")).test(url.host) || url.host.charAt(-1) ==
'.') {
49 if (!url.scheme || !url.host && url.scheme !=
'mailto' && url.scheme !=
'news' && url.scheme !=
'file') {
56 if (url.indexOf(
'http:') === 0 || url.indexOf(
'https:') === 0 || url.indexOf(
'javascript:') === 0 || url.indexOf(
'mailto:') === 0 ) {
58 }
else if (validate(url)) {
61 }
else if ((
new RegExp(
"^(\\#|\\?|//)",
"i")).test(url)) {
65 }
else if ((
new RegExp(
"^[^\/]*\\.php(\\?.*)?$",
"i")).test(url)) {
68 if (url.indexOf(
'/') === 0) {
69 url = url.substring(1);
72 return elgg.config.wwwroot + url;
73 }
else if ((
new RegExp(
"^[^/\\?\\#]*\\.",
"i")).test(url)) {
75 return 'http://' + url;
80 if (url.indexOf(
'/') === 0) {
81 url = url.substring(1);
84 return elgg.config.wwwroot + url;
95 elgg.deprecated_notice =
function(msg, dep_version) {
96 if (
elgg.is_admin_logged_in()) {
97 msg =
"Deprecated in Elgg " + dep_version +
": " + msg;
98 if (typeof console !==
"undefined") {
111 var dest =
elgg.normalize_url(url);
113 if (dest == location.href) {
119 $(window).
on(
'hashchange',
function () {
123 location.href = dest;
135 elgg.parse_url =
function(url, component, expand) {
139 expand = expand ||
false;
140 component = component ||
false;
144 '^(?:(?![^:@]+:[^:@/]*@)([^:/?#.]+):)?(?://)?' 146 +
'((?:(([^:@]*)(?::([^:@]*))?)?@)?' 148 +
'([^:/?#]*)(?::(\\d*))?)' 150 +
'(((/(?:[^?#](?![^?#/]*\\.[^?#/.]+(?:[?#]|$)))*/?)?([^?#/]*))' 167 if (url.indexOf(
'mailto:') === 0) {
168 results[
'scheme'] =
'mailto';
169 results[
'path'] = url.replace(
'mailto:',
'');
173 if (url.indexOf(
'javascript:') === 0) {
174 results[
'scheme'] =
'javascript';
175 results[
'path'] = url.replace(
'javascript:',
'');
179 var re =
new RegExp(re_str);
180 var matches = re.exec(url);
182 for (var i in keys) {
184 results[keys[i]] = matches[i];
188 if (expand && typeof(results[
'query']) !=
'undefined') {
189 results[
'query'] =
elgg.parse_str(results[
'query']);
193 if (typeof(results[component]) !=
'undefined') {
194 return results[component];
208 elgg.parse_str =
function(string) {
213 re = /([^&=]+)=?([^&]*)/g,
217 while (result = re.exec(
string)) {
218 key = decodeURIComponent(result[1].replace(/\+/g,
' '));
219 value = decodeURIComponent(result[2].replace(/\+/g,
' '));
222 key = key.replace(re2,
'');
226 params[key].push(value);
247 elgg.getSelectorFromUrlFragment =
function(url) {
248 var fragment = url.split(
'#')[1];
252 if (fragment.indexOf(
'.') > -1) {
256 return '#' + fragment;
267 elgg.get_logged_in_user_guid =
function() {
268 return elgg.user ?
elgg.user.guid : 0;
276 elgg.is_logged_in =
function() {
277 return elgg.get_logged_in_user_guid() > 0;
285 elgg.is_admin_logged_in =
function() {
286 return elgg.user ?
elgg.user.admin :
false;
294 elgg.get_site_url =
function() {
295 return elgg.config.wwwroot;
305 elgg.get_simplecache_url =
function(view, subview) {
306 elgg.assertTypeOf(
'string', view);
310 if (
elgg.config.simplecache_enabled) {
311 lastcache =
elgg.config.lastcache;
317 path =
'/cache/' + lastcache +
'/' +
elgg.config.viewtype +
'/' + view;
319 elgg.assertTypeOf(
'string', subview);
321 if ((view ===
'js' || view ===
'css') && 0 === subview.indexOf(view +
'/')) {
322 subview = subview.substr(view.length + 1);
324 path =
'/cache/' + lastcache +
'/' +
elgg.config.viewtype +
'/' + view +
'/' + subview;
327 return elgg.normalize_url(path);
Bundled plugins(the contents of the"/mod"directory) are available only under the GPLv2 license.The remainder of the project is available under either MIT or GPLv2.Both licenses can be found below.More info and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two distribute and or modify the software for each author s protection and we want to make certain that everyone understands that there is no warranty for this free software If the software is modified by someone else and passed on