Now that's room service! Choose from over 150,000 hotels
in 45,000 destinations on Yahoo! Travel to find your fit.
Title: Javascript Example code for creating Objects with Public and Private “member” variables, using closures and JSON notation:
Wrote this bit of cool code today to rotate through a series of third party quotes . Figured I should make a post of this most excellent function structure.
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// SETTINGS - change these values to alter the behavior of how,what and when QuoteSwapper displays quotes
// --------
var g_FirstQuoteToDisplay = 4; // Sets what quote number is first displayed when the page loads
var g_QuoteRotationEnabled = true; // Setting this to false will prevent QuoteSwapper from rotating and will; only display the first quote specified
var g_SecondsToDisplayEachQuote = 3; // How many seconds each quote is displayed before rotating to the next
var g_Quotes = [
{ // Quote #1
quoteText: "thanks to thinkingVOICE's Call Tracking Platform we can demonstrate added value to our participating merchants every day",
quoteSource: "Kendall Fargo CEO",
quoteLogo: "logo_stepupCommerce.gif",
quoteLogoX: 101,
quoteLogoY: 53,
quoteLogoAlt: "StepUp Logo (an Intuit Company)",
quoteURL: "http://www.stepup.com/",
quoteTagLine: "an Intuit Company",
specialFrameAction : null
},
{ // Quote #2
quoteText: "ThinkingVoice enables Commercial Direct to qualify leads to our sales reps and close the deal quickly. By offering timeliness and convenience to our prospects, thinkingVoice has paid off big time",
quoteSource: "Jonathan Mirabito",
quoteLogo: "logo_commercialdirect.jpg",
quoteLogoX: 160,
quoteLogoY: 52,
quoteLogoAlt: "Commercial Direct Loans Logo",
quoteURL: "http://www.commercialdirectloans.com/index.jsp?pageId=home",
quoteTagLine: "",
specialFrameAction : null
},
{ // Quote #3
quoteText: "With a simple click, potential customers connect to a live sales representative, get immediate answers to their questions and can register for a WebEx Live! service with confidence",
quoteSource: "Alfred Pong",
quoteLogo: "logo_webex.gif",
quoteLogoX: 160,
quoteLogoY: 60,
quoteLogoAlt: "WebEx Logo",
quoteURL: "http://www.webex.com/",
quoteTagLine: "",
specialFrameAction : null
},
{ // Quote #4
quoteText: "adding thinkingVOICE to my email signature just makes good business sense. And it works so easy with PLAXO.",
quoteSource: "Mark Goldstein",
quoteLogo: "logo_loyaltylab.gif",
quoteLogoX: 160,
quoteLogoY: 42,
quoteLogoAlt: "LoyaltyLab, a division of InStoreCard",
quoteURL: "http://www.instorecard.com/",
quoteTagLine: ""
},
{ // Quote #5
quoteText: '<span style="font-weight:bolder;color:brown;font-family:arial mt rounded; font-size:1em;line-height:.9em;text-align:center;vertical-align:baseline;">Breaking News<br/></span><span style="line-height:1em; font-size:10px; font-family:lucida sans unicode, tahoma;margin:0;">ThinkingVoice announces deals with <a href="http://www.clearchanneloutdoor.com/" target="top" class="announcement_link">ClearChannel Outdoor</a>, <a href="http://www.servicemagic.com/" target="_top" class="announcement_link">Service Magic</a></span>',
quoteSource: '',
quoteLogoX: 194,
quoteLogoY: 290,
quoteLogo: "images/CLearChannelBillboard.gif",
quoteLogoAlt: "ThinkingVoice announces deals with ClearChannel outdoor and Service Magic",
quoteURL: "http://sev.prnewswire.com/advertising/20070605/AQTU18605062007-1.html",
quoteTagLine: "source: prnewswire",
specialFrameAction : null
}
]
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// QUOTESWAPPER - this Object cycles through and displays an array of quotes, images and hyperlinks.
// ============ DO NOT MODIFY CODE IN THIS SECTION
var QuoteSwapper = function() {
var self = this;
var _swapperThread = null;
var _bRotationEnabled = g_QuoteRotationEnabled;
var _currentItem = g_FirstQuoteToDisplay;
function public() {}
public.displayQuote = function( itemToDisplay ) {
itemToDisplay = (("" + itemToDisplay!="undefined") ? itemToDisplay : g_FirstQuoteToDisplay ) % g_Quotes.length; // stay within limits of array
document.getElementById('quoteText').innerHTML = (g_Quotes[ itemToDisplay ].quoteText.length > 0) ? g_Quotes[ itemToDisplay ].quoteText : "";
document.getElementById('quoteSource').innerText = (g_Quotes[ itemToDisplay ].quoteSource.length > 0) ? " - " + g_Quotes[ itemToDisplay ].quoteSource : "";
document.getElementById('quoteLogo').src = g_Quotes[ itemToDisplay ].quoteLogo;
document.getElementById('quoteLogo').width = g_Quotes[ itemToDisplay ].quoteLogoX;
document.getElementById('quoteLogo').height = g_Quotes[ itemToDisplay ].quoteLogoY;
document.getElementById('quoteLogo').alt = g_Quotes[ itemToDisplay ].quoteLogoAlt;
document.getElementById('quoteURL').href = g_Quotes[ itemToDisplay ].quoteURL;
document.getElementById('quoteTagLine').innerHtml = g_Quotes[ itemToDisplay ].quoteTagLine;
_currentItem = itemToDisplay;
}
public.start = function() {
clearInterval( _swapperThread );
if ( _bRotationEnabled ) {
_swapperThread = setInterval("QuoteSwapper.next()", g_SecondsToDisplayEachQuote * 1000);
}
this.displayQuote( g_FirstQuoteToDisplay );
}
public.next = function() {
this.displayQuote( _currentItem + 1 )
}
public.stop = function() {
clearInterval( _swapperThread );
}
return public;
}();
Here is a great resource for .reg files that help you to reset file associations for Windows XP.
http://www.dougknox.com/xp/file_assoc.htm
I used the one for "Directory" and all was corrected!
-shannon norrell
--
_______________________________________________
Surf the Web in a faster, safer and easier way:
Download Opera 9 at http://www.opera.com
Powered by Outblaze
Date: Sat, 2 Jun 2007 19:23:37 -0700 (PDT)
From: theWebDood <thewebdood@yahoo.com>
Subject: RE:
To: "Amacker, Matthew" <mamacker@amazon.com>
No worries mate.Hey, I was thinking about mobile.I think that to have the broadest coverage (pun intended), there should be two basic modalities developed for interfacing with Amazon.com through a mobile phone.The first would be, as I think you mentioned, a lightweight version of Amazon.com designed and coded specifically for mobile phone web browsers. It would be sleak and slim and have only the minimum features required for customers to easily check price and availability on a specific book, to do simple searches, and to be able to select a book and add it to their wishlist or complete checkout right there in the mobile web page. Call this one "mobile.amazon.com"The second, which you may not have considered, is an SMS-based interface that lets users quickly check prices, do simple searches, add a book to their cart and to (possibly) check out by sending a text message to 26296 (AMAZN).For example:p lord fouls bane - query for the price of "Lord Fouls Bane"When query results come back they are identified as 1st, 2nd, 3rd, etc.example:"Lord Foul's Bane", by Stephen R. Donaldson, 1978. Choices are:1st) Hardback, NEW, $42.952nd) Paperback, used $8.253rd) Hardback, used $12.95Using that information, a user could potentially reply with:buy 2nd itemAn SMS dialog may continue where we ask for their account number, etc.There are limitations, to be sure, but the experience is such that a user can find and buy a book through Amazon.com entirely through text messaging using his or her cell phone. Call this variant "Amazon SMS"- - -Anyway, that's a brain dump of my thought stream on mobile at the moment for Amazon.shannon norrellOnly a We support only a very few "verbs address.maybe to direct that an email be sent by sending a text message s and availability and, perhaps, to do a more aprices on books SMS interface
"Amacker, Matthew" <mamacker@amazon.com> wrote:Hi Shannon,Bennett went on vacation. So you might have sent him a note just after he headed out - so it was never passed on to the secondary. We are very interested in getting you in here to talk to some more folks.Bennett gets back on Monday which is probably when he will respond to your note and we can get things rolling again.Sorry for the delays.-Matt
From: theWebDood [mailto:thewebdood@yahoo.com]
Sent: Thursday, May 31, 2007 12:00 PM
To: Amacker, Matthew
Subject: RE:Matt:I agree. I think that we would along famously and have a lot of fun putting out some cool tech together.I got an email from Bennett last week regarding scheduling an interview but things seem to have stalled or otherwise fallen into a black hole.Do you know what is up?-shannon650-200-5044
"Amacker, Matthew" <mamacker@amazon.com> wrote:Thanks for the links!You should have already heard from Bennett so I hope to see you in the offices sometime soon!Please let me know if you need more information about this group or the company - I think we could have a lot of fun.I hope your allergies leave you alone for a bit.Sincerely,Matt
From: theWebDood [mailto:thewebdood@yahoo.com]
Sent: Tuesday, May 22, 2007 3:24 PM
To: Amacker, Matthew
Subject: RE:Matt:Thanks for the call. You seem like a cool guy.Sorry my brain is cloudy with the allergy meds. That site I was trying to remember is called "AListApart.com." As we get older and more experienced as web devs, it becomes harder to find sites that actually teach us or talk about topics we are not already familiar with. A ranomd example I just pulled up is: http://www.alistapart.com/articles/crossbrowserscriptingAnother site I frequent is jibbering.com. You have probably already read his famous article on closuresAnyhow, I think I am going home to bed.My head feels like it has been stuffed with cotton balls.TTYLshannon
"Amacker, Matthew" <mamacker@amazon.com> wrote:Sounds good. I'll give you a call at 2PM at 650 200 5044.If for some reason I miss you please feel free to give me a call back at: 530 400 7823Thanks,Matt
From: theWebDood [mailto:thewebdood@yahoo.com]
Sent: Monday, May 21, 2007 2:59 PM
To: Amacker, Matthew
Subject: Re:Sure, call me sometime tomorrow. You should definitely put me on the OSX Widgets and Vista Gadgets. Not sure if there are many people out there who have developed both for major production distribution. You should see some of the ones I did that weren't released.-shannonps - great job with the flyouts on the A9 search box on Amazon site. I see you did not use scrollbars and instead used Previous and Next links at the bottom. I feel your pain. Scrollbars are incredibly difficult to produce uysing DHTML alone; particularly cross-browser versions. I think I may have tackled this issue, but only after much agony and bloodshed. the reality is that < > is better so you don't have to pull down as much data for a search (since they will probably click on something from the first page anyway), it's just that UI is kind of clunky.
"Amacker, Matthew" <mamacker@amazon.com> wrote:Hello Shannon,
You have a great resume. I'd like to talk to you about it and give you a better picture of the position I'm trying to fill.I'm available anytime tomorrow for a phone call and there are spots available on Wednesday. Is: 650 200 5044 the best number?I'm glad you liked my posting. I hope this finds you well.Sincerely,
Matt @ a9.comP.S. To give you an early taste. My group's tasks:
A9 Websearch on Amazon: Look at the upper right hand corner of Amazon.com for the A9 search box.
A9.com: All UI and backend support for the A9.com site is handled by this group.
Clickriver: All text ads on Amazon are this group.
Mobile: Client that runs on mobile devices - not yet started.
Desktops: OSX and Vista widgets that are soon to be released.
Greasemonkey and bookmarklets: coming soon that will expand the reach of all A9.com properties.
Take the Internet to Go: Yahoo!Go puts the Internet in your pocket: mail, news, photos & more.
Get the free Yahoo! toolbar and rest assured with the added security of spyware protection.
Got a little couch potato?
Check out fun summer activities for kids.
Get the Yahoo! toolbar and be alerted to new email wherever you're surfing.
This is useful code that is good to have around. It is a Perfect
Example of what I am trying to accomplish with this blog - - an archive
of Shannon Norrell cool webdood code. I write so much of it that lots
of little gems like this fall through the cracks. Half the time I don't
even remember that I wrote something, let alone recall how it was
written.
Enjoy.
-shannon norrell
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>getSimilarityScore</title>
<script language="javascript" type="text/javascript">
String.prototype.getSimilarityScore = function(c){
// Uses Levenshtein Distance between two strings algorithm
var s, that=c, l = (s = this.split("")).length, t = (c =
c.split("")).length, i, j, m, n, dis, maxLen, retVal=.95;
if(!(l || t)) {
dis = Math.max(l, t);
} else {
for(var a = [], i = l + 1; i; a[--i] = [i]);
for(i = t + 1; a[0][--i] = i;);
for(i = -1, m = s.length; ++i < m;)
for(j = -1, n = c.length; ++j < n;)
a[(i *= 1) + 1][(j *= 1) + 1] = Math.min(a[i][j + 1] +
1, a[i + 1][j] + 1, a[i][j] + (s[i] != c[j]));
dis = a[l][t];
}
maxLen = Math.max( this.length, that.length );
if (maxLen > 0) {
retVal = (1 - dis/maxLen);
}
return retVal;
};
var foo="Newcastle,wa";
alert( foo.getSimilarityScore('castel') );
</script>
</head>
<body>
</body>
</html>
I will try to post what I end up with as the final markup when I get finished with it.