Saturday, September 8, 2012

[MOVIE] Men in black III Spoiler

earth will be destroy K does not tip

[SCRIPT/JS] Date() Javascript adding days to specific date example

javascript adding days to specific date










example code:
<script>
var now=new Date();

var currentDate=now.getDate();
var currentMonth=now.getMonth();
var currentYear=now.getYear();

var tomorrow=new Date(currentYear,currentMonth,currentDate+1);
var lastWeek=new Date(currentYear,currentMonth,currentDate-7);
var lastMonth=new Date(currentYear,currentMonth-1,currentDate);

</script>

result:
tomorrow: Sun Sep 9 00:00:00 UTC+0900 2012
last week: Sat Sep 1 00:00:00 UTC+0900 2012
last month: Wed Aug 8 00:00:00 UTC+0900 2012 

Friday, September 7, 2012

[TOOL/EDITPLUS] EDITPLUS REGULAR EXPRESSION REPLACE EXAMPLES


first you check the 'Regular expression' option



remove whitepsace of end-of-lines
Find what: ( *)$
Replace with: none

remove whitespace at start each lines
like this codes:
<script src..............
  if(value){
    document.write()
after replace
<script src..............
if(value){
document.write()
Find what: ^([0-9]+ +)
Replace with: none

remove lines has only whitespace or null
Find what: ( *)\n\n
Replace with: none

searching html tag name
Find what: (\<\/?[A-Z]+)

[SCRIPT/JS] setCookie getCookie deleteCookie, Javascript Functions

store cookies
setcookie ('variable name', 'value', 'expiration date', 'domain', 'security');

loading cookies
getCookie ('variable name');

delete cookies
deleteCookie ('variable name');








<script>
 
function setCookie(cookieName, cookieValue, cookieExpire, cookiePath, cookieDomain, cookieSecure){
    var cookieText=escape(cookieName)+'='+escape(cookieValue);
    cookieText+=(cookieExpire ? '; EXPIRES='+cookieExpire.toGMTString() : '');
    cookieText+=(cookiePath ? '; PATH='+cookiePath : '');
    cookieText+=(cookieDomain ? '; DOMAIN='+cookieDomain : '');
    cookieText+=(cookieSecure ? '; SECURE' : '');
    document.cookie=cookieText;
}
 
function getCookie(cookieName){
    var cookieValue=null;
    if(document.cookie){
        var array=document.cookie.split((escape(cookieName)+'=')); 
        if(array.length >= 2){
            var arraySub=array[1].split(';');
            cookieValue=unescape(arraySub[0]);
        }
    }
    return cookieValue;
}
 
function deleteCookie(cookieName){
    var temp=getCookie(cookieName);
    if(temp){
        setCookie(cookieName,temp,(new Date(1)));
    }
}
 
</script>