1
0
mirror of https://github.com/janeczku/calibre-web synced 2024-11-25 02:57:22 +00:00
calibre-web/test/js/runner.js

201 lines
6.1 KiB
JavaScript
Raw Normal View History

2018-10-03 12:20:10 +00:00
output_list = Array();
2018-12-28 12:46:53 +00:00
/* Level - 0: Summary; 1: Failed; 2: All; 3: Skipped 4: Error*/
2018-10-03 12:20:10 +00:00
function showCase(level) {
table_rows = document.getElementsByTagName("tr");
for (var i = 0; i < table_rows.length; i++) {
row = table_rows[i];
id = row.id;
2018-12-28 12:46:53 +00:00
// Show failed if all or failed or summary problems selected
2018-10-03 12:20:10 +00:00
if (id.substr(0,2) == 'ft') {
2018-12-28 12:46:53 +00:00
if (level == 2|| level == 1 || level == 5 ) {
row.classList.remove('hiddenRow');
2018-10-03 12:20:10 +00:00
}
else {
2018-12-28 12:46:53 +00:00
row.classList.add('hiddenRow');
2018-10-03 12:20:10 +00:00
}
}
2018-12-28 12:46:53 +00:00
// Show passed if all selected
2018-10-03 12:20:10 +00:00
if (id.substr(0,2) == 'pt') {
2018-12-28 12:46:53 +00:00
if (level == 2 ) {
2018-10-03 12:20:10 +00:00
row.classList.remove('hiddenRow');
}
else {
row.classList.add('hiddenRow');
}
}
2018-12-28 12:46:53 +00:00
// Show skipped if all or skipped or summary problems selected
2018-10-03 12:20:10 +00:00
if (id.substr(0,2) == 'st') {
2018-12-28 12:46:53 +00:00
if (level ==2 || level ==3 || level == 5) {
row.classList.remove('hiddenRow');
}
else {
row.classList.add('hiddenRow');
}
}
// Show error if all or error or summary problems selected
if (id.substr(0,2) == 'et') {
if (level ==4 || level == 2 || level == 5 ) {
2018-10-03 12:20:10 +00:00
row.classList.remove('hiddenRow');
}
else {
row.classList.add('hiddenRow');
}
}
2020-08-28 14:51:43 +00:00
// Show error if all or error or summary problems selected
if (id.substr(0,2) == 'su') {
if (level == 0 || level == 2) {
row.classList.remove('hiddenRow');
}
else {
row.classList.add('hiddenRow');
}
}
2018-10-03 12:20:10 +00:00
}
}
function showClassDetail(class_id, count) {
var testcases_list = Array(count);
var all_hidden = true;
for (var i = 0; i < count; i++) {
testcase_postfix_id = 't' + class_id.substr(1) + '.' + (i+1);
testcase_id = 'f' + testcase_postfix_id;
testcase = document.getElementById(testcase_id);
if (!testcase) {
testcase_id = 'p' + testcase_postfix_id;
testcase = document.getElementById(testcase_id);
}
if (!testcase) {
testcase_id = 's' + testcase_postfix_id;
testcase = document.getElementById(testcase_id);
}
2018-12-28 12:46:53 +00:00
if (!testcase) {
testcase_id = 'e' + testcase_postfix_id;
testcase = document.getElementById(testcase_id);
}
2018-10-03 12:20:10 +00:00
testcases_list[i] = testcase;
if (testcase.classList.contains('hiddenRow')) {
all_hidden = false;
}
}
for (var i = 0; i < count; i++) {
testcase = testcases_list[i];
if (!all_hidden) {
testcase.classList.remove('hiddenRow');
}
else {
testcase.classList.add('hiddenRow');
}
}
}
function showTestDetail(div_id){
var details_div = document.getElementById(div_id)
var displayState = details_div.style.display
// alert(displayState)
if (displayState != 'block' ) {
displayState = 'block'
details_div.style.display = 'block'
}
else {
details_div.style.display = 'none'
}
}
function html_escape(s) {
s = s.replace(/&/g,'&amp;');
s = s.replace(/</g,'&lt;');
s = s.replace(/>/g,'&gt;');
return s;
}
2018-12-28 12:46:53 +00:00
// rgb(38, 154, 188)#31b0d5
2018-10-03 12:20:10 +00:00
function drawCircle(pass, fail, error, skip){
2018-12-28 12:46:53 +00:00
var color = ["#5cb85c","#d9534f","#31b0d5","#f0ad4e"];
2018-10-03 12:20:10 +00:00
var data = [pass,fail,error,skip];
var text_arr = ["pass", "fail", "error","skip"];
var canvas = document.getElementById("circle");
var ctx = canvas.getContext("2d");
var startPoint=0;
var width = 20, height = 10;
var posX = 112 * 2 + 20, posY = 30;
var textX = posX + width + 5, textY = posY + 10;
for(var i=0;i<data.length;i++){
ctx.fillStyle = color[i];
ctx.beginPath();
ctx.moveTo(112,84);
ctx.arc(112,84,84,startPoint,startPoint+Math.PI*2*(data[i]/(data[0]+data[1]+data[2]+data[3])),false);
ctx.fill();
startPoint += Math.PI*2*(data[i]/(data[0]+data[1]+data[2]+data[3]));
ctx.fillStyle = color[i];
ctx.fillRect(posX, posY + 20 * i, width, height);
ctx.moveTo(posX, posY + 20 * i);
ctx.font = 'bold 14px';
ctx.fillStyle = color[i];
var percent = text_arr[i] + ":"+data[i];
ctx.fillText(percent, textX, textY + 20 * i);
}
}
function show_img(obj) {
var obj1 = obj.nextElementSibling
obj1.style.display='block'
2018-12-28 12:46:53 +00:00
var index = 0;
2018-10-03 12:20:10 +00:00
var len = obj1.getElementsByTagName('img').length;
var imgyuan = obj1.getElementsByClassName('imgyuan')[0]
//var start=setInterval(autoPlay,500);
2018-12-28 12:46:53 +00:00
obj1.onmouseover=function(){
2018-10-03 12:20:10 +00:00
clearInterval(start);
}
2018-12-28 12:46:53 +00:00
obj1.onmouseout=function(){
2018-10-03 12:20:10 +00:00
start=setInterval(autoPlay,1000);
}
for (var i = 0; i < len; i++) {
var font = document.createElement('font')
imgyuan.appendChild(font)
}
2018-12-28 12:46:53 +00:00
var lis = obj1.getElementsByTagName('font');
2018-10-03 12:20:10 +00:00
changeImg(0)
var funny = function (i) {
lis[i].onmouseover = function () {
index=i
changeImg(i)
}
}
for (var i = 0; i < lis.length; i++) {
funny(i);
}
function autoPlay(){
if(index>len-1){
index=0;
2018-12-28 12:46:53 +00:00
clearInterval(start);
2018-10-03 12:20:10 +00:00
}
changeImg(index++);
}
imgyuan.style.width= 25*len +"px";
2018-12-28 12:46:53 +00:00
2018-10-03 12:20:10 +00:00
function changeImg(index) {
var list = obj1.getElementsByTagName('img');
var list1 = obj1.getElementsByTagName('font');
for (i = 0; i < list.length; i++) {
list[i].style.display = 'none';
list1[i].style.backgroundColor = 'white';
}
list[index].style.display = 'block';
list1[index].style.backgroundColor = 'blue';
}
}
function hide_img(obj){
obj.parentElement.style.display = "none";
obj.parentElement.getElementsByClassName('imgyuan')[0].innerHTML = "";
2020-08-28 14:51:43 +00:00
}