[open-ils-commits] r12761 - branches/rel_1_4/Open-ILS/xul/staff_client/chrome/content/util (dbs)

svn at svn.open-ils.org svn at svn.open-ils.org
Wed Apr 1 23:36:00 EDT 2009


Author: dbs
Date: 2009-04-01 23:35:58 -0400 (Wed, 01 Apr 2009)
New Revision: 12761

Modified:
   branches/rel_1_4/Open-ILS/xul/staff_client/chrome/content/util/error.js
Log:
Backport r12670 from trunk: prevent lengthy error messages from spilling off the bottom of the screen

Modified: branches/rel_1_4/Open-ILS/xul/staff_client/chrome/content/util/error.js
===================================================================
--- branches/rel_1_4/Open-ILS/xul/staff_client/chrome/content/util/error.js	2009-04-02 03:33:29 UTC (rev 12760)
+++ branches/rel_1_4/Open-ILS/xul/staff_client/chrome/content/util/error.js	2009-04-02 03:35:58 UTC (rev 12761)
@@ -325,7 +325,7 @@
 		this.sound.bad();
 
 
-		//FIMXE - is that good enough of an escape job?
+		//FIXME - is that good enough of an escape job?
 		s = s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
 
 		var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" flex="1">' 
@@ -394,7 +394,7 @@
 		this.sound.bad();
 
 
-		//FIMXE - is that good enough of an escape job?
+		//FIXME - is that good enough of an escape job?
 		s = s.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;');
 
 		var xml = '<vbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:html="http://www.w3.org/1999/xhtml" flex="1">' 
@@ -473,9 +473,27 @@
 		// the buttons, which are used if BUTTON_TITLE_IS_STRING is assigned to a
 		// particular button. The last two arguments are for an optional check box.
 		var check = {};
-		var rv = promptService.confirmEx(window,title, s, flags, b1, b2, b3, c, check);
+		
+		// promptService.confirmEx does not offer scrollbars for long
+		// content, so trim error lines to avoid spilling offscreen
+		//
+		// There's probably a better way of doing this.
+
+		var maxlines = 30;
+		var ss = '';
+		var linefeeds = 0;
+		for (var i = 0; linefeeds < maxlines && i < s.length; i++) {
+			t = s.charAt(i);
+			if (t == "\n") {
+				linefeeds++;
+			}	
+			ss = ss + t;
+			i++;
+		}
+		
+		var rv = promptService.confirmEx(window,title, ss, flags, b1, b2, b3, c, check);
 		if (c && !check.value) {
-			return this.yns_alert(s,title,b1,b2,b3,c);
+			return this.yns_alert(ss,title,b1,b2,b3,c);
 		}
 		return rv;
 	},



More information about the open-ils-commits mailing list