You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ef...@apache.org on 2007/07/16 01:59:01 UTC
svn commit: r556477 - in /myfaces/tomahawk/trunk/sandbox/core/src/main:
java/org/apache/myfaces/custom/passwordStrength/
resources/org/apache/myfaces/custom/passwordStrength/
resources/org/apache/myfaces/custom/passwordStrength/resource/
resources/org/...
Author: efastl
Date: Sun Jul 15 16:59:00 2007
New Revision: 556477
URL: http://svn.apache.org/viewvc?view=rev&rev=556477
Log:
new password strength component according to TOMAHAWK-1042
thanks to Hazem Saleh
Added:
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthComponent.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthRenderer.java
myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthTag.java
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/passwordStrength/
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/passwordStrength/resource/
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/passwordStrength/resource/PasswordStrength.properties
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/passwordStrength/resource/css/
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/passwordStrength/resource/css/passwordStrength.css
myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/passwordStrength/resource/passwordStrength.js
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthComponent.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthComponent.java?view=auto&rev=556477
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthComponent.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthComponent.java Sun Jul 15 16:59:00 2007
@@ -0,0 +1,99 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.custom.passwordStrength;
+
+import javax.faces.component.UIInput;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+
+import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
+
+
+public class PasswordStrengthComponent extends UIInput {
+
+ public static String COMPONENT_TYPE = "org.apache.myfaces.PasswordStrength";
+
+ public static String RENDERER_TYPE = "org.apache.myfaces.PasswordStrength";
+
+ private String _preferredPasswordLength;
+
+ private String _textStrengthDescriptions;
+
+ private String _prefixText;
+
+ public String getFamily() {
+ return "org.apache.myfaces.PasswordStrength";
+ }
+
+ public String getPreferredPasswordLength() {
+ if (_preferredPasswordLength != null)
+ return _preferredPasswordLength;
+
+ ValueBinding vb = getValueBinding("preferredPasswordLength");
+ return vb != null ? RendererUtils.getStringValue(getFacesContext(), vb)
+ : null;
+ }
+
+ public void setPreferredPasswordLength(String preferredPasswordLength) {
+ _preferredPasswordLength = preferredPasswordLength;
+ }
+
+ public String getPrefixText() {
+ if (_prefixText != null)
+ return _prefixText;
+
+ ValueBinding vb = getValueBinding("prefixText");
+ return vb != null ? RendererUtils.getStringValue(getFacesContext(), vb)
+ : null;
+ }
+
+ public void setPrefixText(String prefixText) {
+ _prefixText = prefixText;
+ }
+
+ public String getTextStrengthDescriptions() {
+ if (_textStrengthDescriptions != null)
+ return _textStrengthDescriptions;
+
+ ValueBinding vb = getValueBinding("textStrengthDescriptions");
+ return vb != null ? RendererUtils.getStringValue(getFacesContext(), vb)
+ : null;
+ }
+
+ public void setTextStrengthDescriptions(String strengthDescriptions) {
+ _textStrengthDescriptions = strengthDescriptions;
+ }
+
+ public Object saveState(FacesContext context) {
+ Object values[] = new Object[4];
+ values[0] = super.saveState(context);
+ values[1] = _preferredPasswordLength;
+ values[2] = _prefixText;
+ values[3] = _textStrengthDescriptions;
+ return ((Object) (values));
+ }
+
+ public void restoreState(FacesContext context, Object state) {
+ Object values[] = (Object[]) state;
+ super.restoreState(context, values[0]);
+ _preferredPasswordLength = (String) values[1];
+ _prefixText = (String) values[2];
+ _textStrengthDescriptions = (String)values[3];
+ }
+}
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthRenderer.java?view=auto&rev=556477
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthRenderer.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthRenderer.java Sun Jul 15 16:59:00 2007
@@ -0,0 +1,250 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.custom.passwordStrength;
+
+import java.io.IOException;
+import java.util.Map;
+
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIInput;
+import javax.faces.component.html.HtmlInputText;
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.Renderer;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.myfaces.custom.accordion.HtmlAccordionPanelRenderer;
+import org.apache.myfaces.custom.excelexport.ExcelExport;
+import org.apache.myfaces.custom.inputAjax.HtmlInputTextAjax;
+import org.apache.myfaces.custom.statechangednotifier.StateChangedNotifierRenderer;
+import org.apache.myfaces.renderkit.html.util.AddResource;
+import org.apache.myfaces.renderkit.html.util.AddResourceFactory;
+import org.apache.myfaces.shared_tomahawk.renderkit.JSFAttr;
+import org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HTML;
+import org.apache.myfaces.shared_tomahawk.renderkit.html.HtmlRendererUtils;
+import org.apache.myfaces.shared_tomahawk.util.MessageUtils;
+
+public class PasswordStrengthRenderer extends Renderer {
+
+ // This private method is used for including all the related resources ...
+ private void includeResources(FacesContext context, UIComponent component,
+ ResponseWriter writer) throws IOException {
+ // Load the resources ...
+ AddResource addResource = AddResourceFactory.getInstance(context);
+ // Load the css style ...
+ String styleLocation = (String) component.getAttributes().get(
+ JSFAttr.STYLE_LOCATION);
+ if (StringUtils.isNotBlank(styleLocation)) {
+ addResource.addStyleSheet(context, AddResource.HEADER_BEGIN,
+ styleLocation + "/passwordStrength.css");
+ } else {
+ addResource.addStyleSheet(context, AddResource.HEADER_BEGIN,
+ PasswordStrengthRenderer.class, "css/passwordStrength.css");
+ }
+ // Load the JS file ...
+ String javascriptLocation = (String) component.getAttributes().get(
+ JSFAttr.JAVASCRIPT_LOCATION);
+ if (javascriptLocation != null) {
+ // add user defined javascripts
+ addResource.addJavaScriptAtPosition(context,
+ AddResource.HEADER_BEGIN, javascriptLocation
+ + "/passwordStrength.js");
+ } else {
+ addResource.addJavaScriptAtPosition(context,
+ AddResource.HEADER_BEGIN, PasswordStrengthRenderer.class,
+ "passwordStrength.js");
+ }
+ }
+
+ private void renderStartDiv(UIComponent component, ResponseWriter writer)
+ throws IOException {
+
+ writer.startElement(HTML.DIV_ELEM, component);
+
+ writer.startElement(HTML.TABLE_ELEM, component);
+
+ writer.startElement(HTML.TR_ELEM, component);
+ writer.startElement(HTML.TD_ELEM, component);
+ }
+
+ private void renderEndDiv(UIComponent component, ResponseWriter writer)
+ throws IOException {
+ writer.endElement(HTML.TD_ELEM);
+ writer.endElement(HTML.TR_ELEM);
+
+ writer.endElement(HTML.TABLE_ELEM);
+
+ writer.endElement(HTML.DIV_ELEM);
+ }
+
+ private String getDefaultTextDesc() {
+ return MessageUtils.getMessage(BUNDLE_BASE_NAME,
+ MessageUtils.getCurrentLocale(),
+ "org.apache.myfaces.custom.passwordStrength.DESC", null)
+ .getDetail();
+ }
+
+ private String getDefaultPrefix() {
+ return MessageUtils.getMessage(BUNDLE_BASE_NAME,
+ MessageUtils.getCurrentLocale(),
+ "org.apache.myfaces.custom.passwordStrength.PREFIX", null)
+ .getDetail();
+ }
+
+ private void createTextSpan(PasswordStrengthComponent passwordStrength,
+ FacesContext context, String clientID) throws IOException {
+ ResponseWriter writer = context.getResponseWriter();
+
+ String preferredLength = passwordStrength.getPreferredPasswordLength();
+ String prefixText = passwordStrength.getPrefixText();
+ String textStrengthDescriptions = passwordStrength
+ .getTextStrengthDescriptions();
+ String txtName = "'" + clientID + "'";
+
+ // Set default values for optional attributes ...
+
+ prefixText = (prefixText == null) ? "'" + getDefaultPrefix() + "'"
+ : "'" + prefixText + "'";
+
+ textStrengthDescriptions = (textStrengthDescriptions == null) ? "'"
+ + getDefaultTextDesc() + "'" : "'" + textStrengthDescriptions
+ + "'";
+
+ writer.startElement(HTML.SPAN_ELEM, passwordStrength);
+
+ writer.startElement(HTML.INPUT_ELEM, passwordStrength);
+ writer.writeAttribute(HTML.TYPE_ATTR, "password", HTML.TYPE_ATTR);
+ writer.writeAttribute(HTML.ID_ATTR, clientID, HTML.ID_ATTR);
+ writer.writeAttribute(HTML.NAME_ATTR, clientID, HTML.NAME_ATTR);
+
+ String value = "";
+ Object objValue = ((UIInput) passwordStrength).getSubmittedValue();
+ if (objValue != null) {
+ value = passwordStrength.getValue().toString();
+ }
+ writer.writeAttribute("value", value, "value");
+
+ writer.writeAttribute("onkeyup", createOnKeyUpString(txtName,
+ preferredLength, prefixText, textStrengthDescriptions, true),
+ "onkeyup");
+ writer.writeAttribute("onblur", ON_BLUR_STRING, "onblur");
+
+ writer.endElement(HTML.INPUT_ELEM);
+
+ writer.endElement(HTML.SPAN_ELEM);
+ }
+
+ private void createIndicatorSpan(UIComponent component,
+ ResponseWriter writer) throws IOException {
+ writer.endElement(HTML.TD_ELEM);
+ writer.startElement(HTML.TD_ELEM, component);
+
+ writer.startElement(HTML.SPAN_ELEM, component);
+ writer.writeAttribute(HTML.ID_ATTR, "indicatorMessage", HTML.ID_ATTR);
+ writer.writeAttribute(HTML.CLASS_ATTR, "indicatorMessage",
+ HTML.CLASS_ATTR);
+ writer.endElement(HTML.SPAN_ELEM);
+
+ writer.endElement(HTML.TD_ELEM);
+ writer.endElement("TR");
+
+ writer.startElement("TR", component);
+ writer.startElement(HTML.TD_ELEM, component);
+
+ writer.startElement("div", component);
+ writer.writeAttribute("id", "leftCharsMessage", "id");
+ writer.endElement("div");
+ }
+
+ private void createHTMLComponents(FacesContext facesContext,
+ UIComponent component, ResponseWriter writer, String clientID)
+ throws IOException {
+ PasswordStrengthComponent passwordStrength = (PasswordStrengthComponent) component;
+
+ renderStartDiv(component, writer);
+
+ createTextSpan(passwordStrength, facesContext, clientID);
+
+ createIndicatorSpan(component, writer);
+
+ renderEndDiv(component, writer);
+ }
+
+ public void encodeBegin(FacesContext context, UIComponent component)
+ throws IOException {
+ RendererUtils.checkParamValidity(context, component,
+ PasswordStrengthComponent.class);
+
+ if (HtmlRendererUtils.isDisplayValueOnly(component)
+ || isDisabled(context, component)) {
+ super.encodeEnd(context, component);
+ return;
+ }
+
+ String clientID = component.getClientId(context);
+
+ ResponseWriter writer = context.getResponseWriter();
+
+ includeResources(context, component, writer);
+
+ createHTMLComponents(context, component, writer, clientID);
+ }
+
+ public void encodeEnd(FacesContext context, UIComponent component)
+ throws IOException {
+ }
+
+ public void decode(FacesContext context, UIComponent component) {
+ Map requestMap = context.getExternalContext().getRequestParameterMap();
+
+ String clientID = component.getClientId(context);
+
+ String newValue = (String) requestMap.get(clientID);
+
+ ((UIInput) component).setSubmittedValue(newValue);
+ }
+
+ protected boolean isDisabled(FacesContext facesContext,
+ UIComponent component) {
+ if (component instanceof HtmlInputText) {
+ return ((HtmlInputText) component).isDisabled();
+ } else {
+ return org.apache.myfaces.shared_tomahawk.renderkit.RendererUtils
+ .getBooleanAttribute(component, HTML.DISABLED_ATTR, false);
+ }
+ }
+
+ private String createOnKeyUpString(String txtName, String preferredLength,
+ String prefix, String textStrengthDescriptions,
+ boolean showMessageIndicator) {
+ String showMessageIndicatorString = "";
+ if (showMessageIndicator == true)
+ showMessageIndicatorString = "show('indicatorMessage')";
+ return "updateStatusValue( " + txtName + "," + preferredLength + ", "
+ + prefix + ", " + textStrengthDescriptions + ", " + "'true');"
+ + showMessageIndicatorString;
+ }
+
+ // The constants ...
+ final String ON_BLUR_STRING = "hide('indicatorMessage');"
+ + "hide('leftCharsMessage');";
+
+ final String BUNDLE_BASE_NAME = "org.apache.myfaces.custom.passwordStrength.resource.PasswordStrength";
+}
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthTag.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthTag.java?view=auto&rev=556477
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthTag.java (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/passwordStrength/PasswordStrengthTag.java Sun Jul 15 16:59:00 2007
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.custom.passwordStrength;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import javax.faces.webapp.UIComponentTag;
+
+import org.apache.myfaces.taglib.html.ext.HtmlInputTextTag;
+
+public class PasswordStrengthTag extends HtmlInputTextTag {
+
+ /**
+ * return the component class ...
+ */
+ public String getComponentType() {
+ return PasswordStrengthComponent.COMPONENT_TYPE;
+ }
+
+ /**
+ * Returns the component renderer ...
+ */
+ public String getRendererType() {
+ return PasswordStrengthComponent.RENDERER_TYPE;
+ }
+
+ /**
+ * release the used resources ...
+ */
+ public void release() {
+ super.release();
+ //_text = null;
+ _preferredPasswordLength = null;
+ _prefixText = null;
+ _textStrengthDescriptions = null;
+ }
+
+ protected void setProperties(UIComponent component) {
+ super.setProperties(component);
+ // setStringProperty(component, "text", _text);
+ setStringProperty(component, "preferredPasswordLength",
+ _preferredPasswordLength);
+ setStringProperty(component, "textStrengthDescriptions",
+ _textStrengthDescriptions);
+ setStringProperty(component, "prefixText", _prefixText);
+ }
+
+ //Getters & Setters ...
+
+ public String getPreferredPasswordLength() {
+ return _preferredPasswordLength;
+ }
+
+ public void setPreferredPasswordLength(String preferredPasswordLength) {
+ this._preferredPasswordLength = preferredPasswordLength;
+ }
+
+ public String getPrefixText() {
+ return _prefixText;
+ }
+
+ public void setPrefixText(String prefixText) {
+ _prefixText = prefixText;
+ }
+
+ public String getTextStrengthDescriptions() {
+ return _textStrengthDescriptions;
+ }
+
+ public void setTextStrengthDescriptions(String strengthDescriptions) {
+ _textStrengthDescriptions = strengthDescriptions;
+ }
+
+ //Attributes ...
+ private String _preferredPasswordLength;
+ private String _textStrengthDescriptions;
+ private String _prefixText;
+}
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/passwordStrength/resource/PasswordStrength.properties
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/passwordStrength/resource/PasswordStrength.properties?view=auto&rev=556477
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/passwordStrength/resource/PasswordStrength.properties (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/passwordStrength/resource/PasswordStrength.properties Sun Jul 15 16:59:00 2007
@@ -0,0 +1,2 @@
+org.apache.myfaces.custom.passwordStrength.DESC = Very Poor;Weak;Average;Strong;Excellent
+org.apache.myfaces.custom.passwordStrength.PREFIX = Strength :
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/passwordStrength/resource/css/passwordStrength.css
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/passwordStrength/resource/css/passwordStrength.css?view=auto&rev=556477
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/passwordStrength/resource/css/passwordStrength.css (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/passwordStrength/resource/css/passwordStrength.css Sun Jul 15 16:59:00 2007
@@ -0,0 +1,2 @@
+.indicatorMessage { color:white; background:gray; font-size: 12px; padding: 3; font-style: italic;
+}
Added: myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/passwordStrength/resource/passwordStrength.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/passwordStrength/resource/passwordStrength.js?view=auto&rev=556477
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/passwordStrength/resource/passwordStrength.js (added)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/resources/org/apache/myfaces/custom/passwordStrength/resource/passwordStrength.js Sun Jul 15 16:59:00 2007
@@ -0,0 +1,65 @@
+function hide(id) {
+ if (document.getElementById){
+ obj = document.getElementById(id);
+ obj.style.display = "none";
+ }
+}
+function show(id) {
+ if (document.getElementById){
+ obj = document.getElementById(id);
+ obj.style.display = "";
+ }
+}
+
+window.onload=function() {
+ hide('indicatorMessage');
+}
+
+//This method is used for online updating the status of the textbox ...
+function updateStatusValue(txtName, preferredLength, prefixText, passwordDesc, showDetails) {
+ //Define the variables ...
+ var content = document.getElementById(txtName).value;
+ var currentStatus = prefixText;
+ var diff = 0;
+ //Check the contents ...
+ var tokens = passwordDesc.split(";");
+ var length = tokens.length;
+ //Calc the delta of char changes : diff = preferredLength / tokens;
+ var delta = preferredLength / length;
+ var change = delta;
+ //Segmentize it ...
+ for(i = 0; i < length; ++i) {
+ //Get the correct tokenizer ...
+ if(content.length <= delta) {
+ currentStatus += tokens[i];
+ break;
+ }
+ //If we reached the last character then always display the last value ...
+ if(i == length - 1) {
+ currentStatus += tokens[length-1];
+ break;
+ }
+ delta = change * (i + 2);
+ }
+ //Show the result messages ...
+ if(document.all){
+ document.getElementById("indicatorMessage").innerText = currentStatus;
+ } else {
+ document.getElementById("indicatorMessage").textContent = currentStatus;
+ }
+ if(content.length == 0) {
+ hide("leftCharsMessage");
+ } else if(showDetails == "true" && content.length < preferredLength) {
+ show("leftCharsMessage");
+ diff = (preferredLength - content.length);
+ var charLeft = diff + " characters are left";
+ if(document.all) {
+ document.getElementById("leftCharsMessage").innerText = charLeft;
+ } else {
+ document.getElementById("leftCharsMessage").textContent = charLeft;
+ }
+ } else {
+ hide("leftCharsMessage");
+ }
+}
+