Articles
22 April 2012 | Category:
JavaScript
| Comments (0)
Just started project named jsCode on GitHub some weeks ago. I’m not going to compete in the race to be the best framework. Re-invent the wheel simply to learn more. Preparing a simple page on jsCode, where you can create your own version of jsCode.
However, if you have a suggestions or a critical voice then just write a comment.
22 April 2012 | Category:
Browsers
| Comments (0)
Finally, there is a one, big table of CSS Compatibility and Internet Explorer available on Microsoft site.
However, it’s surprised me that there is much more information for web developers on Windows Internet Explorer API reference (Developer Center). Hm, seems look good.
2 March 2012 | Category:
JavaScript
| Comments (0)
Well, this time will be shortly as always. I wanted to get value from some param in URL. After some research this could be done by this code (I use it):
/**
* Function getValueFromURLparam
* Extracting Querystring key/value pairs
*/
var getValueFromURLparam = function(name, url)
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^]*)";
var regex = new RegExp( regexS );
var results = regex.exec(url);
return (results === null) ? "" : results[1];
};
2 March 2012 | Category:
JavaScript
| Comments (0)
Some day I wanted to check if the string is valid of JSON format. After some research I found the solution:
/**
* Function isJSON
* Check if a string is JSON
*/
if(!String.prototype.isJSON)
{
String.prototype.isJSON = function()
{
return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(this.replace(/"(\\.|[^"\\])*"/g,'')));
}
}
1 March 2012 | Category:
JavaScript
| Comments (0)
Sometimes in our JavaScript code we use bulit-in console to view information, errors, etc. But when we close the Firebug then we see the JS errors. Why? Because there is no object window.console. So, what to do? Just create console object and create empty object for all console methods.
My code, which I use:
/**
* Firebug console
* If not available then add empty method
*/
var isFirebug = false;
if(typeof window.console != 'undefined')
{
for (var obj in window.console)
{
if (typeof window.console[obj] != 'u[......]
Read more about post What to do if Firebug console is not available
9 February 2012 | Category:
JavaScript
| Comments (0)
After some research I found the simple solution to convert HTML characters entities back to regular text using JavaScript. The code is simple and fast.
var decodeEntities = function( s )
{
var str, temp = document.createElement('p');
temp.innerHTML = s;
str = temp.textContent || temp.innerText;
temp = null;
return str;
};
9 February 2012 | Category:
JavaScript
| Comments (0)
Have you ever tried to create date from timestamp using JavaScript? After some testing code I found the solution. This is what i use:
var getDateFromTimestamp = function( t )
{
var a = new Date(t);
a =
{
day : a.getDate(),
month : a.getMonth() + 1,
year : String( a.getFullYear() ),
hours : a.getHours(),
minutes : a.getMinutes()
};
if( a.month < 10 )
{
a.month = '0' + a.month;
}
if( a.minutes < 10 )
{
a.minutes = '0' + a.minutes;
}
var fulldate = [a.day, a.month, a.year].join('.'),
time = [a.hours, a.minutes].join(':');
return ({
fulldate : fulldate,
time : time
});
};
[......]
Read more about post JavaScript and get date from timestamp
6 February 2012 | Category:
Browsers
| Comments (0)
It’s seems that in Firefox 12 developers will be able to use breaks (newlines) in tooltips (title attribute). Finally.
At this moment there is no way to use new line code to break a line text in title attribute. Of course, there is some tricks to change title to your_attribute and then styling it, but unfortunately this options is poor accessibility. Screen readers may have problem with non-standard attributes. As I know.
5 February 2012 | Category:
WordPress
| Comments (0)
Sometimes we want to check if the user is on home page. This can be done by this little function. Just add this code to your functions.php and use it likt this:
if (is_homepage()){ return true; }
Source:
function is_homepage(){
$siteurl = get_option('home');
if ($siteurl [strlen ( $siteurl ) - 1] != '/')
{
$siteurl .= '/';
}
$self_url = sprintf ( 'http%s://%s%s', (isset ( $_SERVER ['HTTPS'] ) && $_SERVER ['HTTPS'] == TRUE ? 's' : ''), $_SERVER ['HTTP_HOST'], $_SERVER ['REQUEST_URI'] );
if ([......]
Read more about post WordPress and checking if user is on home page
24 January 2012 | Category:
Tools
| Comments (1)
I have used the following method to successfully show Filezilla passwords (and all other settings) for sites saved in Filezilla. Just in 3 steps: File -> Export -> Export site manager entries (check box). Save the .xml file to location, open .xml and all site details are displayed.