<% my $api = gitprep_api; my $user = param('user'); my $project = param('project'); my $display = stash('display') || ''; my $rev = stash('rev'); $rev = '' unless defined $rev; my $branches = stash('branches'); my $ssh_rep_url = stash('ssh_rep_url'); my $logined = $api->logined; my $type = $display eq 'tree' || $display eq 'tree_top' || $display eq 'blob' ? 'tree' : 'commits'; my $path = stash('Path'); my $title; my $rev_short; if (defined $rev && length $rev == 40) { $title = 'Tree'; $rev_short = substr($rev, 0, 10); } else { $title = 'Branch'; $rev_short = $rev; } %> %= javascript begin $(document).ready(function () { // Switch branches and tags var revs_init = false; $('#rev-btn').on('click', function () { if (!revs_init) { $.get('<%= url_for("/$user/$project/api/revs") %>', function (result) { var branch_names = result.branch_names; var tag_names = result.tag_names; var style = 'style="border-top-left-radius:0px;border-top-right-radius:0px;"'; if (branch_names.length === 0) { $('#branch-names-list').append( '
  • No branches
  • ' ); } else { for (var i = 0; i < branch_names.length; i++) { var branch_name = branch_names[i]; $('#branch-names-list').append( '
  • ' + branch_name + '">' + branch_name + '
  • ' ); } } if (tag_names.length === 0) { $('#tag-names-list').append( '
  • No tags
  • ' ); } else { for (var i = 0; i < tag_names.length; i++) { var tag_name = tag_names[i]; $('#tag-names-list').append( '
  • ' + tag_name + '">' + tag_name + '
  • ' ); } } $('#rev-popup') .css('display', 'block') .css('top', '5px') .css('left', '0px') ; }); revs_init = true; } else { $('#rev-popup') .css('display', 'block') .css('top', '5px') .css('left', '0px') ; } }); $('#revs-tab a').click(function (e) { e.preventDefault(); $(this).tab('show'); }) $('#rev-close').on('click', function () { $('#rev-popup').css('display', 'none'); }); // Repository URL buttons var http_rep_url = '<%= url_for("$user/$project.git")->to_abs %>'; var logined = <%= $logined ? 'true' : 'false' %>; var ssh_rep_url = '<%= $ssh_rep_url %>'; // Click HTTP button $('#btn_http').on('click', function () { $('#rep_url').val(http_rep_url); $('#btn_http').addClass('btn-info'); $('#btn_ssh').removeClass('btn-info'); }); // Click SSH button $('#btn_ssh').on('click', function () { $('#rep_url').val(ssh_rep_url); $('#btn_http').removeClass('btn-info'); $('#btn_ssh').addClass('btn-info'); }); // Initialize if (logined) { $('#btn_ssh').trigger('click'); } else { $('#btn_http').trigger('click'); } }); % end
    % if ($display eq 'tree' || $display eq 'blob') { %= include '/include/page_path', Path => $path; % }
    % if ($display eq 'tree_top') {
    % }