Changeset 26554


Ignore:
Timestamp:
2012-12-05T14:56:21+13:00 (11 years ago)
Author:
sjm84
Message:

More improvements to Greenbug

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/js/debug_scripts.js

    r26492 r26554  
    9292                $(this).val("Open editor");
    9393                _editingDiv.hide();
    94                 _mainDiv.css("height", "300px");
     94                _mainDiv.css("height", (_mainDiv.height() - 200) + "px");
    9595            }
    9696            else
     
    9898                $(this).val("Close editor");
    9999                _editingDiv.show();
    100                 _mainDiv.css("height", "500px");
     100                _mainDiv.css("height", (_mainDiv.height() + 200) + "px");
    101101            }
    102102        });
     
    129129                _xmlStatusBar.css({"color":"white", "background": "green"});
    130130                _xmlStatusBar.removeAttr("title");
    131                 _saveButton.removeAttr("disabled");
     131                if(_saveButton.val() == "Save changes")
     132                {
     133                    _saveButton.removeAttr("disabled");
     134                }
    132135            }
    133136           
     
    155158               
    156159                if(_currentName && _currentName.length > 0){parameters["s1.name"] = _currentName;}
    157                 if(_currentMatch && _currentMath.length > 0){parameters["s1.match"] = _currentMatch;}
     160                if(_currentMatch && _currentMatch.length > 0){parameters["s1.match"] = _currentMatch;}
     161               
     162                _saveButton.val("Saving...");
     163                _saveButton.attr("disabled", "disabled");
    158164               
    159165                $.post(url, parameters)
    160166                .success(function()
    161167                {
    162                     alert("The template has been saved successfully.");
     168                    $.ajax(gs.xsltParams.library_name + "?a=s&sa=c")
     169                    .success(function()
     170                    {
     171                        alert("The template has been saved successfully.");
     172                    })
     173                    .error(function()
     174                    {
     175                        alert("Error reloading collection.");
     176                    })
     177                    .complete(function()
     178                    {
     179                        _saveButton.val("Save changes");
     180                        _saveButton.removeAttr("disabled");
     181                    });
    163182                })
    164183                .error(function()
     
    242261            _currentMatch = match;
    243262       
     263            var responseName = "requestedNameTemplate";
     264       
    244265            var url = gs.xsltParams.library_name + "?a=g&rt=r&s=RetrieveXMLTemplateFromFile&s1.filePath=" + _currentFilepath + "&s1.namespace=" + _currentNamespace + "&s1.nodename=" + _currentNodename;
     266            if(_currentMatch && _currentMatch.length > 0){url += "&s1.match=" + _currentMatch; responseName = "requestedMatchTemplate";}
    245267            if(_currentName && _currentName.length > 0){url += "&s1.name=" + _currentName;}
    246             if(_currentMatch && _currentMatch.length > 0){url += "&s1.match=" + _currentMatch;}
    247268            $.ajax(url)
    248269            .success(function(response)
    249270            {
    250271                var template;
    251                 if(response.search(/<requestedTemplate>/) != -1)
    252                 {
    253                     var startIndex = response.indexOf("<requestedTemplate>") + ("<requestedTemplate>").length;
    254                     var endIndex = response.indexOf("</requestedTemplate>");
     272                if(response.search(responseName) != -1)
     273                {
     274                    var startIndex = response.indexOf("<" + responseName + ">") + responseName.length + 2;
     275                    var endIndex = response.indexOf("</" + responseName + ">");
    255276                    template = response.substring(startIndex, endIndex);
    256277                }
     
    303324            if(_debugOn && !_pauseSelector)
    304325            {
    305                 var infoContainer = $("<div>");
    306                 infoContainer.css({"cursor":"pointer", "border":"1px dashed #AAAAAA", "margin":"5px"});
    307                 var fromDIV = $("<div>");
    308                 var elementDIV = $("<div>");
    309 
    310                 elementDIV.css("font-size", "1.1em");
    311                 fromDIV.css("font-size", "0.9em");
    312 
    313                 infoContainer.append(fromDIV);
    314                 infoContainer.append(elementDIV);
    315                
    316                 _elements.push(infoContainer);
    317                
    318                 var filepath = $(this).attr("filename");
    319                 var fullNodename = $(this).attr("nodename");
    320                 var colonIndex = fullNodename.indexOf(":");
    321                 var namespace = fullNodename.substring(0, colonIndex);
    322                 var nodename = fullNodename.substring(colonIndex + 1);
    323                 var name = $(this).attr("name");
    324                 var match = $(this).attr("match");
    325 
    326                 addMouseEventsToInfoContainer(infoContainer, filepath, nodename, namespace, name, match);
    327                
    328                 var nodeName = $(this).attr("nodename");
    329                 var filename = $(this).attr("filename");
    330                 var attrstr = "";
    331                 var illegalNames = ["nodename", "filename", "style", "debug", "id", "class"];
    332 
    333                 $(this.attributes).each(function()
    334                 {
    335                     for(var i = 0; i < illegalNames.length; i++)
     326                var nodes = new Array();
     327                if($(this).is("table, tr"))
     328                {
     329                    var size = parseInt($(this).attr("debugSize"));
     330                    for(var i = 0; i < size; i++)
    336331                    {
    337                         if(this.name == illegalNames[i]){return;}
     332                        var tempNode = $("<div>");
     333                        tempNode.tempAttrs = new Array();
     334                        $(this.attributes).each(function()
     335                        {
     336                            if(this.value.charAt(0) == '[')
     337                            {
     338                                var values = eval(this.value);
     339                                if(values[i] == "")
     340                                {
     341                                    return;
     342                                }
     343                                tempNode.attr(this.name, values[i]);
     344                                tempNode.tempAttrs.push({name:this.name, value:values[i]});
     345                            }
     346                        });
     347                        nodes.push(tempNode);
    338348                    }
    339                     attrstr += this.name + "=\"" + this.value + "\" ";
     349                }
     350                else
     351                {
     352                    nodes.push(this);
     353                }
     354               
     355                $(nodes).each(function()
     356                {
     357                    var filepath = $(this).attr("filename");
     358                    var fullNodename = $(this).attr("nodename");
     359                    var colonIndex = fullNodename.indexOf(":");
     360                    var namespace = fullNodename.substring(0, colonIndex);
     361                    var nodename = fullNodename.substring(colonIndex + 1);
     362                    var name = $(this).attr("name");
     363                    var match = $(this).attr("match");
     364
     365                    var infoContainer = $("<div>");
     366                    infoContainer.css({"cursor":"pointer", "border":"1px dashed #AAAAAA", "margin":"5px"});
     367                    var fromDIV = $("<div>");
     368                    var elementDIV = $("<div>");
     369
     370                    elementDIV.css("font-size", "1.1em");
     371                    fromDIV.css("font-size", "0.9em");
     372
     373                    infoContainer.append(fromDIV);
     374                    infoContainer.append(elementDIV);
     375                   
     376                    _elements.push(infoContainer);
     377                   
     378                    addMouseEventsToInfoContainer(infoContainer, filepath, nodename, namespace, name, match);
     379                   
     380                    var attrstr = "";
     381                    var illegalNames = ["nodename", "filename", "style", "debug", "id", "class"];
     382
     383                    var attributes = ((this.tempAttrs) ? this.tempAttrs : this.attributes);
     384                   
     385                    $(attributes).each(function()
     386                    {
     387                        for(var i = 0; i < illegalNames.length; i++)
     388                        {
     389                            if(this.name == illegalNames[i]){return;}
     390                        }
     391                        attrstr += this.name + "=\"" + this.value + "\" ";
     392                    });
     393                   
     394                    fromDIV.text("From " + filepath + ":");
     395                    elementDIV.text("<" + fullNodename + " " + attrstr + ">");
     396                   
     397                    _textDiv.prepend(infoContainer);
    340398                });
    341                
    342                 fromDIV.text("From " + filename + ":");
    343                 elementDIV.text("<" + nodeName + " " + attrstr + ">");
    344                
    345                 _textDiv.prepend(infoContainer);
    346399               
    347400                if(!_itemSelected)
Note: See TracChangeset for help on using the changeset viewer.