Related Posts Plugin for WordPress, Blogger...
Custom Search
Showing posts with label Javascript. Show all posts
Showing posts with label Javascript. Show all posts

Thursday, September 8, 2011

The Great Popular Posts With 3D Cube Animation




I previously said that this widget is great, I think so, hopefully as well as for you. With this widget loading my homepage seems to be lighter and more efficient, and not much need of a place or space. A brilliant innovation.
This widget I adopted from the work of our blogger friends Abu Farhan and hopefully you be willing to pages linked his site.



Below I wrote down how to make it.

This script very easy to install, you only have to put the script to the new Gadget :

  • Login to Blogger Dashboard and navigate to Design – Page Elements
  • Click “Add Gadget” and Choose “Popular Posts”(If you already have this gadget skip this step)
  • After you have Popular Post Gadget “Add Gadget” again and select “HTML/Javascript”
  • Put all script bellow to the “Content” of HTML/Javascript Gadget

<style type="text/css">
.cube { width: 200px; height: 200px;}
a img { border: none; }
#linksCube img { width: 100%; height: 100%; }
</style>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js" type="text/javascript">
</script>
<script src="http://accordion-for-blogger.googlecode.com/svn/trunk/jqueryimagecube.js" type="text/javascript">
</script>
<script charset="utf-8" type="text/javascript">
$(function () {
$('.popular-posts ul').abupopularcube();
});
</script>
<script src="http://accordion-for-blogger.googlecode.com/svn/trunk/popularcube.js" type="text/javascript">
</script>

  • Done- your popular post now with animation


Good luck, hope you like it and useful for your web page.



Free Sitemap Generator

Friday, August 26, 2011

Page Visibility API




A major pain point for web developers is knowing when users are actually interacting with the page. If a page is minimized or hidden behind another tab, it may not make sense to continue functionality such as polling the server for updates or performing an animation. The Page Visibility API aims to give developers information about whether or not the page is visible to the user.
The API itself is very simple, consisting of three parts:
  • document.hidden – A boolean value indicating if the page is hidden from view. This may mean the page is in a background tab or that the browser is minimized.
  • document.visibilityState – A value indicating one of four states:
    1. The page is in a background tab or the browser is minimized.
    2. The page is in the foreground tab.
    3. The actual page is hidden but a preview of the page is visible (such as in Windows 7 when moving the mouse over an icon in the taskbar).
    4. The page is being prerendered off screen.
  • The visibilitychange event – This event fires when a document changes from hidden to visible or vice versa.
As of the time of this writing, only Internet Explorer 10 and Chrome (12+) have implemented the Page Visibility API. Internet Explorer has prefixed everything with “ms” while Chrome has prefixed everything with “webkit”. So document.hidden is implemented as document.msHidden in Internet Explorer and document.webkitHidden in Chrome. The best way to check for support is with this code:

function isHiddenSupported(){
return typeof (document.hidden || document.msHidden || document.webkitHidden) != "undefined";
}

To check to see if the page is hidden, the following can be used:To check to see if the page is hidden, the following can be used:


function isPageHidden(){
return document.hidden || document.msHidden || document.webkitHidden;
}


Note that this code will indicate that the page is not hidden in unsupporting browsers, which is the intentional behavior of the API for backwards compatibility.
To be notified when the page changes from visible to hidden or hidden to visible, you can listen for the visibility change event. In Internet Explorer, this event is called msvisibilitychange and in Chrome it’s called webkitvisibilitychange. In order to work in both browsers, you need to assign the same event handler to each event, as in this example:


function handleVisibilityChange(){
var output = document.getElementById("output"),
msg;

if (document.hidden || document.msHidden || document.webkitHidden){
msg = "Page is now hidden." + (new Date()) + ""
} else {
msg = "Page is now visible." + (new Date()) + ""
}

output.innerHTML += msg;

}

//need to add to both
document.addEventListener("msvisibilitychange", handleVisibilityChange, false);
document.addEventListener("webkitvisibilitychange", handleVisibilityChange, false);


This code works well in both Internet Explorer and Chrome. Further, this part of the API is relatively stable so it’s safe to use the code in real web applications.


Differences

The biggest difference between the implementations is with document.visibilityState. Internet Explorer 10 PR 2′s document.msVisibilityState is a numeric value representing one of four constants:
  1. document.MS_PAGE_HIDDEN (0)
  2. document.MS_PAGE_VISIBLE (1)
  3. document.MS_PAGE_PREVIEW (2)
  4. document.MS_PAGE_PRERENDER (3)
In Chrome, document.webkitVisibilityState is one of three possible string values:
  1. “hidden”
  2. “visible”
  3. “prerender”
Chrome does not feature constants for each state, though the final implementation will likely contain them.
Due to these differences, it’s recommended not to rely on the vendor-prefixed version of document.visibilityState and instead stick to using document.hidden.

Uses

The intended use of the Page Visibility API is to signal that to the page that the user isn’t interacting with the page. You can use that information to, for example, stop polling for updates from the server or stop animations (though if you’re using requestAnimationFrame(), that will happen automatically).
After a little thought, I realized that the Page Visibility API is much more about the user than it is about the page. The component now fires the idle event when the page becomes hidden and the active event when the page once again becomes visible.
Whether using the Idle Timer, or the Page Visibility API on its own, this new functionality gives web developers a much-needed peek into what the browser is doing with our web application. I hope to see many more great advancements coming from the W3C Performance group.



Free Sitemap Generator

Thursday, August 25, 2011

Contain CSS and JavaScript in External Files




Many of these performance rules deal with how external components are managed. However, before these considerations arise we should ask a more basic question: Should JavaScript and CSS be contained in external files, or inlined in the page itself?

Using external files in the real world generally produces faster pages because the JavaScript and CSS files are cached by the browser. JavaScript and CSS that are inlined in HTML documents get downloaded every time the HTML document is requested. This reduces the number of HTTP requests that are needed, but increases the size of the HTML document. On the other hand, if the JavaScript and CSS are in external files cached by the browser, the size of the HTML document is reduced without increasing the number of HTTP requests.

The key factor, then, is the frequency with which external JavaScript and CSS components are cached relative to the number of HTML documents requested. This factor, although difficult to quantify, can be gauged using various metrics. If users on our site have multiple page views per session and many of our pages re-use the same scripts and stylesheets, there is a greater potential benefit from cached external files.

Many web sites fall in the middle of these metrics. For these sites, the best solution generally is to deploy the JavaScript and CSS as external files. The only exception where inlining is preferable is with home pages. Home pages that have few (perhaps only one) page view per session may find that inlining JavaScript and CSS results in faster end-user response times.

For front pages that are typically the first of many page views, there are techniques that leverage the reduction of HTTP requests that inlining provides, as well as the caching benefits achieved through using external files. One such technique is to inline JavaScript and CSS in the front page, but dynamically download the external files after the page has finished loading. Subsequent pages would reference the external files that should already be in the browser's cache.



Free Sitemap Generator

Sunday, August 21, 2011

Script to Display The Name and Title of The Article After The Copy




Our discussion this time about the script, which at the time of our article in the copy and paste, the script will display the title and the name of our blog in an article in the copy and paste it. I am sure many may already know this script, but there is no harm in sharing the material we make as we are this time.

This is the following steps:

  • Log in to Blogger with your Google Account
  • Go to Design --&gt; Edit HTML
  • Insert the following script after the code  <head>

<script type='text/javascript'>
function addLink() {
    var body_element = document.getElementsByTagName('body')[0];
    var selection;
    selection = window.getSelection();
    var pagelink = "<br/><br/> Read more at: <a href='"+document.location.href+"'>"+document.location.href+"</a><br/>Copyright  infoblog-infoblogging.blogspot.com Under Common Share Alike Atribution"; // change this if you want
    var copytext = selection + pagelink;
    var newdiv = document.createElement('div');
    newdiv.style.position='absolute';
    newdiv.style.left='-99999px';
    body_element.appendChild(newdiv);
    newdiv.innerHTML = copytext;
    selection.selectAllChildren(newdiv);
    window.setTimeout(function() {
        body_element.removeChild(newdiv);
    },0);
}document.oncopy = addLink;
</script>



  • Replace the URL infoblog-infoblogging.blogspot.com on the script with the URL of your blog.
  • Save the template.
  • Done.

If you perform the steps above correctly then try the test on your blog, your own copy of the article continues to put in notepad. And then what happens, there's your blog URL in the article at the bottom.
But there are drawbacks of this script, when to turn off javascript in their browser, this script will not work, and I am sure this script has a lot of blogger who know it especially reliable.

Good luck. Even if there is something wrong, please comment how to be better.



Free Sitemap Generator

Subscribe to Posts (Atom)

Add to Google Reader or Homepage

Subscribe in Bloglines


Subscribe via Email



Get Tweets!

 
Return to Top