Source

jackpot30 / remoting / server / web / web.ui / src / org / netbeans / modules / jackpot30 / backend / ui / showCode.html

<html>
<head>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js"></script>
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/themes/base/jquery-ui.css" rel="stylesheet" type="text/css">
    <script type="text/javascript">
        $(document).ready(function() {
            var $codeEl = $("#code");
            var $code = $codeEl.text();

            $codeEl.empty();
            
            var $highlights = "${categories}".split(", ");
            var $spans = [${spans}];
            var $current = 0;
            for (var i = 0; i < $highlights.length; i++ ) {
                $codeEl.append($('<a id="p' + $current + '"><span class="' + $highlights[i] + '"' + ($highlights[i].indexOf("identifier") !== (-1) ? ' onclick="ic(' + $current + ')"' : '') + '>' + $code.slice($current, $current+$spans[i]).replace('&', '&amp;').replace('<', '&lt;') + "</span></a>"));
                $current += $spans[i];
            }

            if (!window.location.hash) {
                var $params = window.location.search.substring(1).split("&");

                for (var i = 0; i < $params.length; i++) {
                    if ($params[i].indexOf("signature=") !== (-1)) {
                        $.get('/index/ui/target?path=${path}&relative=${relative}&signature=' + unescape($params[i].substring("signature=".length)), function(data) {
                            var parsedData = $.parseJSON(data);
                            if ("position" in parsedData) {
                                window.location.hash = "#p" + parsedData.position;
                            }

                        });
                    }
                }
            } else {
                window.location.hash = window.location.hash;
            }
        });

        function ic(pos) {
            $.get('/index/ui/target?path=${path}&relative=${relative}&position=' + pos, function(data) {
                var parsedData = $.parseJSON(data);
                if ("position" in parsedData) {
                    window.location.hash = "#p" + parsedData.position;
                } else if ("source" in parsedData) {
                    window.location = "/index/ui/show?path=" + parsedData.path + "&relative=" + parsedData.source + "&signature=" + parsedData.signature;
                } else if ("targets" in parsedData) {
                    var popupContent = "The target element is defined in the following files:<br>";
                    popupContent += "<ul>";

                    for (var i = 0; i < parsedData.targets.length; i++) {
                        var categoryData = parsedData.targets[i];
                        popupContent += "<li>" + categoryData.rootDisplayName/*XXX: escape*/ + "<br>";

                        for (var f = 0; f < categoryData.files.length; f++) {
                            popupContent += "<img src='/index/icons/javaFile.png' alt='Java File'/>"
                            popupContent += "<a href='/index/ui/show?path=" + categoryData.rootPath + "&relative=" + categoryData.files[i] + "&signature=" + parsedData.signature + "'>" + categoryData.files[i] + "</a><br>";
                        }

                        popupContent += "</li><br>";
                    }

                    popupContent += "</ul><br>";
                    $('#popup').html(popupContent)
                                    .dialog({
                                        title: 'Show',
                                        width: 800 //XXX: hardcoded size
                                    });
                } else if ("signature" in parsedData) {
                    alert("Cannot find source file for class: " + parsedData.signature.split(":")[1]);
                } else {
                    alert("Cannot resolve target on this place");
                }
            });
        }
    </script>
    <style type="text/css">
        .keyword {color: #0000FF; font-weight: bold;}
        .comment {color: #737373;}
        .character {color: #006F00;}
        .number {color: #780000;}
        .string {color: #99009D;}
        .identifier {}
        .identifier:hover { cursor: hand; cursor: pointer; text-decoration:underline; color:blue;}
        .whitespace {}
        .highlight {background-color:#DDDD00;}
        .constructor {font-weight: bold;}
        .method {font-weight: bold;}
        .field {color: #098618; font-weight: bold;}
        .parameter {color: #a06001;}
        .unused {color: gray;}
        .static {font-style:italic;}
    </style>
</head>
<body>
<pre id="code">
${code}
</pre>
<div id="popup"></div>
</body>
</html>