jQuery Extension: myURL

Simple and easy jQuery compatible way to make url calls in javascript. Use it for controller calls, image folder calls, or whatever you like!

by SpYk3

HTML

<p class="ui-widget ui-widget-header"></p><br />
    <p class="ui-widget ui-widget-content"></p><br />
    <p class="ui-widget ui-widget-header ui-state-active"></p><br />
    <p class="ui-widget ui-widget-header ui-state-highlight"></p><br />
    <p id="makeItYourOwn" class="ui-widget ui-widget-header ui-state-error"></p><br />

CSS

body { background-color: #000; }

/*
 * jQuery UI CSS Framework 1.8.13
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Theming/API
 */

/* Layout helpers
----------------------------------*/
.ui-helper-hidden { display: none; }
.ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); }
.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; }
.ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
.ui-helper-clearfix { display: inline-block; }
/* required comment for clearfix to work in Opera \*/
* html .ui-helper-clearfix { height:1%; }
.ui-helper-clearfix { display:block; }
/* end clearfix */
.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); }


/* Interaction Cues
----------------------------------*/
.ui-state-disabled { cursor: default !important; }


/* Icons
----------------------------------*/

/* states and images */
.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; }


/* Misc visuals
----------------------------------*/

/* Overlays */
.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }


/*
 * jQuery UI CSS Framework 1.8.13
 *
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
 * Dual licensed under the MIT or GPL Version 2 licenses.
 * http://jquery.org/license
 *
 * http://docs.jquery.com/UI/Theming/API
 *
 * To view and modify this theme, visit...

JavaScript

/* - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* - - - - - - - - PLUG-IN BEGIN - - - - - - - - - - - - */
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - */
;(function($){$.myURL||($.extend({myURL:function(c){$.myURL.defaults.base||$.myURL.config();if(c){var a,b=$.myURL.defaults.base;if("index"==c)b+="/index.php",a=Array.prototype.slice.call(arguments,1);else{if("pathname"==c)return window.location.pathname;if("afterpath"==c)return window.location.href.substr(window.location.href.indexOf(window.location.pathname)+window.location.pathname.length);if("fullpathname"==c)return $.myURL("pathname")+$.myURL("afterpath");a=Array.prototype.slice.call(arguments)}if(0<
a.length){var e=[],d=void 0;for(x in a)if("string"===typeof a[x])""==!a[x]&&("/"==a[x].charAt(0)&&(a[x]=a[x].substring(1)),"/"==a[x].charAt(a[x].length-1)&&(a[x]=a[x].substring(0,a[x].length-1)),""==!a[x]&&(e[x]=a[x]));else if("object"===typeof a[x]){var f=!1;if(0<e.length)for(y in e)-1<e[y].indexOf("?")&&(f=!0);if("[object Array]"===Object.prototype.toString.call(a[x]))for(y in a[x])if("string"==typeof a[x][y])d+=(f?"&":d?-1<d.indexOf("?")?"&":"?":"?")+a[x][y];else{if("object"==typeof a[x][y])var g=
a[x][y].key+"="+a[x][y].value,d=d?d+((-1<d.indexOf("?")?"&":f?"&":"?")+g):(f?"&":"?")+g}else d=d?d+((-1<d.indexOf("?")?"&":f?"&":"?")+$.param(a[x])):(f?"&":"?")+$.param(a[x])}0<e.length&&(b=b+"/"+e.join("/"));d&&(-1<b.indexOf("/?")&&(b=b.replace("/?","?")),b+=d)}b=$.myURL.defaults.trail?b.charAt(b.length-1)?b+"/":b:b;a=b.split("/");if(a[""==a[a.length-1]?a.length-2:a.length-1].match(/.[.,!,@,#,$,%,^,&,*,?,_,~]/))"/"==b.charAt(b.length-1)&&(b=b.substring(0,b.length-1));return b}b=$.myURL.defaults.base;
return b=$.myURL.defaults.trail?b.charAt(b.length-1)?b+"/":b:b}}),$.myURL.config=function(c){var...