<commit_before>{% extends "base.html" %}
{% block title %}Workflow Details{% endblock %}
{% block javascript_includes %}
<script type="text/javascript" src="{{ url_for ('static', filename='js/highcharts/highcharts.js') }}"></script>
{% endblock %}
{% block javascript_init %}
<script type="text/javascript" charset="utf-8">
var chart;
var chartOptions;
var chartData = 
{
	Running: 
	{
		jobs: {{ counts.others - counts.others_workflow }},
		workflow: {{ counts.others_workflow }},
		total: {{ counts.others }}
	},
	Successful: 
	{
		jobs: {{ counts.success - counts.success_workflow }},
		workflow: {{ counts.success_workflow }},
		total: {{ counts.success }}
	},
	Failed: 
	{
		jobs: {{ counts.fail - counts.fail_workflow }},
		workflow: {{ counts.fail_workflow }},
		total: {{ counts.fail }}
	}
}

$(document).ready (function () 
{
	// Radialize the colors
    Highcharts.getOptions ().colors = $.map (Highcharts.getOptions ().colors, function (color) 
    {
        return {
            radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
            stops: [
                [0, color],
                [1, Highcharts.Color (color).brighten (-0.3).get ('rgb')] // darken
            ]
        };
    });
	
	$('#jobs_tabs').tabs (
	{
		ajaxOptions: 
		{
			error: function (xhr, status, index, anchor) 
			{
				$(anchor.hash).html ("We encountered an error loading this tab.");
			}
		},
		load: function(event, ui)
		{ 
			if (ui.index == 0)
			{
				if ($('#sub_workflows').html() == '')
				{
					$('#sub_workflows').html('No sub-workflows found.')	
				}
				else
				{
					$('#sub_workflows_list').dataTable ({"bJQueryUI" : true, "sPaginationType": "full_numbers"});
				}
			}
			else if (ui.index == 1)
			{
				if ($('#failed_jobs').html() == '')
				{
					$('#failed_jobs').html('No failed jobs.')
				}
				else
				{
					$('#failed_jobs_list').dataTable ({"bJQueryUI" : true, "sPaginationType": "full_numbers"});
				}
			}
			else if (ui.index == 2)
			{
				if ($('#running_jobs').html() == '')
				{
					$('#running_jobs').html('No running jobs.')
				}
				else
				{
					$('#running_jobs_list').dataTable ({"bJQueryUI" : true, "sPaginationType": "full_numbers"});
				}
			}
			else if (ui.index == 3)
			{
				if ($('#successful_jobs').html() == '')
				{
					$('#successful_jobs').html('No successful jobs.')
				}
				else
				{
					$('#successful_jobs_list').dataTable ({"bJQueryUI": true,
							"sPaginationType": "full_numbers",
							"bProcessing": true,
							"bServerSide": true,
							"sAjaxSource": "{{ url_for ('successful_jobs', root_wf_id = root_wf_id, wf_id = wf_id) }}",
							"bAutoWidth": false,
							"aoColumns": [
							              { "mData": "Job Name" },
							              { "mData": "Time Taken", "sClass": "nowrap" }
							            ]
					});
				}
			}
		} 
	});
	
	$("#jobs_tabs").bind ("tabsselect", function (event, ui) 
	{ 
		window.location.hash = ui.tab.hash;

		if (ui.index == 3)
		{
			$('#successful_jobs_list').dataTable ({"bJQueryUI": true,
					"sPaginationType": "full_numbers",
					"bProcessing": true,
					"bServerSide": true,
					"sAjaxSource": "{{ url_for ('successful_jobs', root_wf_id = root_wf_id, wf_id = wf_id) }}",
					"bAutoWidth": false,
					"aoColumns": [
					              { "mData": "Job Name" },
					              { "mData": "Time Taken", "sClass": "nowrap" }<commit_msg>Prevent data tables from being reinitialized, and remove unnecessary code from load event<commit_after>{% extends "base.html" %}
{% block title %}Workflow Details{% endblock %}
{% block javascript_includes %}
<script type="text/javascript" src="{{ url_for ('static', filename='js/highcharts/highcharts.js') }}"></script>
{% endblock %}
{% block javascript_init %}
<script type="text/javascript" charset="utf-8">
var tablesInitialized = [false, false, false, false]

var chart;
var chartOptions;
var chartData = 
{
	Running: 
	{
		jobs: {{ counts.others - counts.others_workflow }},
		workflow: {{ counts.others_workflow }},
		total: {{ counts.others }}
	},
	Successful: 
	{
		jobs: {{ counts.success - counts.success_workflow }},
		workflow: {{ counts.success_workflow }},
		total: {{ counts.success }}
	},
	Failed: 
	{
		jobs: {{ counts.fail - counts.fail_workflow }},
		workflow: {{ counts.fail_workflow }},
		total: {{ counts.fail }}
	}
}

$(document).ready (function () 
{
	// Radialize the colors
    Highcharts.getOptions ().colors = $.map (Highcharts.getOptions ().colors, function (color) 
    {
        return {
            radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
            stops: [
                [0, color],
                [1, Highcharts.Color (color).brighten (-0.3).get ('rgb')] // darken
            ]
        };
    });
	
	$('#jobs_tabs').tabs (
	{
		ajaxOptions: 
		{
			error: function (xhr, status, index, anchor) 
			{
				$(anchor.hash).html ("We encountered an error loading this tab.");
			}
		},
		load: function(event, ui)
		{ 
			if (ui.index == 0)
			{
				if ($('#sub_workflows').html() == '')
				{
					$('#sub_workflows').html('No sub-workflows found.')	
				}
				else
				{
					$('#sub_workflows_list').dataTable ({"bJQueryUI" : true, "sPaginationType": "full_numbers"});
				}
			}
			else if (ui.index == 1)
			{
				if ($('#failed_jobs').html() == '')
				{
					$('#failed_jobs').html('No failed jobs.')
				}
				else
				{
					$('#failed_jobs_list').dataTable ({"bJQueryUI" : true, "sPaginationType": "full_numbers"});
				}
			}
			else if (ui.index == 2)
			{
				if ($('#running_jobs').html() == '')
				{
					$('#running_jobs').html('No running jobs.')
				}
				else
				{
					$('#running_jobs_list').dataTable ({"bJQueryUI" : true, "sPaginationType": "full_numbers"});
				}
			}
		} 
	});
	
	$("#jobs_tabs").bind ("tabsselect", function (event, ui) 
	{ 
		window.location.hash = ui.tab.hash;
	
		if (ui.index == 3 && !tablesInitialized [ui.index])
		{
			tablesInitialized [ui.index] = true;
			
			$('#successful_jobs_list').dataTable ({"bJQueryUI": true,
					"sPaginationType": "full_numbers",
					"bProcessing": true,
					"bServerSide": true,
					"sAjaxSource": "{{ url_for ('successful_jobs', root_wf_id = root_wf_id, wf_id = wf_id) }}",
					"bAutoWidth": false,
					"aoColumns": [
					              { "mData": "Job Name" },
					              { "mData": "Time Taken", "sClass": "nowrap" }
{'fraction_non_alphanumeric': 0.1910928616550853, 'fraction_numerical': 0.004895767530006317, 'mean_word_length': 2.6927113702623906, 'pattern_counts': {'":': 36, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4043871', 'n_tokens_mistral': 2705, 'n_tokens_neox': 2184, 'n_words': 424}