[pLog-svn] r2814 - plog/trunk/js/ui

mark at devel.lifetype.net mark at devel.lifetype.net
Wed Jan 18 03:48:41 GMT 2006


Author: mark
Date: 2006-01-18 03:48:40 +0000 (Wed, 18 Jan 2006)
New Revision: 2814

Modified:
   plog/trunk/js/ui/plogui.js
Log:
Finally, addArticleCategoryOption works for Safari. Safari does not support select.options.add, I have to use the DOM level 0 object to handle all option insert stuff. :(

It makes the new code looks ugly, but works.. :D

Modified: plog/trunk/js/ui/plogui.js
===================================================================
--- plog/trunk/js/ui/plogui.js	2006-01-17 21:39:23 UTC (rev 2813)
+++ plog/trunk/js/ui/plogui.js	2006-01-18 03:48:40 UTC (rev 2814)
@@ -74,7 +74,7 @@
 	}
 }
 
-function addArticleCategoryOption(originalRequest)
+function addArticleCategoryOption_old(originalRequest)
 {
 	//put returned XML in the textarea
 	var xmldoc = originalRequest.responseXML;
@@ -98,6 +98,33 @@
 	}
 }
 
+function addArticleCategoryOption(originalRequest)
+{
+	//put returned XML in the textarea
+	var xmldoc = originalRequest.responseXML;
+	var success = xmldoc.getElementsByTagName('success')[0].firstChild.nodeValue;
+	var message = xmldoc.getElementsByTagName('message')[0].firstChild.nodeValue;
+	if (!success) {
+		window.alert(message);
+	}
+	else
+	{
+		var catId = xmldoc.getElementsByTagName('id')[0].firstChild.nodeValue;
+		var catName = xmldoc.getElementsByTagName('name')[0].firstChild.nodeValue;
+	    for(i=$( 'postCategories' ).length; i>0; i--)
+	    {
+			tmpText = $( 'postCategories' ).options[i-1].text;
+			tmpValue = $( 'postCategories' ).options[i-1].value;
+			$( 'postCategories' ).options[i] = new Option( tmpText, tmpValue );
+			$( 'postCategories' ).options[i].selected = false;
+	    }
+	    $( 'postCategories' ).options[0] = new Option( catName, catId );
+	    $( 'postCategories' ).options[0].selected = true;
+	    $( 'newArticleCategory' ).value = '';
+	    $( 'addArticleCategory' ).disabled = 0;
+	}
+}
+
 function showArticleCategorySavingStatus(originalRequest) {
 	$( 'newArticleCategory' ).value = msgSaving;
 	$( 'addArticleCategory' ).disabled = 1;



More information about the pLog-svn mailing list