Archive

Author Archive

Create Push-like Notifications with Javascript!

September 12, 2010 Leave a comment

Do you know the Iphone Push notifications?
Well you can use something like that IN your web page thanks to the Javascript API that came along with HTML5!
Its as simple as this!

window.webkitNotifications.createNotification(image_to_display, title, text).show()

Of course you will need to include some failture handling…since not all browsers have this implemented.(here goes my little script):

if (window.webkitNotifications){hasnotif="y";}else{hasnotif="n";}

function c_perm(id){
if (hasnotif=="y")//has notifications,ask for permision
{
	document.getElementById(id).addEventListener('click', function() {
	  window.webkitNotifications.requestPermission();
	}, false);

}  
else
{
	throw("Cant use Notifications.")
}	
}
//
//
function showNotification(title, text, img) {
  if (window.webkitNotifications.checkPermission() == 0) {
    // note the show()
    window.webkitNotifications.createNotification(img, title, text).show(); 
  } else {
    		throw("Failed to use Notifications!");
  }  }

And thats some simple error handling(for complex use you should make a better error handling, eg: the “Failed to use Notifications!” error is raised when client did not authorized OR when the client cant use them).
Heres a picture of what you can get!
Example
Notes:To test this Javascript i believe you have to upload you files into a server since the authorization for NOtifications is Domain Based.

Javascript View counter!(Client only)

September 11, 2010 Leave a comment

Hello ppl that use AJAX and server-side to create view-counters!

I have something to tell you all!(You still need  some server side support)

HTML5 gives YOU the option to use localStorage besides other things like god dam easy configuration storage(Check out HTML5 and you will see what i mean, i will not cover this aspect in this post)

The following script(JS) saves a local_views variable with localStorage.(You can create a AJAX function to send the views to your server,or you can just use like “You have visited this page:12 times”)

Hope you find it useful.

//try to access to local storage
if (localStorage){haslocal = "y";}else{haslocal="n";}
function store(key, value)
{	
	if (haslocal="y")
	{
		localStorage.setItem(key, value);
	}
	else
	{
		throw("Local Storage not suported.");
	}
}


function record()
{
	if (haslocal="y")//test for localStorage Support
	{
		if (localStorage.local_views==null)//if local_views variable isnt set
		{
			localStorage.setItem("local_views", 1);
		}
		else//if local_views is set increment it
		{
			//test if thers a int stored
			if (parseInt(localStorage.local_views))
			{
				localStorage.local_views++;	
			}
			else
			{
				//not a int stored going back to one
				localStorage.local_views = 1;
			}		
		}
	}
	else
	{
		throw("Local Storage not suported.");
	}
	
	
}
function getViews()
{
	if (haslocal="y")
	{
		local_views = localStorage.local_views;
	}
	else
	{
		throw("Local Storage not suported.");
	}
}
//store() is a no-need simplification to store values in localstorage
//record() well RECORDS the views
//getViews() ugh? gets the number of views and stores it in local_views variable
Categories: HTML/CSS/JS, Web Tags: ,

Chromium Webapps on Google Chrome!

September 11, 2010 Leave a comment

Have you ever heard of Chromium OS?

Heres the short version- its a operating system made by Google- based on the cloud, no information is stored on the computer!

The best part is the applications it has.. they are part of the browser(see picture below)

Google ChromeScreenSnapz001

You can use them on Google Chrome!(With the developer version)

Check out this website for instructions.

My opinions:

Until devs start using NativeClient to produce installable webapps there isnt anything EPIC about these,just a different display.

PS: I have a shared folder here with some webapps ready to use.

Categories: Web

My 1 Share

September 10, 2010 Leave a comment

If you didnt noticed in the 1 post i made(like 2 posts behind lol) i showed up some code… and i didint used the plugin.

If you want to show code  with HTML theres a website here that  has a language->HTML  w/syntax highlighting   converter.

Basically its normal HTML and CSS and escaping BUT it does the work for you.

Categories: HTML/CSS/JS

What will i do in here

September 10, 2010 Leave a comment

I’ll post code chunks   especially the ones the  make automagical stuff :3

I’ll post ideas too sometimes… im more into code..

Categories: Uncategorized

Hey visitor!

September 10, 2010 Leave a comment

Hey ppl so i’ll use this as my Blog…

a lot easier than coding multiple HTML files..

and i can still do

function test() 
{
  alert("It workz");

}


show code… yay

Categories: Uncategorized