We help IT Professionals succeed at work.
Get Started

Can an expert tell me what the following asp.net ajax jscript code does?

480 Views
Last Modified: 2013-12-17
SInce I can't find a javascript or an ASP.NET AJAX forum here (Why???), I guess this is the best place to ask an ASP.NET AJAX javascript  question! ;-)

I hope an expert can comment the following scriptlet of javascript code (from the ajax htmleditor control in AjaxControlToolkit), and tell me what's going on.  I haven't a clue, mainly because of the prominent regex.

500 pts to the expert that can answer the question!  Thanks.
checkState : function() {
        if(!AjaxControlToolkit.HTMLEditor.ToolbarButton.FontName.callBaseMethod(this, "checkState")) return false;
    
        var editor = this._designPanel;
        var param =null;
        try{param = (Function.createDelegate(editor, AjaxControlToolkit.HTMLEditor._queryCommandValue))("fontname");} catch(e){}
 
        if(!editor._FontNotSet)
        if(!param || param.length==0) {
            param = AjaxControlToolkit.HTMLEditor.getStyle(editor._doc.body,"font-family");
        }
 
        var el   = this._select;
        var i=0;
        if(param && param.length > 0) {
            var seek = param.toLowerCase().split(",")[0].replace(/^(['"])/,"").replace(/(['"])$/,"");
 
            for(i=0; i< el.options.length; i++) {
                var cur = el.options.item(i).value.toLowerCase().split(",")[0];
                if(cur==seek) break
            }
            if(i==el.options.length) {
                try {
                    var newopt = document.createElement("OPTION");
                    newopt.value = param.replace(/^(['"])/,"").replace(/(['"])$/,"");
                    newopt.text  = param.split(",")[0].replace(/^(['"])/,"").replace(/(['"])$/,"");
                    el.add(newopt,(AjaxControlToolkit.HTMLEditor.isIE)?i:null);
                    $addHandler(newopt, "click", this._onclick_option$delegate);
                } catch(e) {
                    i = 0;
                }
            }
        }
        el.selectedIndex = i;
    }

Open in new window

Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE