<commit_before>/* global obogo */
(function () {
    var framework = obogo.app.framework;
    var $ = obogo.query;
    var cors = obogo.ajax.cors;

    var module = framework.module('blast');

    module.service('BlastService', function () {
        var scope = this;
        scope.state = 'launcher';

        var createdOn = new Date();

        scope.conversations = [
            {
                read: false,
                user: 1,
                company: {
                    name: 'Moxy'
                },
                displayName: '<NAME>',
                profile: {
                    firstName: 'Jim',
                    lastName: 'Bo'
                },
                avatar: 'images/gd2.jpg',
                summary: 'Hi Sally, Have you opted into the waiting list? We\'re slowly rolling it out to all our users at the minute but',
                messages: [
                    { user: 1, displayName: '<NAME>', text: 'Hello, world', createdOn: createdOn },
                    { user: 2, displayName: '<NAME>',
                        text: '<p>Hi Rob,</p>' +
                            '<p>Have you opted into the waiting list? We\'re slowly rolling it out to all our users at' +
                            'the minute but once you have opted in you should get access in the next few' +
                            'days. </p>' +
                            '<p>If you haven\'t opted in you can do so here - <br>' +
                            '<a href="https://app.intercom.io/inapps_optin" rel="nofollow" target="_blank">https://app.intercom.io/inapps_optin</a>' +
                            '</p>' +
                            '<p>Regards,<br>' +
                            'Martin</p>',
                        createdOn: createdOn },
                    { user: 1, displayName: '<NAME> 1', text: 'Goodbye 1', createdOn: createdOn }
                ],
                lastUpdatedOn: Date.now()
            },
            {
                read: false,
                user: 1,
                company: 'Moxy',
                displayName: '<NAME>',
                profile: {
                    firstName: 'Jim',
                    lastName: 'Bo'
                },
                avatar: 'images/gd2.jpg',
                summary: 'Hi Rob, Have you opted into the waiting list? We\'re slowly rolling it out to all our users at the minute but',
                messages: [
                    { user: 1, displayName: '<NAME>', text: 'Hello, world', createdOn: createdOn },
                    { user: 2, displayName: '<NAME>', text: 'Hello, again', createdOn: createdOn },
                    { user: 1, displayName: '<NAME>', text: 'Goodbye 2', createdOn: createdOn }
                ],
                lastUpdatedOn: Date.now()
            },
            {
                read: true,
                user: 1,
                company: 'Moxy',
                displayName: '<NAME>',
                profile: {
                    firstName: 'Jim',
                    lastName: 'Bo'
                },
                avatar: 'images/gd2.jpg',
                summary: 'Hi Mike, Have you opted into the waiting list? We\'re slowly rolling it out to all our users at the minute but',
                messages: [
                    { user: 1, displayName: '<NAME>', text: 'Hello, world', createdOn: createdOn },
                    { user: 2, displayName: '<NAME>', text: 'Hello, again', createdOn: createdOn },
                    { user: 1, displayName: '<NAME>', text: 'Goodbye 3', createdOn: createdOn }
                ],
                lastUpdatedOn: Date.now()
            },
            {
                read: true,
                user: 1,
                company: 'Moxy',
                displayName: '<NAME>',
                profile: {
                    firstName: 'Jim',
                    lastName: 'Bo'
                },
                avatar: 'images/gd2.jpg',
                summary: 'Hi Lori, Have you opted into the waiting list? We\'re slowly rolling it out to all our users at the minute but',
                messages: [
                    { user: 1, displayName: '<NAME>', text: 'Hello, world', createdOn: createdOn },
                    { user: 2, displayName: '<NAME>', text: 'Hello, again', createdOn: createdOn },
                    { user: 1, displayName: '<NAME>', text: 'Goodbye 4', createdOn: createdOn }
                ],
                lastUpdatedOn: Date.now()
            }
        ];

        scope.setState = function (state) {
            scope.state = state;
        };

        var $rootScope = module.get('$rootScope');

        cors.get('https://freegeoip.net/json/98.202.127.113', function (response) {
            var data = JSON.parse(response);
            scope.name = data.region_name;
            $rootScope.$broadcast('service::changed', scope.name);
        });

    });

    module.filter('upper', function () {
        return function (val) {
            return (val + '').toUpperCase();
        };
    });

    module.directive('goCloak', function () {
        return {
            link: function (scope, el) {
                el.removeAttribute('go-cloak');
            }
        };
    });

    module.directive('goShow', function () {
        return {
            link: function (scope, el) {

                var modelName = el.getAttribute('go-show');
                scope.$watch(modelName, function (newVal) {
                    if (newVal) {
                        $(el).css('display', null);
                    } else {
                        $(el).css('display', 'none');
                    }
                });

            }
        };
    });

    module.directive('goModel', function () {
        return {
            link: function (scope, el) {

                var modelName = el.getAttribute('go-model');

                scope.$watch(modelName, function (newVal) {
                    el.value = newVal;
                });

                function eventHandler(evt) {
                    scope.$resolve(modelName, el.value);
                    scope.$apply();
                }

                $(el).bind('change keyup blur', eventHandler);

                scope.$on('$destroy', function () {
                    $(el).unbindAll();
                });
            }
        };
    });

    module.directive('blastMain', function (BlastService) {
        return {
            link: function (scope, el) {
                scope.blastService = BlastService;

//                scope.toggleShow = function(){
//                    BlastService.show = !BlastService.show;
//                };
//
//                scope.$on('service::changed', function (event, value) {
//                    scope.$apply();
//                });
            }
        };
    });

})();
<commit_msg>blast - added the filter for blastTimeAgo<commit_after>/* global obogo */
(function () {
    var framework = obogo.app.framework;
    var $ = obogo.query;
    var cors = obogo.ajax.cors;

    var module = framework.module('blast');

    module.service('BlastService', function () {
        var scope = this;
        scope.state = 'launcher';

        var createdOn = new Date();

        scope.conversations = [
            {
                read: false,
                user: 1,
                company: {
                    name: 'Moxy'
                },
                displayName: '<NAME>',
                profile: {
                    firstName: 'Jim',
                    lastName: 'Bo'
                },
                avatar: 'images/gd2.jpg',
                summary: 'Hi Sally, Have you opted into the waiting list? We\'re slowly rolling it out to all our users at the minute but',
                messages: [
                    { user: 1, displayName: '<NAME>', text: 'Hello, world', createdOn: createdOn },
                    { user: 2, displayName: '<NAME>',
                        text: '<p>Hi Rob,</p>' +
                            '<p>Have you opted into the waiting list? We\'re slowly rolling it out to all our users at' +
                            'the minute but once you have opted in you should get access in the next few' +
                            'days. </p>' +
                            '<p>If you haven\'t opted in you can do so here - <br>' +
                            '<a href="https://app.intercom.io/inapps_optin" rel="nofollow" target="_blank">https://app.intercom.io/inapps_optin</a>' +
                            '</p>' +
                            '<p>Regards,<br>' +
                            'Martin</p>',
                        createdOn: createdOn },
                    { user: 1, displayName: '<NAME> 1', text: 'Goodbye 1', createdOn: createdOn }
                ],
                lastUpdatedOn: Date.now()
            },
            {
                read: false,
                user: 1,
                company: 'Moxy',
                displayName: '<NAME>',
                profile: {
                    firstName: 'Jim',
                    lastName: 'Bo'
                },
                avatar: 'images/gd2.jpg',
                summary: 'Hi Rob, Have you opted into the waiting list? We\'re slowly rolling it out to all our users at the minute but',
                messages: [
                    { user: 1, displayName: '<NAME>', text: 'Hello, world', createdOn: createdOn },
                    { user: 2, displayName: '<NAME>', text: 'Hello, again', createdOn: createdOn },
                    { user: 1, displayName: '<NAME>', text: 'Goodbye 2', createdOn: createdOn }
                ],
                lastUpdatedOn: Date.now()
            },
            {
                read: true,
                user: 1,
                company: 'Moxy',
                displayName: '<NAME>',
                profile: {
                    firstName: 'Jim',
                    lastName: 'Bo'
                },
                avatar: 'images/gd2.jpg',
                summary: 'Hi Mike, Have you opted into the waiting list? We\'re slowly rolling it out to all our users at the minute but',
                messages: [
                    { user: 1, displayName: '<NAME>', text: 'Hello, world', createdOn: createdOn },
                    { user: 2, displayName: '<NAME>', text: 'Hello, again', createdOn: createdOn },
                    { user: 1, displayName: '<NAME>', text: 'Goodbye 3', createdOn: createdOn }
                ],
                lastUpdatedOn: Date.now()
            },
            {
                read: true,
                user: 1,
                company: 'Moxy',
                displayName: '<NAME>',
                profile: {
                    firstName: 'Jim',
                    lastName: 'Bo'
                },
                avatar: 'images/gd2.jpg',
                summary: 'Hi Lori, Have you opted into the waiting list? We\'re slowly rolling it out to all our users at the minute but',
                messages: [
                    { user: 1, displayName: '<NAME>', text: 'Hello, world', createdOn: createdOn },
                    { user: 2, displayName: '<NAME>', text: 'Hello, again', createdOn: createdOn },
                    { user: 1, displayName: '<NAME>', text: 'Goodbye 4', createdOn: createdOn }
                ],
                lastUpdatedOn: Date.now()
            }
        ];

        scope.setState = function (state) {
            scope.state = state;
        };

        var $rootScope = module.get('$rootScope');

        cors.get('https://freegeoip.net/json/98.202.127.113', function (response) {
            var data = JSON.parse(response);
            scope.name = data.region_name;
            $rootScope.$broadcast('service::changed', scope.name);
        });

    });

    module.filter('upper', function () {
        return function (val) {
            return (val + '').toUpperCase();
        };
    });

    module.filter('blastTimeAgo', function () {

        var ago = ' ago';

        function timeAgo(date) {
            var interval, seconds;
            seconds = Math.floor((new Date() - date) / 1000);

            interval = Math.floor(seconds / 31536000);
            if (interval >= 1) {
                return interval + ' years' + ago;
            }

            interval = Math.floor(seconds / 2592000);
            if (interval >= 1) {
                return interval + ' months' + ago;
            }

            interval = Math.floor(seconds / 86400);
            if (interval >= 1) {
                return interval + ' days' + ago;
            }

            interval = Math.floor(seconds / 3600);
            if (interval >= 1) {
                return interval + ' hours' + ago;
            }

            interval = Math.floor(seconds / 60);
            if (interval >= 1) {
                return interval + ' mins' + ago;
            }

            interval = seconds < 0 ? 0 : Math.floor(seconds);

            if (interval <= 10) {
                return 'just now';
            }

            return interval + ' secs' + ago;
        }

        return function (date) {
            return timeAgo(date);
        };
    });

    module.directive('goCloak', function () {
        return {
            link: function (scope, el) {
                el.removeAttribute('go-cloak');
            }
        };
    });

    module.directive('goShow', function () {
        return {
            link: function (scope, el) {

                var modelName = el.getAttribute('go-show');
                scope.$watch(modelName, function (newVal) {
                    if (newVal) {
                        $(el).css('display', null);
                    } else {
                        $(el).css('display', 'none');
                    }
                });

            }
        };
    });

    module.directive('goModel', function () {
        return {
            link: function (scope, el) {

                var modelName = el.getAttribute('go-model');

                scope.$watch(modelName, function (newVal) {
                    el.value = newVal;
                });

                function eventHandler(evt) {
                    scope.$resolve(modelName, el.value);
                    scope.$apply();
                }

                $(el).bind('change keyup blur', eventHandler);

                scope.$on('$destroy', function () {
                    $(el).unbindAll();
                });
            }
        };
    });

    module.directive('blastMain', function (BlastService) {
        return {
            link: function (scope, el) {
                scope.blastService = BlastService;

//                scope.toggleShow = function(){
//                    BlastService.show = !BlastService.show;
//                };
//
//                scope.$on('service::changed', function (event, value) {
//                    scope.$apply();
//                });
            }
        };
    });

})();

{'fraction_non_alphanumeric': 0.12743980146220404, 'fraction_numerical': 0.007445167348581394, 'mean_word_length': 1.1881420604637511, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 64, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '6188838', 'n_tokens_mistral': 4034, 'n_tokens_neox': 3708, 'n_words': 998}