// // iWeb - BlogSummary.js // Copyright 2006-2008 Apple Inc. // All rights reserved. // var BlogSummaryWidget=Class.create(JSONFeedRendererWidget,{widgetIdentifier:"com-apple-iweb-widget-blogSummary",initialize:function($super,instanceID,widgetPath,sharedPath,sitePath,preferences,runningInApp) {if(instanceID) {$super(instanceID,widgetPath,sharedPath,sitePath,preferences,runningInApp);this.contentID="summary-content";this.itemTemplateID="item-template";this.itemID="item";this.separatorTemplateID="separator-template";this.selectState=null;this.sfrShadow=null;this.disableShadows=isEarlyWebKitVersion;this.styleThreeMaximumWidth=0.65;this.debugBorders=(location.href.indexOf("summaryBorders")!=-1);this.debugCompiledHtml=(location.href.indexOf("summaryCompiledHtml")!=-1);this.debugFinalHtml=(location.href.indexOf("summaryFinalHtml")!=-1);this.debugTrace=(location.href.indexOf("summaryTrace")!=-1);if(this.debugTrace)trace=print;if(this.privateInitialize) {this.privateInitialize();} document.blogSummaryWidget=this;this.initializingPreferences=true;this.initializeDefaultPreferences({"htmlTemplate":"","excerpt-length":"100","extraSpace":0,"headerOnTop":false,"imageSize":"25","imageSizeOverride":"","imagePosition":"Left","imageOutside":false,"imageVisibility":true,"rss-for-archive":false,"photoProportions":"Landscape"});delete this.initializingPreferences;this.dotMacAccount=this.preferenceForKey("dotMacAccount")||"";this.updateTemplate();this.applyUpgrades();this.fetchAndRenderRSS();}},sizeDidChange:function() {this.invalidateFeedItems("sizeDidChange");},onload:function($super) {$super();this.changedPreferenceForKey("htmlTemplate");this.changedPreferenceForKey("sfr-stroke");this.changedPreferenceForKey("sfr-reflection");this.changedPreferenceForKey("sfr-shadow");},changedPreferenceForKey:function($super,key) {try {if(this.initializingPreferences) {return;} if(this.privateChangedPreferenceForKey) {this.privateChangedPreferenceForKey(key);} if(key=="htmlTemplate") {this.updateTemplate();} if(key=="rss-for-archive") {this.fetchAndRenderRSS();} if(key=="photoProportions") {this.invalidateFeedItems(key);}} catch(e) {debugPrintException(e);} $super(key);},applyUpgrades:function() {var upgrades=this.preferenceForKey("upgrades");if(upgrades===undefined) {upgrades={};} if((!upgrades["styleThreeWidthScale"])) {if(this.imagePlacementStyle()==3) {var oldImageSize=this.preferenceForKey("imageSize");var newImageSize=Math.floor(oldImageSize/this.styleThreeMaximumWidth);this.setPreferenceForKey(newImageSize,"imageSize",false);trace("Upgrading image size from %s to %s",oldImageSize,newImageSize);} upgrades["styleThreeWidthScale"]=true;this.setPreferenceForKey(upgrades,"upgrades",false);}},updateTemplate:function() {var html=this.preferenceForKey("htmlTemplate");html=html.replace(/
/g,"");html=html.replace(//g,"");if(html=="") {var markup;if(this.preferenceForKey("rss-for-archive")) markup=BlogSummaryShared.defaultArchiveMarkup;else markup=BlogSummaryShared.defaultSummaryMarkup;trace("** brand-new widget html being compiled from source markup");if(markup) {html=BlogSummaryShared.compileMarkup(markup);}} if(html) {if(html.indexOf("")==-1) {if(html.indexOf("Read more...")!=-1) html=html.replace(/Read more\.\.\./g,"Read more...");else if(html.indexOf("More...")!=-1) html=html.replace(/More\.\.\./g,"More...");} var contentDiv=this.getElementById(this.contentID);if(contentDiv) {if(this.debugCompiledHtml)print("\n\n%s\n\n",html);html=html.replace(/\$WIDGET_ID/g,this.instanceID);contentDiv.innerHTML=html;this.resetRenderingState=true;this.invalidateFeedItems("updateTemplate");optOutOfCSSBackgroundPNGFix(contentDiv);}}},commentCountText:function(count,enabled) {if(count==0) {if(enabled) {return this.localizedString("No Comments");} else {return"";}} else if(count==1) {return this.localizedString("1 Comment");} else {return String.stringWithFormat(this.localizedString("%s Comments"),count);}},replaceLinkTargets:function(node,replaceArray) {var byteToPercentEscapeValue=function(ch) {ch=ch&0xFF;var hiChar="0123456789ABCDEF".charAt(ch/16);var loChar="0123456789ABCDEF".charAt(ch%16);return"%"+hiChar+loChar;};var sanitizeUrlStringForIE6=function(s) {var result="";for(var i=0;i