<commit_before>﻿@using CkanDotNet.Api.Model
@using CkanDotNet.Web.Models
@using CkanDotNet.Web.Models.Helpers
@model Package

@{
    bool editable = Convert.ToBoolean(ViewData["editable"]);
    string ratingId = GuidHelper.GetUniqueKey(16);
}

@if (Model.RatingsAverage.HasValue || editable)
{
<div id="@ratingId" class="rating">
    @{
    int rating = 0;
    if (Model.RatingsAverage.HasValue)
    {
        rating = (int)Math.Round(Model.RatingsAverage.Value);
    }
    }
    @for (int i = 1; i <= 5; i++)
    {
        @Html.RadioButton("newrate", i, rating == i)
    }
    
</div>
<span class="rating-response"></span>
}

<script language="javascript">
$("#@(ratingId)").stars({
    oneVoteOnly: true,
    @if (!editable)
    {  
        @:disabled: true, 
    }
    callback: function(ui, type, value){
        var url = "http://@SettingsHelper.GetRepositoryHost()/package/rate/@Model.Name?rating=" + value;
        $("#@(ratingId)_iframe").get(0).src = url;

        $(".rating-response").text("Thanks for your rating!");

        @if (SettingsHelper.GetGoogleAnalyticsEnabled()) 
        {
            <text>
            // Track the rating event in analytics
            _gaq.push([
                '_trackEvent',
                'Package:@Model.Name',
                'Rate',
                value,
                value]);
            </text>
        }           
    }
});
</script>

@if (editable)
{<commit_msg>Add support for dynamically resizing frame when rating submitted<commit_after>﻿@using CkanDotNet.Api.Model
@using CkanDotNet.Web.Models
@using CkanDotNet.Web.Models.Helpers
@model Package

@{
    bool editable = Convert.ToBoolean(ViewData["editable"]);
    string ratingId = GuidHelper.GetUniqueKey(16);
}

@if (Model.RatingsAverage.HasValue || editable)
{
<div id="@ratingId" class="rating">
    @{
    int rating = 0;
    if (Model.RatingsAverage.HasValue)
    {
        rating = (int)Math.Round(Model.RatingsAverage.Value);
    }
    }
    @for (int i = 1; i <= 5; i++)
    {
        @Html.RadioButton("newrate", i, rating == i)
    }
    
</div>
<span class="rating-response"></span>
}

<script language="javascript">
$("#@(ratingId)").stars({
    oneVoteOnly: true,
    @if (!editable)
    {  
        @:disabled: true, 
    }
    callback: function(ui, type, value){
        var url = "http://@SettingsHelper.GetRepositoryHost()/package/rate/@Model.Name?rating=" + value;
        $("#@(ratingId)_iframe").get(0).src = url;

        $(".rating-response").text("Thanks for your rating!");

        @if (SettingsHelper.GetIframeEnabled())
        {
            <text>resizeFrame();</text>
        }

        @if (SettingsHelper.GetGoogleAnalyticsEnabled()) 
        {
            <text>
            // Track the rating event in analytics
            _gaq.push([
                '_trackEvent',
                'Package:@Model.Name',
                'Rate',
                value,
                value]);
            </text>
        }           
    }
});
</script>

@if (editable)
{
{'fraction_non_alphanumeric': 0.15946843853820597, 'fraction_numerical': 0.003986710963455149, 'mean_word_length': 2.193001060445387, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 21, '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': '3508316', 'n_tokens_mistral': 984, 'n_tokens_neox': 937, 'n_words': 177}