Skip to content

Instantly share code, notes, and snippets.

$.myURL("index") // = http://spyk3lc.blogspot.com/index.php
$.myURL("images", "somePic.png") // = http://spyk3lc.blogspot.com/images/somePic.png
// Keep in mind this works for any directory ...
$.myURL("someDir") // = http://spyk3lc.blogspot.com/someDir/
// .. and it's content
$.myURL("someDir", "someContent.xx") // = http://spyk3lc.blogspot.com/someDir/someContent.xx
$.myURL("index", "someDir", "someContent.xx") // = http://spyk3lc.blogspot.com/index.php/someDir/someContent.xx
// Notice I have no need to include the .php tag as the extension already includes it via the keyword "index"!
$.myURL("doit.php/your/own/way/in/one/line.gif")
// = http://spyk3lc.blogspot.com/doit.php/your/own/way/in/one/line.gif
$.myURL.config({
local: {
main: "myMainLocalDirectory"
},
onSite:
{
main: "myMainSiteDirectory",
sub: "myMainSiteSubDir/andAnotherDir"
}
});
(function(a){a.myURL||(a.extend({myURL:function(d){a.myURL.defaults.base||a.myURL.config();if(d){var b,c=a.myURL.defaults.base;if("index"==d)c+="/index.php",b=Array.prototype.slice.call(arguments,1);else{if("pathname"==d)return window.location.pathname;if("afterpath"==d)return window.location.href.substr(window.location.href.indexOf(window.location.pathname)+window.location.pathname.length);if("fullpathname"==d)return a.myURL("pathname")+a.myURL("afterpath");b=Array.prototype.slice.call(arguments)}if(0<
b.length){var e=[],f=void 0;for(x in b)"string"===typeof b[x]?""==!b[x]&&("/"==b[x].charAt(0)&&(b[x]=b[x].substring(1)),"/"==b[x].charAt(b[x].length-1)&&(b[x]=b[x].substring(0,b[x].length-1)),""==!b[x]&&(e[x]=b[x])):"object"===typeof b[x]&&(f="?"+a.param(b[x]));0<e.length&&(c=c+"/"+e.join("/"));f&&(c+=f)}c=a.myURL.defaults.trail?c.charAt(c.length-1)?c+"/":c:c;b=c.split("/");if(b[""==b[b.length-1]?b.length-2:b.length-1].match(/.[.,!,@,#,$,%,^,&,*,?,_,~]/))"/"==c.charAt(c.length-1)&&(c=c.substring(0,
c.length-1)
$.myURL("someDir", "someContent.xx", { data1: 'someString', data2: 'some Other string' })
// Will produce something like:
// http://spyk3lc.blogspot.com/someDir/someContent.xx?data1=someString&data2=some+Other+string
// A simple timer var is like
var tmrStopType
// Again, what you name the function is clearly up to you, I wouldn't really recommend my example name as it is just plain bad :P
function stopType() {
// The following if statement will check if your timer has been assigned yet, and if so, clears it so it will no longer continue to your work function
if (tmrStopType!= undefined) clearTimeout(tmrStopType);
// The following will attempt to start your work function after 2 seconds unless interrupted and reset by previous if statement
// Also, many people would rather write this statement as tmrStopType= setTimeout(stopTypeWork(), 2000);
// If, you want to, that is fine, i don't because it is not a style of timer writing that is readable to ALL browsers, however, the following is
tmrStopType= setTimeout(function (){ stopTypeWork() }, 2000);
};
function stopTypeWork() {
// do work
}