• We Code
  • We Design
  • We Develope
  • We Write
  • We Share

menu

Tuesday, January 21, 2014

Offline App Capability In HTML5

0 comments
HTML5 Offline Apps
Html5 Offline Apps
Offline app capability in HTML5 bought all the power to store data offline .When we talks about offline people ask offline means without internet ? First take the term ONLINE first . online and Web are kind of synonyms.
So why the term Offline is getting use for web technology . The offline here means run the webpage from file:// uri. But hang on it does not mean the web page will never get connected to server.The term offline will make more sense if we will take it like the web page could survive at the server downtime.There are various apps who connects the cloud server and survives at downtime. Gmail Mobile app and gmail offline are examples
.
In the Older time devs used the technique like cookies,Plugin Based Storage for storage. But the era of HTML5 bought more power to the client side for storage.
 . You can check the application for online/offline using navigator.onLine(). And it works everywhere in latest browser even in IE also.
You can also listen the events for it using.

document.body.addEventListener("online", function () {console.log("Now you are online !!!")}
document.body.addEventListener("offline", function () {console.log("Now you are offline !!!!")}

HTML5 bought many features to make application offline .Few Technique to make app offline
1.Application Cache : CACHE MANIFEST file make you able to store the resourse files locally for offline usage.Make a reference of manifest file inside <html> tag.
<html manifest="MyManifest.appcache">.

</html>
The mime type of the manifest must be text/cache-manifest.Manifest file is a simple text file . It looks like this

CACHE MANIFEST
index.html
index.css
index.js

2.Web Storage : Web storage have two sub category. One is persistent called local storage . In local storage we can set a value to a key using localstorage.key="value"
And we can retrieve it later . The other category of web storage is session storage we use it similar but the data gets lost once the browser gets closed .
We can just match the strings using the web storage.Simplicity is for calling the API is good part of this and bad performance is bad part of it.

3.Web SQL Database : Web sql database is a relational database .It has all the power of storing the complex relational database. it is well supported in all mobile browser the performance is really good .It has robustness. And the best part it is really easy to maintain.One have good command over sql can play with it with lot of ease.

4.Indexed database : Indexed Database is a collection of  stores of objects . Where you can keep the objects for future use.In indexed Db you don't need to define a schema before like  web sql database . In Index db you can have multiple databases and in each database you can have multiple stores.Indexed Database have good search performance and have robustness

Read more ►

Thursday, December 26, 2013

How to Make a user friendly Interface for Mobile Platforms?

0 comments
We all web Ninja knows the value of USER EXPERIENCE. In mobile platform it requires a different approach to make a better user experience. I am listing few points one must remember while making mobile Interface.
  • 1 .Responsive Web design
  • 2 .The event handing must be touch friendly
  • 3. The Forms must be design in a mobile friendly way .
  • 4. Use appropriate screen pixel densities of images


1. We all know responsive Design is one which adapts the layout on the basis of the screen size. It means the user will have the same  EXPERIENCE on mobile as on Desktop while browsing the site.few well known technique for making website responsive are these.
<meta name="viewport" content="width=device-width, initial-scale=1" />



<link rel="stylesheet" type="text/css" href="main.css" media="screen, handheld" />
<link rel="stylesheet" type="text/css" href="fallback.css" media="screen  and (min-width: 40.5em)" />
<!--[if (lt IE 9)&(!IEMobile)]>
<link rel="stylesheet" type="text/css" href="fallback.css" />
<![endif]-->
It means non mobile version and The IE version 9 or less than 9 will use fallback.css. We all knows IE 9 and lower does not support media queries. Not only IE some mobile browser like Symbian Browser (Doesn’t exist though) and BlackBerry older browser also not support the media queries. So Conclusion of this Part is make web design responsive.If you don’t know learn it.
Use Appcache to make website offline available. Believe me it increase user experiences

2. Now let’s  jump on the second point event handling. Now days mobile are touch friendly. Apple   bought “touch events AP” from ios 2.0 .Android is also catching up with touch events. W3C also making draft on touch event https://dvcs.w3.org/hg/webevents/raw-file/tip/touchevents.html. There are single touch and Multi touch Devices in market. Let’s not focus on multi and single touch devices (It’s another big debate).
So currently there are three basic touch events currently

  1. touchstart: When a DOM element is touched.
  2. touchmove: when a touch is dragged over the  DOM element.
  3. touchend: when the touch removed from DOM element.


3. The Forms  So one need to handle these events for making website touch friendly .Few things one must remember while approaching for touch friendly devices
1 .Disable the zooming : Preventing the user from zooming will prevent user to scale website.
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">

2.Prevent the scrolling: Few devices  like IOS jumps the viewport when the scroll exceed the limits.    
document.body.addEventListener('touchmove', function(event) {
  event.preventDefault();
}, false);

Now let’s come to Third point make form user friendly. Mobile have on-screen keyboard and its really frustrating to fill the form with this. But thanks to HTML5 which came with new semantic input types and validation. For making form filling mobile friendly on need to follow these two things .
1 .Input Type. There are number of new input type introduced in HTML which invokes relative on-screen keyboard.
The full list of all input types :
url ,tel ,Email , search, Number ,Color , Range , Datetime , datetime-local  ,Date,  Time , Week ,month
For Example I write < input type=”number” />, the browser will show a numeric onscreen keyboard. Or I write < input type=”Email” /> the on screen keyboard will show alpha numeric keyboard with @ and .com button . So the user will feel it more easy to fill the form
2.Form Validation : Validation of form is very important .It keeps the data clean and improve the  user experience . There are two approach one can use for form validation
 I . Pattern . Pattern is nothing but a regular expression to validate
 <form action="Myform.asp">
  Country code: <input type="text" name="Your country_code" pattern="[A-Za-z]{3}" title=" only Three letter country code">
  <input type="submit">
</form>
The above example will validate the input field and will allow only 3 character
II. Require : If input field have require attribute the user must fill the field before submitting the form

<input type="text" required  name="Your country_code" pattern="[A-Za-z]{3}" title=" only Three letter country code">
III min, max and step: For numeric value specify the minimum maximum value and for the value will increment in slider
<input type="number" id="myNumber" min="10" max="50" step="10" />
IV  maxlength : The maxlength attribute for Input type  will specify the maximum allowed length of input character


4.Now days there is very wide range of screen pixel densities. Some devices have really very very high resolution display. So first and best suggestion for the optimizing different screen pixels  is avoid images as much as you can. Now days there are SVG CSS3 for getting nice interface. And these works fine across the web
But if it is compulsory to use image you can  go for these two approach
1.       Optimize  Single image  for multiple platform. You can use one image and optimize it for different devices. But this will affect the performance badly. As user will download the Hidpi image in all browser ,the old browser will render it badly .
2.       Multiple Image approach . Use multiple images and decide on the browser capacity which to load .We can use following technique to make the dicision
  • 1 . Javascript
  • 2 .server side Delivery
  • 3. CSS Media Queries   




Read more ►

Monday, January 28, 2013

How To Use JavaScript With HTML 5

0 comments

HTML 5 is definitely the future of the web. So one must learn how to work on the JavaScript with Html 5.This article gives you the just introduction how to use JavaScript in html 5.
JavaScript moved a lot since Netscape livescript  . So the Html . As you all now traditional JavaScript have the DOM selector getElementById , getElementsByTagname,getElementsByClassname. The HTML 5 provide  javascript a new function called queryselector .So what does this query Selector does ? Before going into this lets see the syntax  of this function.
document.querrySelector(‘idname’);
Let’s see how its work?
If we have a HTML file like this.
<div>
<p id=’Australia’>Melbourne</p>
<p id=’US’>New York</p>
<p id=’Australia’>Sydney</p>
</div>
And now if you use function like document.querySelector(‘australia’).style.color =’red’; in your JavaScript file it will change the color of only first element with the id Australia to red. It means the Melbourne will turn into red and Sydney will not any effect on it.
There  is one more function  called document.querySelectorAll . If you will use this function like document.querySelectorAll(‘Australia’).style.color =’red’; it will turn all the elements associated with the Australia. It means it will turn Melbourne as we Sydney into red.
Read more ►

Thursday, January 24, 2013

how to move a div using javascript

4 comments
This tutorial is for how to move a DIV using java script . Here is the example  for moving a div by the help of javascript .
 
You have to make the div position Absolute for older browser . I made the ufo div position absolute for getting the div move using javascript  .


<html>
<head>
<style>
#ufo
{
position:absolute;}
</style>
<script>
function initial()
{
document.getElementById('ufo').style.left=200+'px';
document.getElementById('ufo').style.top=200+'px';
}
function right(){
document.getElementById('ufo').style.left=parseInt(document.getElementById('ufo').style.left)-5+'px';
}
function left(){
document.getElementById('ufo').style.left=parseInt(document.getElementById('ufo').style.left)+5+'px';
}
function top(){
document.getElementById('ufo').style.top=parseInt(document.getElementById('ufo').style.top)+5+'px';
}
function down(){
document.getElementById('ufo').style.top=parseInt(document.getElementById('ufo').style.top)-5+'px';
}
</script>
<link rel="stylesheet" href="main.css">
</head>
<body onload="initial()">
<div id = "ufo">
i am a moving dig. bring mouse over me fellas !!!! </div>
<button id="button" onClick="right();">Press here to move left</button>
<button id="button" onClick="left();">press here to move light</button>
<button id="button" onClick="top();">press here to move down</button>
<button id="button" onClick="down();">press here to move up</button>
</body>
</html>


If you wanna get animation using CSS3 in this . Here is the code for CSS3 make some animation .


#ufo
{
position:absolute;
display:block;
margin:auto;
text-align:center;
width:100px;
height:100px;
border:1px solid blue;
-webkit-transform:rotate(20deg);
background:-webkit-linear-gradient(top,yellow,green);
-webkit-border-radius:25px;
-webkit-box-shadow:rgba(110,110,110,.4) -10px 10px 10px;
text-shadow:rgba(110,110,110,.7) -1px 2px 3px;
}
#ufo:hover
{
width:200px;
height:200px;
-webkit-transform:rotate(70deg);
}
#button
{
height:30px;
weight:100px;
-webkit-transform:rotate(350deg);
margin:auto;
background:-webkit-linear-gradient(top,red,yellow);
-webkit-border-radius:25px;
-webkit-box-shadow:rgba(110,110,110,.4) -10px 10px 10px;

Any doubt any query related to  this comment bellow .
Read more ►