Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one or more
0003  * contributor license agreements.  See the NOTICE file distributed with
0004  * this work for additional information regarding copyright ownership.
0005  * The ASF licenses this file to You under the Apache License, Version 2.0
0006  * (the "License"); you may not use this file except in compliance with
0007  * the License.  You may obtain a copy of the License at
0008  *
0009  *    http://www.apache.org/licenses/LICENSE-2.0
0010  *
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  */
0017 
0018 /* Adds background colors to stripe table rows in the summary table (on the stage page). This is
0019  * necessary (instead of using css or the table striping provided by bootstrap) because the summary
0020  * table has hidden rows.
0021  *
0022  * An ID selector (rather than a class selector) is used to ensure this runs quickly even on pages
0023  * with thousands of task rows (ID selectors are much faster than class selectors). */
0024 function stripeSummaryTable() {
0025     $("#task-summary-table").find("tr:not(:hidden)").each(function (index) {
0026        if (index % 2 == 1) {
0027          $(this).css("background-color", "#f9f9f9");
0028        } else {
0029          $(this).css("background-color", "#ffffff");
0030        }
0031     });
0032 }
0033 
0034 function toggleThreadStackTrace(threadId, forceAdd) {
0035     var stackTrace = $("#" + threadId + "_stacktrace")
0036     if (stackTrace.length == 0) {
0037         var stackTraceText = $('#' + threadId + "_td_stacktrace").html()
0038         var threadCell = $("#thread_" + threadId + "_tr")
0039         threadCell.after("<tr id=\"" + threadId +"_stacktrace\" class=\"accordion-body\"><td colspan=\"4\"><pre>" +
0040             stackTraceText +  "</pre></td></tr>")
0041     } else {
0042         if (!forceAdd) {
0043             stackTrace.remove()
0044         }
0045     }
0046 }
0047 
0048 function expandAllThreadStackTrace(toggleButton) {
0049     $('.accordion-heading').each(function() {
0050         //get thread ID
0051         if (!$(this).hasClass("hidden")) {
0052             var trId = $(this).attr('id').match(/thread_([0-9]+)_tr/m)[1]
0053             toggleThreadStackTrace(trId, true)
0054         }
0055     })
0056     if (toggleButton) {
0057         $('.expandbutton').toggleClass('hidden')
0058     }
0059 }
0060 
0061 function collapseAllThreadStackTrace(toggleButton) {
0062     $('.accordion-body').each(function() {
0063         $(this).remove()
0064     })
0065     if (toggleButton) {
0066         $('.expandbutton').toggleClass('hidden');
0067     }
0068 }
0069 
0070 
0071 // inOrOut - true: over, false: out
0072 function onMouseOverAndOut(threadId) {
0073     $("#" + threadId + "_td_id").toggleClass("threaddump-td-mouseover");
0074     $("#" + threadId + "_td_name").toggleClass("threaddump-td-mouseover");
0075     $("#" + threadId + "_td_state").toggleClass("threaddump-td-mouseover");
0076     $("#" + threadId + "_td_locking").toggleClass("threaddump-td-mouseover");
0077 }
0078 
0079 function onSearchStringChange() {
0080     var searchString = $('#search').val().toLowerCase();
0081     //remove the stacktrace
0082     collapseAllThreadStackTrace(false)
0083     if (searchString.length == 0) {
0084         $('tr').each(function() {
0085             $(this).removeClass('hidden')
0086         })
0087     } else {
0088         $('tr').each(function(){
0089             if($(this).attr('id') && $(this).attr('id').match(/thread_[0-9]+_tr/) ) {
0090                 var children = $(this).children()
0091                 var found = false
0092                 for (var i = 0; i < children.length; i++) {
0093                     if (children.eq(i).text().toLowerCase().indexOf(searchString) >= 0) {
0094                         found = true
0095                     }
0096                 }
0097                 if (found) {
0098                     $(this).removeClass('hidden')
0099                 } else {
0100                     $(this).addClass('hidden')
0101                 }
0102             }
0103         });
0104     }
0105 }