0

1

It'd be nice to have a custom field type for wiki articles. For example, we could create custom fields in cases like "Requirements" and "Specification" that would maintain links to wiki pages. Since FB would know the type in the field, it could also do things like show the current heading for the article and even show popup summaries of the pages, etc.

flag

1 Answer

0

Below is a customization/bugmonkey script I was able to create to provide the desired functionality:

name:          Customization to link custom fields that use W1234 syntax to their corresponding wiki pages.
description:   If the value of a custom field is the capital letter W followed by 2-6 digits, it will turn it into a wiki article link.
author:        Scott Willeke
version:       1.0.0.0

js:

    $('[id*="bugviewContainerSide"]').find(".content").each(
        function(index) {
            var wikiField = $(this);
            var oldValue = wikiField.html();
            var matchWikiLink = /^(W\d{2,6})$/;
            if (matchWikiLink.test(oldValue)) {
                console.log('matched wikifield:' + wikiField);
                var articleUrl = 'default.asp?' + oldValue;
                console.log('getting article:' + articleUrl);
                $.get(articleUrl, function(data) {
                    console.log('got article.');
                    //NOTE: <title> element seems stripped from $(data) object. Is also why jquery.load(...) with a selector won't work
                    var matchHtmlTitle = /<title>([^<>]+) - FogBugz<\/title>/i;
                    var articleTitle = matchHtmlTitle.exec(data);
                    if (articleTitle != null) {
                        articleTitle = articleTitle[1];
                    }
                    console.log('articleTitle:' + articleTitle);
                    // if for some reason we fail to get a good title, lets keep the Wnnnn link as the title
                    if (articleTitle == null || articleTitle.length == 0)
                        articleTitle = oldValue;
                    wikiField.html('<a href="default.asp?' + oldValue + '">' + articleTitle + '</a>');
                });
            }
        }
    );
link|flag

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.