DCSIMG
June 2009 - Posts - Guy Burstein's Blog

Guy Burstein's Blog

Developer Evangelist @ Microsoft

News

Guy Burstein The Bu

Disclaimer
Postings are provided 'As Is' with no warranties and confer no rights.

Guy Burstein LinkedIn Profile

TwitterCounter for @bursteg

June 2009 - Posts

How to build a Simple IE8 Accelerator

How to build a Simple IE8 Accelerator

This post is a step by step guide for building IE8 Accelerators.

A Short Introduction to IE8 Accelerators

Accelerators are used to make the user more productive while surfing the net, by:

How to build a Simple IE8 Accelerator 1. Speeding up the process of getting additional information about a meaningful string (address, stock quote, a product, a twitter account name, etc). In this sample

2. Allowing user to perform a quick action on a selected text.

From a technical perspective, Accelerators define 2 actions: Preview and Execute. When the user selects some text and hover over an accelerator, the Preview action is being performed - the selected text is sent to a defined url, that returns a 320x240 web page with a preview of the data.
When the user clicks the Accelerator, the Execute action is performed and the browser navigates to a page passing it the selected text as a parameter.

To build IE8 Accelerators, we have several steps to do:

  1. Building an Accelerator Page
  2. Defining the Accelerator OpenService Xml
  3. Registering the Accelerator with IE8
  4. Using the Accelerator

To make sure this guide is generic enough for every Accelerator you may think of and not just for Twitter profiles, I am leaving the twitter logic to the last part of this post.

1. Building an Accelerator Page

Create a new ASP.Net Web Application in Visual Studio 2008 or open an existing one.

Add a new Web Form for the Accelerator Preview. In the page code behind, extract the query string parameters write them to the Response object:

protected void Page_Load(object sender, EventArgs e)

{

  foreach (string param in Request.QueryString.AllKeys)

  {

    Response.Write(param + " = " + Request.QueryString[param] + "<br />");

  }

}

Test the page: Navigate to the accelerator’s url, and add several parameters. For example:

http://localhost:16319/ShowTwitterUser.aspx?data1=guy&data2=burstein

How to build a Simple IE8 Accelerator  

Defining the Accelerator OpenService Xml

In order to register the Accelerator with a user’s browser, we have to create an xml file with the details of the Accelerator.

Add an Xml file to the web application that defines the Accelerators metadata required by the browser.

<openServiceDescription
     
xmlns=http://www.microsoft.com/schemas/openservicedescription/1.0>

  <homepageUrl>http://www.bursteg.net/</homepageUrl>

  <display>

    <name>Twitter Profile Accelerator</name>

    <icon>http://www.twitter.com/favicon.ico</icon>

  </display>

  <activity category="Define">

    <activityAction context="selection">

      <preview action="http://www.bursteg.net/Twitter/ShowTwitterUser.aspx">

        <parameter name="selection" value="{selection}" />

      </preview>

      <execute action="http://www.bursteg.net/Twitter/ShowTwitterUser.aspx">

        <parameter name="documentUrl" value="{documentUrl}" />

        <parameter name="documentTitle" value="{documentTitle}" />

        <parameter name="documentDomain" value="{documentDomain}" />

        <parameter name="documentHost" value="{documentHost}" />

        <parameter name="selection" value="{selection}" />

      </execute>

    </activityAction>

  </activity>

</openServiceDescription>

Few things to notice in the Accelerator Xml:

1. There is some meta data about the accelerator such as homepage Url and the display name and icon.

2. The Activity node defines a category to which this accelerator belongs to. There are some default categories like Map, Translate, Blog etc, but users can manage their categories using the Manage Add-ons Dialog.

3. As described earlier, the accelerator defines 2 actions, preview and execute, each defines a Url to call to when clicked / previewed, and several parameters to pass to the target page.

Register the Accelerator with the User’s Browser

In a page of your chose (for example Default.aspx) add a button that registers the accelerator when clicked:

<input id="btnRegister" type="button" value="Add Accelerator to IE8" 
      onclick="BLOCKED SCRIPTwindow.external.AddService('TwitterProfileAccelerator.xml');" />

How to build a Simple IE8 Accelerator

When the user clicks on the above button, a dialog pops us asking his permission to add this accelerator to his browser, and whether to make it the default accelerator in its category.

How to build a Simple IE8 Accelerator

Using the Accelerator

After the user has added the accelerator to his browser he can start using it. Select some text and the accelerator box will appear next to it. Click on it add hover over the new accelerator. This should make an HTTP request to the accelerator page passing it the text you have selected.

How to build a Simple IE8 Accelerator

If you click on the accelerator, IE8 will open the target page in a new tab passing it the selected text and additional information as defined in the accelerator xml.

How to build a Simple IE8 Accelerator

Summary

In this pot I took the steps needed to build an accelerator. You can follow them you build your own accelerators and add additional logic to provide more interaction with your uses.

Enjoy!

Posted: Jun 29 2009, 01:08 PM by Guy Burstein | with 8 comment(s)
תגים:,

חיפוש מוצרים באתר זאפ עם Internet Explorer 8

חיפוש מוצרים באתר זאפ עם Internet Explorer 8

חיפוש מוצרים באתר זאפ עם Internet Explorer 8אתמול קיבלתי מייל מחבר שלי:

“לא תאמין – היום חברה שלי ואני חוגגים שנה יחד, ואני מחפש לה מתנה. אני חייב לצאת גדול כי היא קנתה לי Xbox !!!”

אני לא יודע מה התגובה הראשונה שלכם כשאתה קוראים את מה שחבר שלי כתב לי, אבל הדבר הראשון שעלה לי לראש זה – בואו נראה כמה באמת החברה שלו השקיעה…
אז כדי לדעת כמה בימינו אלה עולה Xbox, סביר להניח שהייתי פותח טאב חדש, גולש לאתר השוואת המחירים – זאפ ומבצע חיפוש למחרוזת Xbox כדי לראות כמה הוא עולה.

עם Internet Explorer 8, זה הרבה יותר פשוט. כאשר מסמנים טקסט כלשהו באינטרנט, פתאום מופיע הלחצן הכחול הזה:

חיפוש מוצרים באתר זאפ עם Internet Explorer 8

שכאשר לוחצים עליו, נפתחת רשימה של Accelerators (או בעברית – מאיצי גלישה) שמאפשרים לי להפעיל כל מיני שירותים על הטקסט שסימנתי. לדוגמא, אני יכול להפעיל את ה- Accelerator של חיפוש פריטים בזאפ ולקבל את התוצאה הבאה:

חיפוש מוצרים באתר זאפ עם Internet Explorer 8

ה- Accelerator פונה לאתר זאפ, ומציג לי את הפריטים שעונים לשם Xbox עם התמונה שלהם, טווחי המחירים ומידע נוסף. ובשביל לקבל את כל זה הייתי צריך בסך הכל לסמן טקסט ולהפעיל Accelerator. הרבה יותר פשוט מקודם!

אם גם אתם רוצים להוסיף את ה- Accelerator של חיפוש פריטים בזאפ ל- Explorer שלכם, תוכלו לעשות את זה מתוך גלריית ההרחבות של Internet Explorer 8 שמכילה עוד הרבה הרחבות שפותחו ע”י אתרים מובילים בארץ. את כל ההרחבות של אתר זאפ תוכלו למצוא כאן.

בהמשך אספר על עוד הרחבות ל- Internet Explorer 8 שפותחו בארץ…

תהנו!

Getting Started with jQuery in Visual Studio 2008

Getting Started with jQuery in Visual Studio 2008

jQuery IntellSense in Visual Studio 2008

In this post I’ll talk about adding jQuery IntellSense in Visual Studio 2008, and how to add jQuery to a simple Web Application inside Visual Studio 2008.

jQuery IntelliSense in Visual Studio 2008 - KB946581

In order to use jQuery in Visual Studio 2008 with IntelliSence a hotfix for Visual Studio 2008 must be installed:

  1. Download the hotfix from Connect
  2. Run the executable and extract its contents to a folder in your hard drive.
  3. Make sure all instances of Visual Studio 2008 are closed, and run VS90-KB946581.exe from the above folder.

Download the Latest jQuery Library + Documentation

To use jQuery in Visual Studio 2008, and enjoy its IntelliSense, you should download 2 javascript files. One contains the actual jQuery library, and the second contains the library with documentation for Visual Studio 2008 to display its IntelliSense.

  1. Go to jQuery Official Download Page
  2. Scroll down and find the Current Release section.
  3. Download the Uncompressed version (jquery-1.2.6.js) and the documentation for Visual Studio (jquery-1.2.6-vsdoc.js).

Using jQuery in a Visual Studio 2008 Web Application

jQuery IntelliSense in Visual Studio 2008 - KB946581In a new Web Application or inside an existing one, add the jQuery scripts into a certain folder.

In a web page (or a master page), add a reference to the jQuery library:

<head runat="server">

  <title>jQuery Sample</title>

 

  <script src="scripts/jquery-1.2.6.js"
          type="text/javascript" ></script>

 

</head>

Then, in any javascript function you can start using jQuery functions and enjoy the IntelliSense in Visual Studio 2008.

jQuery IntelliSense in Visual Studio 2008 - KB946581

A Simple Example of Using jQuery Functions

For example, Assuming that you have a page with the following content in it:

<form id="form1" runat="server">

<div>

  <input type="text" class="inputs" id="txtName"
         value="Enter Text Here" />

  <input type="button" class="inputs" id="btnSubmit"
         value="Click Me" onclick="handleButtonClick();" />

</div>

</form>

This form contains a single textbox followed by a button.

jQuery IntelliSense in Visual Studio 2008 - KB946581

The handleButtonClick() function handles the button onclick event.

<script type="text/javascript">

  function handleButtonClick() {

  }

</script>

The way jQuery works is by selecting DOM elements and then doing something with them, such as executing a function or applying some properties. For example:

<script type="text/javascript">

  function handleButtonClick() {

    $("#txtName").css("border", "solid 2px red");

  }

</script>

The above method uses the selector function $ to select DOM elements (in this case – a single element with id = txtName) and to apply a style property of a red border. Running this page and clicking the button results in this output:

jQuery IntelliSense in Visual Studio 2008 - KB946581

Summary

In this post I talked about the steps you should follow in order to use jQuery in Visual Studio 2008 with InstelliSense support. Then, we used jQuery in a simple web application.