[Carbon-dev] svn commit r31363 - trunk/carbon-components/policy-editor/org.wso2.carbon.policyeditor.ui/src/main/resources/web/policyeditor/js

tyrell at wso2.com tyrell at wso2.com
Mon Feb 23 22:01:22 PST 2009


Author: tyrell
Date: Mon Feb 23 22:01:22 2009
New Revision: 31363
URL: http://wso2.org/svn/browse/wso2?view=rev&revision=31363

Log:
Improving internal documentation.

Modified:
   trunk/carbon-components/policy-editor/org.wso2.carbon.policyeditor.ui/src/main/resources/web/policyeditor/js/policy-editor.js

Modified: trunk/carbon-components/policy-editor/org.wso2.carbon.policyeditor.ui/src/main/resources/web/policyeditor/js/policy-editor.js
URL: http://wso2.org/svn/browse/wso2/trunk/carbon-components/policy-editor/org.wso2.carbon.policyeditor.ui/src/main/resources/web/policyeditor/js/policy-editor.js?rev=31363&r1=31362&r2=31363&view=diff
==============================================================================
--- trunk/carbon-components/policy-editor/org.wso2.carbon.policyeditor.ui/src/main/resources/web/policyeditor/js/policy-editor.js	(original)
+++ trunk/carbon-components/policy-editor/org.wso2.carbon.policyeditor.ui/src/main/resources/web/policyeditor/js/policy-editor.js	Mon Feb 23 22:01:22 2009
@@ -17,6 +17,11 @@
 var lastUsedServiceId = "";
 var lastUsedServiceVersion = "";
 
+/**
+ * Retrieves a Policy using a given URL
+ *
+ * @param url
+ */
 function getPolicyDoc(url) {
 
     var body_xml = '<ns1:getPolicyDocRequest xmlns:ns1="http://org.wso2.wsf/tools">' +
@@ -35,6 +40,9 @@
     buildTreeView(policyDoc);
 }
 
+/**
+ * Retrieves a list of available Policy Schemas (XSDs) from the backend
+ */
 function getPolicSchemaDefs() {
     var body_xml = '<ns1:getAvailableSchemasRequest xmlns:ns1="http://org.wso2.wsf/tools">' +
                    '</ns1:getAvailableSchemasRequest>';
@@ -61,6 +69,12 @@
     }
 }
 
+/**
+ * Retrieves a schema by a given name from the backend
+ *
+ * @param policyName
+ * @param isLastCall
+ */
 function getPolicySchemaDef(policyName, isLastCall) {
 
     var body_xml = '<ns1:getSchemaRequest xmlns:ns1="http://org.wso2.wsf/tools">' +
@@ -81,6 +95,11 @@
     }
 }
 
+/**
+ * Utility function to remove CDATA tags from a response
+ * 
+ * @param candidateString
+ */
 function removeCDATA(candidateString)
 {
     //Verify whether this is a CDATA string
@@ -99,6 +118,11 @@
     return candidateString;
 }
 
+/**
+ * Synchronizes the Raw Policy (Text) view using the changes done to the in-memory policy document
+ * 
+ * @param policyDocument
+ */
 function syncRawPolicyView(policyDocument) {
 
     var rawPolicyTextArea = document.getElementById("raw-policy");
@@ -130,6 +154,11 @@
     }
 }
 
+/**
+ * Formats a given XML using the backend service
+ * 
+ * @param xml
+ */
 function formatXMLUsingService(xml) {
     xml = "<![CDATA[" + xml + "]]>";
 
@@ -147,6 +176,10 @@
     removeCDATA(this.req.responseXML.getElementsByTagName("return")[0].firstChild.nodeValue);
 }
 
+/**
+ * Synchronizes the Policy Tree using the in-memory Policy document
+ * 
+ */
 function syncPolicyTreeView() {
     var rawPolicy = document.getElementById("raw-policy").value;
 
@@ -235,12 +268,14 @@
 
         if (mode == "add") {
             uiHTML = uiHTML +
-                     "<input id='cmdAddElement' type='button' value='" + jsi18n["add.element.to.document"] + "' onclick='createElementFromUIData(\"" +
+                     "<input id='cmdAddElement' type='button' value='" +
+                     jsi18n["add.element.to.document"] + "' onclick='createElementFromUIData(\"" +
                      schemaElement.getAttribute("name") + "\",\"" +
                      namespaceURI + "\");'/>";
         } else if (mode == "edit") {
             uiHTML = uiHTML +
-                     "<input id='cmdEditElement' type='button' value='" + jsi18n["update.element"] + "' onclick='updateElementFromUIdata();'/>";
+                     "<input id='cmdEditElement' type='button' value='" + jsi18n["update.element"] +
+                     "' onclick='updateElementFromUIdata();'/>";
         }
 
         uiHTML = uiHTML + "</div>";
@@ -249,7 +284,7 @@
 
     } else {
         document.getElementById("divPolicyInputGatherer").innerHTML =
-        jsi18n["the.element"]  + " '" + schemaElement.getAttribute("name") +
+        jsi18n["the.element"] + " '" + schemaElement.getAttribute("name") +
         "' " + jsi18n["does.not.have.editable.attributes"];
     }
 }
@@ -329,6 +364,11 @@
 }
 
 
+/**
+ * Loads the schema fragment for a named element
+ * 
+ * @param elementName
+ */
 function getSchemaForElement(elementName) {
     // searching the element array
     for (var x = 0; x < elements.length; x++) {
@@ -347,6 +387,10 @@
     return null;
 }
 
+/**
+ * Saves the modified Policy Document using the backend service.
+ *  
+ */
 function savePolicyXML() {
     // Ensure the in memory policy is in sync with the UI
     var rawPolicy = document.getElementById("raw-policy").value;
@@ -381,6 +425,10 @@
 
 }
 
+/**
+ * POSTs an updated Policy document to a given URL via a dynamically generated Form.
+ *  
+ */
 function postbackUpdatedPolicy() {
     var formEl = document.getElementById("post-back-form");
     
@@ -416,6 +464,10 @@
 
 }
 
+/**
+ * Allows the user to return to the page prior to the Policy Editor page.
+ *  
+ */
 function goBack() {
     var parts = callbackURL.split("?");
     var backURL = parts[0] + "?";
@@ -458,6 +510,13 @@
     location.href = backURL + backUrlParams;
 }
 
+/**
+ * Utility function to create a Cookie
+ * 
+ * @param name
+ * @param value
+ * @param days - How many days before the cookie expires
+ */
 function createCookie(name, value, days) {
     if (days) {
         var date = new Date();
@@ -468,6 +527,11 @@
     document.cookie = name + "=" + value + expires + "; path=/";
 }
 
+/**
+ * Utility function to read a cookie value
+ * 
+ * @param name
+ */
 function readCookie(name) {
     var nameEQ = name + "=";
     var ca = document.cookie.split(';');
@@ -479,6 +543,11 @@
     return null;
 }
 
+/**
+ * The breadcome behaves weirdly by showing the proxy page. This function removes that by
+ * manipulating the breadcrumb cookie.
+ *  
+ */
 function cleanBreadCrumb() {
     // Read the existing breadcrumb value
     var breadCrumb = readCookie("current-breadcrumb");
@@ -497,12 +566,17 @@
     createCookie("current-breadcrumb", newBreadCrumb);
 }
 
+/**
+ * Sometimes the ending breadcrumb link is activated, which is unorthodox.
+ * Killing the last link to prevent it.
+ * 
+ */
 function disableLastBreadcrumbLink() {
 
     var breadCrumbLinks = document.getElementById("breadcrumb-div").getElementsByTagName("a");
     for (var x = 0; x < breadCrumbLinks.length; x++) {
-       var currentLinkText = breadCrumbLinks[x].firstChild.nodeValue;
-        if(currentLinkText == "Policy"){
+        var currentLinkText = breadCrumbLinks[x].firstChild.nodeValue;
+        if (currentLinkText == "Policy") {
             breadCrumbLinks[x].href = "#";
         }
     }



More information about the Carbon-dev mailing list