Trying to add button to fogbugz customization so we can condense some articles

34 Views Asked by At

Fogbugz has updated the way that their pages are generated... They call it ocelot. This JQuery no longer works in their customizations.

The goal of the code was to take any of the text generated with "__" and hide it, but add an element that could be double-clicked that would show all of those elements.

I can't even seem to be able to get any elements added to the html, but I can manipulate the CSS. Any suggestions?

js:

$("div.codesnippet").each(function() {
    try {
        //collapse if code block starts with two leading underscores    
        var codeblock = $(this).find("pre.prettyprint");    
        var txt = codeblock.text();
        if(Left(txt,2)=="__") {
            $(this).addClass("collapsed");
            var firstspan = $($(codeblock).find("span")[0]);
            $(firstspan).text($(firstspan).text().replace("__",""));    
        }
    } catch (err) {
        //alert("div.codesnippet: " + err.message);   
    }
});
$("code.inline-codesnippet").each(function() {
    try {
        var span = $($(this).find("span")[0]);        
        var txt = span.html();
        if (typeof txt === "undefined"){return;}
        
        if(Left(txt,3)=="__ ") {
            span.html(' ' + Mid(txt,4));
        } else if (Left(txt,2)=="__") {
            span.html(Mid(txt,3));
        }            
    } catch (err) {
        //alert("error inline-codesnippet: " + err.message);
        //alert("span contents: " + txt);
    }
});
$("div.codesnippet").attr("title", "Double-click to collapse/expand");
$("div.codesnippet").dblclick(function() {
    $(this).toggleClass("collapsed");
});

css:

div.codesnippet.collapsed {
  height: 20px;
  background-color: #DDD;
  overflow: hidden !important;
  cursor: default;
}
.bugevent code.inline-codesnippet {
  padding-left: 33px;
}```


Tried rewriting all of the jquery, even just to add a single element, but nothing showed on the DOM
0

There are 0 best solutions below