(function () { 'use strict'; var serviceId = 'showboardsService'; angular.module('showboards').factory(serviceId, ['user', '$location', showboardsService]); function showboardsService(user, $location) { var service = { getCurrentShowboard: getCurrentShowboard, setCurrentShowboard: setCurrentShowboard, createBlankShowboard: createBlankShowboard, getShowboardUserDetails: getShowboardUserDetails, createBlankShowboardItem: createBlankShowboardItem, goBack: goBack, getReportReason: getReportReason, getCurrentShowboardItem: getCurrentShowboardItem, setCurrentShowboardItem: setCurrentShowboardItem }; var currentShowboard; var currentShowboardItem; return service; function getCurrentShowboard() { return currentShowboard; } function setCurrentShowboard(showboard) { currentShowboard = showboard; } function getCurrentShowboardItem() { return currentShowboardItem; } function setCurrentShowboardItem(showboardItem) { currentShowboardItem = showboardItem; } // Create a blank showboard function createBlankShowboard() { return { name: '', description: '', displayAsOrganisation: false, publiclyVisible: null, publiclyAccessible: null, isDiscoverable: true, rules: '', tags: [], status: 0, showBoardStyle: { headerColour: 'primary', headerImageUrl: null }, numTimesViewed: 0, showBoardItems: [], allocatedAccessibleGroupIds: [], allocatedVisibleGroupIds: [] } } // Create a blank showboard function createBlankShowboardItem() { return { name: '', description: '', displayAsOrganisation: false, publiclyVisible: null, publiclyAccessible: null, tags: [], showBoardItemStyle: { headerColour: 'primary', headerImageUrl: null }, numTimesViewed: 0, status: 1 } } function getShowboardUserDetails(showboard) { user.getUserProfile(showboard.createdBy).then(function (data) { showboard.user = data; }); } // function to get back to the marking schemes list function goBack(path) { currentShowboard = null; $location.path(path); }; function getReportReason(reason) { if (reason == 0) { return "This isn't useful"; } if (reason == 1) { return 'This is inappropriate'; } if (reason == 2) { return 'This is factually incorrect'; } if (reason == 3) { return 'This offends me'; } if (reason == 4) { return 'This is spam'; } if (reason == 5) { return 'Other'; } } } angular.module('showboards').filter('filterByMultipleOf', function () { return function (items, options) { var count = 0; return items.filter(function (element, index) { if (index >= options.start) { if (count % options.multipleOf == 0) { count = count + 1; return element; } count = count + 1; } }); } }); })();