web etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster
web etiketine sahip kayıtlar gösteriliyor. Tüm kayıtları göster

31 Mayıs 2011 Salı

javascript ajax long polling- with jQuery

Specific methods of implementing Comet fall into two major categories: streaming and long polling.

Streaming

An application using streaming Comet opens a single persistent connection from the client browser to the server for all Comet events. These events are incrementally handled and interpreted on the client side every time the server sends a new event, with neither side closing the connection.[3]

Specific techniques for accomplishing streaming Comet include the following:

Hidden iframe

A basic technique for dynamic web application is to use a hidden iframe HTML element (an <I>inline frame</I>, which allows a website to embed one HTML document inside another). This invisible iframe is sent as a chunked block, which implicitly declares it as infinitely long (sometimes called “forever frame”). As events occur, the iframe is gradually filled with script tags, containing JavaScript to be executed in the browser. Because browsers render HTML pages incrementally, each script tag is executed as it is received.[11]

One benefit of the iframe method is that it works in every common browser. Two downsides of this technique are the lack of a reliable error handling method, and the impossibility of tracking the state of the request calling process.[11]

XMLHttpRequest

The XMLHttpRequest (XHR) object, the main tool used by Ajax applications for browser–server communication, can also be pressed into service for server–browser Comet messaging, in a few different ways.

In 1995, Netscape Navigator added a feature called “server push”, which allowed servers to send new versions of an image or HTML page to that browser, as part of a multipart HTTP response (see History section, below), using the content type multipart/x-mixed-replace. Since 2004, Gecko-based browsers such as Firefox accept multipart responses to XHR, which can therefore be used as a streaming Comet transport.[12] On the server side, each message is encoded as a separate portion of the multipart response, and on the client, the callback function provided to the XHR onreadystatechange function will be called as each message arrives. This functionality is only included in Gecko-based browsers, though there is discussion of adding it to WebKit.[13]

Instead of creating a multipart response, and depending on the browser to transparently parse each event, it is also possible to generate a custom data format for an XHR response, and parse out each event using browser-side JavaScript, relying only on the browser firing the onreadystatechange callback each time it receives new data.

Ajax with long polling

None of the above streaming transports works across all modern browsers without negative side-effects. This forces Comet developers to implement several complex streaming transports, switching between them depending on the browser. Consequently many Comet applications use long polling, which is easier to implement on the browser side, and works, at minimum, in every browser that supports XHR. As the name suggests, long polling requires the client to poll the server for an event (or set of events). The browser makes an Ajax-style request to the server, which is kept open until the server has new data to send to the browser, which is sent to the browser in a complete response. The browser initiates a new long polling request in order to obtain subsequent events.

Specific technologies for accomplishing long-polling include the following:

XMLHttpRequest long polling

For the most part, XMLHttpRequest long polling works like any standard use of XHR. The browser makes an asynchronous request of the server, which may wait for data to be available before responding. The response can contain encoded data (typically XML or JSON) or Javascript to be executed by the client. At the end of the processing of the response, the browser creates and sends another XHR, to await the next event. Thus the browser always keeps a request outstanding with the server, to be answered as each event occurs.

Script tag long polling

While any Comet transport can be made to work across subdomains, none of the above transports can be used across different second-level domains (SLDs), due to browser security policies designed to prevent cross-site scripting attacks.[14] That is, if the main web page is served from one SLD, and the Comet server is located at another SLD, Comet events cannot be used to modify the HTML and DOM of the main page, using those transports. This problem can be side-stepped by creating a proxy server in front of one or both sources, making them appear to originate from the same domain. However, this is often undesirable for complexity or performance reasons.

Unlike iframes or XMLHttpRequest objects, script tags can be pointed at any URI, and JavaScript code in the response will be executed in the current HTML document. This creates a potential security risk for both servers involved, though the risk to the data provider (in our case, the Comet server) can be avoided using JSONP.

A long-polling Comet transport can be created by dynamically creating script elements, and setting their source to the location of the Comet server, which then sends back JavaScript (or JSONP) with some event as its payload. Each time the script request is completed, the browser opens a new one, just as in the XHR long polling case. This method has the advantage of being cross-browser while still allowing cross-domain implementations.[14]

referrer : http://en.wikipedia.org/wiki/Comet_%28programming%29

<script type="text/javascript">

 

    $(document).ready(function () {

 

        var ctr = 1;

        $.PeriodicalUpdater('@Url.Content("~/SupportService/MessageQueue")', {

            minTimeout: 10 * 1000,

            maxTimeout: 10 * 60 * 1000,

            multiplier: 2.3,

            type: 'json',

            data: function () { return ctr++; },

            cache: true

        }, function (data) {

            $('#curtime').html(data.curtime);

        });

 

    });

 

</script>

jsfile : https://github.com/RobertFischer/JQuery-PeriodicalUpdater/

demo   : http://demo.smokejumperit.com/demo.html

RobertFischer / JQuery-PeriodicalUpdater

A port of Prototype's Ajax.PeriodicalUpdater function to jQuery.

Basically, this function polls some remote service at fairly regular internvals, and (optionally) processes the result via a callback. The period of calls will decay as long as the same response keeps coming back from the server (either in the form of repeated data or in the form of a 304 Not Modified status), which reduces the load on the server naturally. The first Ajax call happens as a page 'onReady' handler (ie: the jQuery(function) call), so it is safe to put the PeriodicalUpdater call anywhere on the page.

Usage: $.PeriodicalUpdater('/path/to/service', { method: 'get', // method; get or post data: '', // array of values to be passed to the page - e.g. {name: "John", greeting: "hello"} minTimeout: 1000, // starting value for the timeout in milliseconds maxTimeout: 8000, // maximum length of time between requests multiplier: 2, // the amount to expand the timeout by if the response hasn't changed (up to maxTimeout) type: 'text', // response type - text, xml, json, etc. See $.ajax config options maxCalls: 0, // maximum number of calls. 0 = no limit. autoStop: 0 // automatically stop requests after this many returns of the same data. 0 = disabled. }, function(remoteData, success, xhr, handle) { // Process the new data (only called when there was a change) });

The "data" value can be one of three things:

  • A scalar, in which case it will be used constantly.
  • A JSON map/object, in which case it will be turned into key/value pairs by jQuery
  • An anonymous function, in which case it will be executed before each AJAX call. See jQuery.ajax for more information.

Any of the other standard $.ajax configuration options can be passed to the setting map.
The only exception is the flag that treats modifications as errors. That’s always going to be 'true'.

The function call returns a handle. You can call .stop() on this handle in order to stop the updating and ignore any subsequent responses. If the maximum number of calls, .stop(), or the autoStop has been triggered, you can restart the updater using .restart() on the handle. This handle is also passed into the callback function as the fourth argument.

More info, including advantages over 360innovate version, see the blog post on EnfranchisedMind.

referrer: https://github.com/RobertFischer/JQuery-PeriodicalUpdater/blob/master/README.md

 

13 Haziran 2009 Cumartesi

http://soswitcher.blogspot.com/

Blogger – Ping that Blog Post

Pinging a new Blogger Post, with a long list of Ping Services can be very easy for any blogger that publishes their new blog post with “Windows Live Writer”.

What is pinging, you ask?bloggerping2

Pinging a Blogger blog post, is a quick way to notify search engines that you have just published new content on your blog. Sure the search engines will crawl your new blog post eventually on their own. Why wait for the search engines to decide when to visit your blog?

This is why pinging a blog is beneficial, by pinging our own blog, we give a boost to our new blog post, to allow them to be updated on search engines like Google, sooner rather than later.

We can use services like pingomatic.com to manually ping a list of servers, or for everyone that works with “Windows Live Writer”, we can enjoy the benefits of having our new blog post ping every single server in the list below automatically, each time we post a new Blogger post, here’s how.

  • Copy the list of URL’s below
  • Open “Windows Live Writer”, & go to Tools –> Options –> Ping Servers
  • Paste the list of servers into the textbox, in the “Ping Servers” textbox
  • Click: Apply –> Ok

Blogger Ping

<----- Start List ----->

http://blogsearch.google.com/ping/RPC2
http://rpc.technorati.com/rpc/ping
http://ping.feedburner.com/
http://1470.net/api/ping
http://api.feedster.com/ping
http://api.moreover.com/RPC2
http://api.moreover.com/ping
http://api.my.yahoo.com/RPC2
http://api.my.yahoo.com/rss/ping
http://bblog.com/ping.php
http://bitacoras.net/ping
http://blog.goo.ne.jp/XMLRPC
http://blogdb.jp/xmlrpc
http://blogmatcher.com/u.php
http://bulkfeeds.net/rpc
http://coreblog.org/ping/
http://mod-pubsub.org/kn_apps/blogchatt
http://www.lasermemory.com/lsrpc/
http://ping.amagle.com/
http://ping.bitacoras.com
http://ping.blo.gs/
http://ping.bloggers.jp/rpc/
http://ping.cocolog-nifty.com/xmlrpc
http://ping.blogmura.jp/rpc/
http://ping.exblog.jp/xmlrpc
http://ping.myblog.jp
http://ping.rootblog.com/rpc.php
http://ping.syndic8.com/xmlrpc.php
http://ping.weblogalot.com/rpc.php
http://ping.weblogs.se/
http://pingoat.com/goat/RPC2
http://rcs.datashed.net/RPC2/
http://rpc.blogbuzzmachine.com/RPC2
http://rpc.blogrolling.com/pinger/
http://rpc.icerocket.com:10080/
http://rpc.newsgator.com/
http://rpc.pingomatic.com
http://rpc.weblogs.com/RPC2
http://topicexchange.com/RPC2
http://trackback.bakeinu.jp/bakeping.php
http://www.a2b.cc/setloc/bp.a2b
http://www.bitacoles.net/ping.php
http://www.blogdigger.com/RPC2
http://www.blogoole.com/ping/
http://www.blogoon.net/ping/
http://www.blogpeople.net/servlet/weblogUpdates
http://www.blogroots.com/tb_populi.blog?id=1
http://www.blogshares.com/rpc.php
http://www.blogsnow.com/ping
http://www.blogstreet.com/xrbin/xmlrpc.cgi
http://www.mod-pubsub.org/kn_apps/blogchatter/ping.php
http://www.newsisfree.com/RPCCloud
http://www.newsisfree.com/xmlrpctest.php
http://www.popdex.com/addsite.php
http://www.snipsnap.org/RPC2
http://www.weblogues.com/RPC/
http://xmlrpc.blogg.de
http://xping.pubsub.com/ping/

<----- End List ----->

Technorati Tags: Blogger,Ping,Blog,Windows Live Writer

Read more...

Labels: Blogger, Ping, Windows Live Writer
Posted by Switcher at Tuesday, June 09, 2009

0 comments

Saturday, May 30, 2009

Blogger – Feedburner in Google Images

Blogger & Feedburner are both great Google products. Did you know Feedburner images, posted on Blogger, will show up in Google Images, as a Feedburner .GIF image?feedburner

I actually found this out by searching for one of my blog post Titles, to see what images are showing up on Google Images.

This will only work If you already have a Feedburner account setup, & have the Feedurner image posted on your Blogger site.

So If you already have the Feedburner Feed on your blog, try this:

  • Go to Google Images
  • Search for one of your Blogger post Titles & only the name of your blog (example:SoSwitcher) not the end (example: .blogspot.com)
  • My Google Image search looks like this “Blogger Ad Code Converter soswitcher”
  • Below is the result image from my search , it’s not an active URL, just the image.

Something else that is cool, the above image will always be updated with the newest content from my blog, since it’s an animated .GIF, while it still shows on Google Images.

What’s funny is, my search results show more links pointing to bloggertricks, than my own blog (lol).

This might not look like a big deal, having a single image on the net, the way I see it, every little bit helps a future visitor find my blog. :)

Switcher

Technorati Tags: Blogger,Feedburner,Image

Read more...

Labels: Blogger, Feedburner, Google
Posted by Switcher at Saturday, May 30, 2009

0 comments

Thursday, May 28, 2009

Blogger - Change Page Title Tags for your Blog

I was doing some research on my blog post Blogger Ad Code Converter, & found I didn’t like the way the Google Search results showed only the word “SoSwitcher”. What I really wanted was for each of my blog post Title to not only be on the Google Search, but for it to be first words of the Title, from left to right.BloggerPageTitle

So, I searched Google & found a nice code snippet that would work, I added the code to my template & remembered reading a blog post a while back that someone said your blog page would load a little bit faster (maybe something like 1000th of a second faster, HA!), any way it made sense to me, instead of using the Blogger tag (example: <data:blog.title/>) for your Blogger Template to call up your blogs URL, to just hard code the URL (example: soswitcher.blogspot.com), since I’m already editing the Blogger template.

You don’t have to stop at just your Page Title either, If you notice some of the big names on the web, like Amazon, or Ebay, they both add keywords to their websites Title, & you’ll also notice that both Amazon & Ebay, also have those same keywords in their Google Search results.

Below is the Blogger Code that I added to my Template:

<b:if cond='data:blog.pageType == &quot;index&quot;'> <title>SoSwitcher</title> <b:else/> <title><data:blog.pageName/> SoSwitcher</title> </b:if>

I decided not to put the URL in my Page Title, but instead add the single word “SoSwitcher”.

So the code in the textbox above will look like this:

  • Index Page Title – SoSwitcher
  • Each Post Page Title – Post Title + SoSwitcher

I might be adding some keywords in the mix, sometime soon .

Switcher

Technorati Tags: Blogger,Title,Tag,Page

Read more...

Labels: Blogger
Posted by Switcher at Thursday, May 28, 2009

0 comments

Tuesday, May 26, 2009

Blogger Ad Code Converter

Have you ever wanted to add Google Adsense code inside your Blogger Template, & found it’s not a simple copy & paste job?

Well, now your in luck!

I built a Google Widget that will allow you to convert Google Adsense code into Blogger xhtml code, & not only that, you can also add the Blogger Code Converter to your webpage or blog, since it’s a Google Widget.

The code converter is simple to use:BloggerCode

  • Copy the code you want to convert (Right click – Copy)
  • Paste that code into the code converter textbox (Right click – Paste)
  • Press the button at the bottom of the widget “Convert Code”
  • (Right click – Select All) of the converted code in the Code Converter textbox
  • (Right click – Copy) the converted code in the Code Converter textbox
  • Paste the newly converted code into your Blogger template, etc…

I’ve added the New Google Code Converter to my sidebar, on the lower right side. The Code Converter size can be adjusted, when you go to get the code from the Google button below.

Note:

It’s up to anyone that uses this widget to double check the Google Code Converter Widget code, for any mistakes, I’ve been working with this for a while, with no problems. Please let me know of any issues or suggestions you might have, with this widget, by adding comments below.

You can click on the Google button below to add this Widget to your own blog.

Blogger Code Converter Widget

Blogger Ad Code Converter

Gadgets powered by Google

Technorati Tags: Adsense,Google,Convert Code,Widget

Read more...

Labels: Adsense, Blogger, Code
Posted by Switcher at Tuesday, May 26, 2009

2 comments

Saturday, May 16, 2009

Blogger - Host Javascript File for Free

If you have ever downloaded a Free Blogger template or Widget, you might find that it includes javascript files that link to the blog designers website, or file sharing site. It’s never a good idea as a long term blogger to leave any external links in your blog template that you don’t have control over. The reason you always need to control your templates links:javascript

  • Blog Designers site goes down
  • Blog Designers site bandwidth has reached it’s maximum limit
  • As a Blog Designer you might be hosting your personal site javascript files on the very same account, that your Free Blogger Templates javascript files are hosted, so If you have 1,000 free downloaded templates floating around cyber space, and none of them change the javascript URL, they are all pulling bandwidth from your personal javascript site host.

Bottom line is, control is everything, nobody likes a broken blog.

Below is an easy & Free way to host all your javascript files on your very own Free Google website:

1) Sign up for a Free Google Sites website

2) Create a new Google Sites webpage

3) Get the URL/link of the javascript that is hard coded into your New Blogger template (example: http://www.YourWebsite/YourNewJavascriptFile.js )

4) Download the javascript file to your local PC

5) Open the javascript file in a text editor (Microsoft Notepad, etc…)

6) Save the javascript text file as a regular text file, so our example file in the above URL will look like this: (example: YourNewJavascriptFile.txt )

7) Upload the New Text file to your Google Sites website

8) Right click & Copy on your New uploaded .txt file on your Google webpage, & get the URL/link (example: http://sites.google.com/site/YourGoogleWebsite/Webpage1/YourNewJavascriptFile.txt )

9) Right click Paste the new URL/Link into your Blogger template

You have now hosted your javascript file on your own Free website, not to mention Google is great about keeping their servers running at 99.99% of the time.

A word of advice, Google once had a Free website hosting a while back, Google has since shut down new members to the first Free website, so grab a free site while you can, you never know If they will stop new members from the second Free websites (Google Sites). Also the old members still have active Google websites, just no new members, get them while you can, you never know when you’ll need it to host files.

The right sidebar includes a working example of how I’m hosting a “Recent Post Thumbnails Widget for Blogger” javascript file on my own Google Site, to prevent any future broken links.

Read more...

Labels: Blogger, Javascript
Posted by Switcher at Saturday, May 16, 2009

8 comments

Friday, May 15, 2009

Blogger Poll – Add to Blog Post

Over on the BloggerTricks Forums, John Cena asked If it was possible, & how to add a Blogger Widget Poll to a Blog Post. The short answer is yes, it is possible to add a Blogger (Widget based) Poll to a Blogger Post, you'll have to work with some basic HTML.

1) Create a "Blogger Widget Poll" inside your sidebar, just like you've done before. Make sure to give it an easy to find/remember Title.
BloggerPoll

2) After the Blogger Widget Poll, is added to your sidebar, visit your blogs HomePage in your Browser (I'm working with Internet Explorer as my Browser).

3) After you have your HomePage loaded into your Browser window, Go to the top Toolbar & View/Source (of your blogs Homepage) HTML.

4) In a text editor (Windows Notepad) etc... Find/Search for the Title to your new Polls Title.

5) Copy (Right Click/Copy) the HTML Code that looks similar to the code below:

<h1>How do you like my blog?</h1> <iframe allowtransparency="true" frameborder="0" height="275" scrolling="no" name="poll-widget8782362485789065652" src="http://www.google.com/reviews/polls/display/8782362485789065652/blogger_template/run_app?hideq=true&amp;purl=http%3A%2F%2Fsoswitcher.blogspot.com%2F" style="border:none; width:275;"></iframe>

6) Paste your new Polls HTML into your Blogger Post/Article.

7) After you get the Blogger Widget HTML, you can go ahead & delete the Blogger Widget Poll, from your Sidebar, we only needed that to get the HTML source code.

Note:
The actual Poll is inside an Iframe, I also added bit of HTML code to prevent the Poll from adding a scrollbar to the Poll, I didn’t like the way it looks witha scrollbar on the Poll inside a Blog Post, so this is just an option, to remove scrollbars, after the (height="275") add this code (scrolling="no").

Once you have the Polls HTML Code, you can change a few things to make it look better in your Blog Post, for example, Blogger sets the default width of a Blogger Poll to 100%, If you want to add a Poll to a Post/Article I think it would look better as a fixed number (example: width:275), the same goes for the Poll Height, Iframe border etc...

This is the first time I've tried this, deleting a Poll & still keep the HTML, so I want to thank John Cena for the idea.

Below is a working example of a Blogger Widget Poll, inserted in a Blogger Blog Post.

Switcher

 

reference : http://soswitcher.blogspot.com/

imdb plugin

Insert IMDb Info

Allows you to search IMDb and then insert film details into your blog entry within Windows Live Writer
This plugin was made using the ImdbServices wrapper at http://www.codeplex.com/imdb
Feedback should be sent to wlm@scottisafool.co.uk or http://scottisafooldev.spaces.live.com/
NOTE: REQUIRES .NET 3.5!

refer :http://gallery.live.com/liveItemDetail.aspx?li=aa71d18d-e738-475d-85fa-198c64ea3987&bt=9

a lot of free Icons

Animals
Arts
Cartoons
Cinema
Computer
Folders
Food
Games
Hardware
Miscellanea
Music
Pc collection2
Pc collections
People
Sistemi operativi
Smilies
Software
Sport


http://icone.goldenweb.it/