Revision: 547
Author: geof.glass
Date: Fri Jun 22 13:02:02 2012
Log: Fix error logging message when XML doc is bad
Always submit preference change if prefs not yet fetched
http://code.google.com/p/marginalia/source/detail?r=547
Modified:
/marginalia-lib/trunk/marginalia/annotation.js
/marginalia-lib/trunk/marginalia/prefs.js
=======================================
--- /marginalia-lib/trunk/marginalia/annotation.js Wed May 30 14:51:38 2012
+++ /marginalia-lib/trunk/marginalia/annotation.js Fri Jun 22 13:02:02 2012
@@ -558,7 +558,8 @@
if ( !xmlDoc || xmlDoc.documentElement.tagName == "error" )
{
- logError( "parseAnnotationXML Error: " +
xmlDoc.documentElement.textValue() );
+ if ( xmlDoc )
+ logError( "parseAnnotationXML Error: " +
xmlDoc.documentElement.textValue() );
alert( getLocalized( 'corrupt XML from service' ) );
return null;
}
=======================================
--- /marginalia-lib/trunk/marginalia/prefs.js Wed May 30 14:51:38 2012
+++ /marginalia-lib/trunk/marginalia/prefs.js Fri Jun 22 13:02:02 2012
@@ -31,6 +31,9 @@
{
this.preferences = new Object( );
this.service = service;
+ // Need to know whether preferences have been fetched yet, as
+ // that is asynchronous:
+ this.preferencesFetched = false;
if ( prefs )
{
@@ -71,6 +74,7 @@
trace( 'prefs', 'Preference: ' + name + ' = "' + value + '"' );
}
}
+ this.preferencesFetched = true;
if ( this.continueFunction )
{
var continueFunction = this.continueFunction;
@@ -92,8 +96,13 @@
Preferences.prototype.setPreference = function( name, value )
{
// Only set the preference if it has changed (saves HTTP requests)
- if ( ! this.preferences[ name ] || this.preferences[ name ] != value )
+ // Must send if preferences have not yet been fetched.
+ if ( ! this.preferencesFetched
+ || ! this.preferences[ name ]
+ || this.preferences[ name ] != value )
+ {
this.service.setPreference( name, value );
+ }
this.preferences[ name ] = value;
}