Search  
Sunday, February 05, 2012 ..:: Home ::.. Register  Login
 Technical detail of Live Clipboard Minimize
Location: BlogsWindows Live    
Posted by: Keiji Oenoki 9/8/2006 5:00 PM

In this blog I'll dive into the implementation detail of Live Clipboard, which was originally proposed by Ray Ozzie several months ago. But first, I developed a simple demo below:

Live Clipboard Demo

First, let's examine how the UI is implemented. The context menu you see when you do a right-click is, quite surprisingly, from a transparent TEXTAREA. The TEXTAREA, via CSS, has the cursor set to 'pointer', z-index set to positive, and opacity set to 0. When a right-click is detected via onMouseEvent (which is fired before the context menu is displayed), TEXTAREA's value is set to the content that should go to the clipboard, and the entire text is programatically selected (so that the context menu for text selection is displayed). When the user select "Copy", the desired text is indeed copied to the clipboard. As for Paste, onPaste event is simulated by calling a function every 50 millseconds that checks the value of the TEXTAREA. If it changes, then either delete, cut, or paste was performed by the user. They seem "hacky" at first, but this is one of few techniques that work well across browsers.

Next, let's examine the data that actually go to the clipboard. As you may have expected, XML is used for this purpose, and its schema is well documented here. As a reference, here's a sample XML for a vCard:

<?xml version="1.0" encoding="utf-8" ?>
<liveclipboard version="0.92"
  source="http://localhost:2475/live/liveclipboard.htm"
  xmlns:lc="http://www.microsoft.com/schemas/liveclipboard">
<lc:data>
<lc:format type="vcard" contenttype="application/xhtml+xml">
<lc:item>
  <div class="vcard uid" title="undefined">
  <div class="fn n"><span class="given-name">Keiji</span> <span class="family-name">Oenoki</span></div>
  <a class="email" href="mailto:keijio@microsoft.com">keijio@microsoft.com</a>
  <div class="tel"><span class="value">425-705-0742</span></div>
  <div class="adr">
  <span class="type">Work</span>:
  <div class="street-address">1065 La Avenida St</div>
  <span class="locality">Mountain View</span>
  <span class="region">CA</span> 
  <span class="postal-code">94043</span> 
  <span class="country-name">USA</span></div></div>
</lc:item>
</lc:format>
</lc:data>
</liveclipboard>

It is important to note that microformat is used here. Micrformat is a way to encode semantic information using the class tag of HTML. This allows both human and machine to easily access the information. Here's an example of encoding "first name" and "last name" using the SPAN tag:

<p>This document was prepared by <span class="name">Keiji Oenoki</span>, 
who lives in Mountain View...</p>

Next, let's talk about presentation using CSS. CSS controls how the data is displayed. For example, name can be displayed in a bold font, or address information can be made hidden.

Finally, JavaScript bridges the gap between the data and the presentation. In Live Clipboard, this is achieved by connecting three JavaScript objects - HCard, MicroFormatBindingObject, and WebClip. Consider this example:

var hCard1 = new HCard("Keiji", "Oenoki", "keijio@microsoft.com", 
  "425-705-0742", null, null, null, null, null, null,
  null, null, null, null, null, null, null, null,
  "1065 La Avenida St", "Mountain View", "CA", "94043","USA", "Microsoft");
var contactBinding1 = new MicroFormatObjectBinding(
  document.getElementById("contactHcard1"),
  hCard1, "ContactContainer unselected",
  "ContactContainer selected");
var clipBoardControl1 = new WebClip(
  document.getElementById("webClipControl1"), contactBinding1.onCopy,
  contactBinding1.onPaste, contactBinding1.onActive, contactBinding1.onInactive);

The first line instantiates the raw data, the second line associates the data with a DIV element (for presentation purpose), and finally the last line connects the data and the presentation using events. There are four types of events in WebClip:

  • onCopy: returns the data used during the Copy operation
  • onPaste: invoked when delete/cut/paste is performed
  • onActive: invoked when the data is selected
  • onInactive: invoked when the data selection is cleared

That's it! The source code is open to anyone interested:

 

Permalink |  Trackback

Comments (5)   Add Comment
Re: Technical detail of Live Clipboard    By D on 3/21/2010 7:22 PM


christian louboutin--louboutin--christian louboutin--louboutin shoes--christian louboutin boots--lv handbags--mbt shoes--christian louboutin--nike shoes--cheap nike shoes--discount nike shoes--nike shoes sale--Jimmy choo--Jimmy choo shoes--cheap Jimmy choo--discount Jimmy choo--Jimmy choo shoes sale--moncler women--cheap moncler women--discount moncler women--moncler women sale--Manolo Blahnik--Manolo Blahnik shoes--cheap Manolo Blahnik--discount Manolo Blahnik--Manolo Blahnik sale--moncler men--cheap moncler men--discount moncler men--moncler men sale--Balmain Shoes--cheap Balmain Shoes--discount Balmain Shoes--Balmain Shoes sale--moncler kids--cheap moncler kids--discount moncler kids--moncler kids sale--Yves saint Laurent--Yves saint Laurent shoes--cheap Yves saint Laurent--discount Yves saint Laurent--Yves saint Laurent sale--cheap mbt shoes--discount mbt shoes--mbt shoes sale--Ed Hardy--Ed Hardy shoes--cheap Ed Hardy--discount Ed Hardy--Ed Hardy sale--UGG boots--cheap UGG boots--discount UGG boots--UGG boots sale--Alexander McQueen--Alexander McQueen shoes--cheap Alexander McQueen--discount Alexander McQueen--Alexander McQueen sale--Chanel Shoes--cheap Chanel Shoes--discount Chanel Shoes--Chanel Shoes sale--Gucci Shoes--cheap Gucci Shoes--discount Gucci Shoes--Gucci Shoes sale--Tory Burch Shoes--Tory Burch--cheap Tory Burch Shoes--discount Tory Burch Shoes--Tory Burch Shoes sale--Lanvin Shoes--cheap Lanvin Shoes--Lanvin Shoes--Lanvin Shoes sale--Bottega Veneta--Bottega Veneta shoes--cheap Bottega Veneta--discount Bottega Veneta--Bottega Veneta sale--


Re: Technical detail of Live Clipboard    By Hyundai on 5/1/2011 11:30 PM
Hi..thanks for the information… loved it simply Oh man! What an amazing thing to say
Used Hyundai

Re: Technical detail of Live Clipboard    By Buy Generic Levitra on 6/20/2011 10:43 PM
Thanks for sharing this information. Keep up the good work.
Buy Generic Levitra

Re: Technical detail of Live Clipboard    By asfsdfsd on 6/20/2011 11:03 PM
You got a really useful blog. I have been here reading for about an hour. I am a newbie and your success is very much an inspiration for me.
Stone Bathtubs

Re: Technical detail of Live Clipboard    By terry on 12/26/2011 10:24 PM
I think it is designed to use usual Javascript and CSS ways to bring the clipboard to the web and to work in most browsers
order essay example


Your name:
Title:
Comment:
Add Comment   Cancel 

  

 Blogs Minimize

      

 Links Minimize

      

 Book Review Minimize

      

 Toolbar Minimize

      

© 2006 Oenoki, Inc. All rights reserved.   Terms Of Use  Privacy Statement