@model PantheonRA.Contracts.DataContracts.CompanyInfoData
@{
    ViewBag.Title = Loc.Announcements;
    Html.RenderPartial("_Breadcrumb", new PantheonRA.BackOffice.Models.BreadcrumbViewModel
    {
        Links = new List<Tuple<string, string>> {
            new Tuple<string, string>(Loc.CompanyInfo, string.Empty)
        }
    });
}

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox">
                <div class="ibox-title"></div>
                <div class="ibox-content">
                    <table id="grid-data" data-grid-id="announcement" class="list-table" data-url="@Url.Action("AnnouncementData", "Announcement")">
                        <thead>
                            <tr>
                                <th data-column-id="Severity" data-sortable="true" data-formatter="severity">@Loc.Severity</th>
                                <th data-column-id="DateString" data-sortable="true" data-type="date">@Loc.Date</th>
                                <th data-column-id="Message" data-width="80%" data-sortable="false" data-formatter="message" data-css-class="message-text">@Loc.Message</th>
                            </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
    </div>
</div>

@section pageScripts{
    <script>
        $(document).ready(function () {
            window.localStorage.setItem('AnnouncementsCount', 0);

            var grid = $("#grid-data").bootgrid({
                ajax: true,
                type: 'POST',
                formatters: {
                    severity: function (column, row) {
                        switch(row.Severity) {
                            case "N":
                                return '@Loc.Announcement';
                            case "S":
                                return "<span class='text-danger'>" + '@Loc.Urgent' + "</span>";
                             case "T":
                                return '@Loc.Task';
                        }
                    },
                    message: function (column, row) {
                        return "<strong>" + row.Title + "</strong><br><span>" + urlify(row.Text.replace(/\n/g, "<br>")) + "</span>";
                    }
                },
                templates: {
                    search: "",
                    header: ""
                },
                labels: {
                    noResults: $("#bootgrid-noResults").val(),
                    infos: $("#bootgrid-infos").val(),
                    loading: $("#bootgrid-loading").val()
                }
            });
        });

        function urlify(text) {
            var urlRegex = /(https?:\/\/[^\s]+)/g;
            return text.replace(urlRegex, function (url) {
                return '<a href="' + url + '" target="_blank">' + url + '</a>';
            })
        }
    </script>
}