(function () { 'use strict'; var app = angular.module('showboardsAdmin'); var templatePath = modulesSharedResourcesUrl + 'Modules/MyShowboardsAdmin/Views/'; app.directive('showboardsList', ['showboardsAdminDataContext', 'showboardsAdminService', '$filter', 'common', '$location', '$modal', function (showboardsAdminDataContext, showboardsAdminService, $filter, common, $location, $modal) { return { restrict: 'E', templateUrl: templatePath + 'showboardslist.html', link: link }; function link($scope, elem, attrs) { var getLogFn = common.logger.getLogFn; var logSuccess = getLogFn("showboardsAdmin", "success"); var logError = getLogFn("showboardsAdmin", "error"); function getShowboards() { showboardsAdminDataContext.getAllMyShowboards().then(function (data) { $scope.showboards = data; $scope.showboardsOriginal = angular.copy(data); $scope.showboardsLoaded = true; }); } $scope.getShowboardUser = function (showboard) { showboardsAdminService.getShowboardUserDetails(showboard); } $scope.manageShowboard = function (showboard) { showboardsAdminService.setCurrentShowboard(showboard); $location.path('/showboards/manage'); } $scope.deleteShowboard = function (showboard) { showboardsAdminDataContext.deleteShowboard(showboard).then(function (data) { logSuccess("Showboard deleted successfully"); getShowboards(); }); } $scope.searchShowboards = function (val) { $scope.showboards = $scope.showboardsOriginal; $scope.showboards = $filter('filter')($scope.showboards, { name: val, description: val }); if ($scope.showboards.length == 0) { $scope.noResults = true; } else { $scope.noResults = false; } } $scope.withdrawShowboard = function (showboard) { showboard.status = 2; showboardsAdminDataContext.updateShowboard(showboard).then(function (data) { logSuccess("Showboard withdrawn successfully"); getShowboards(); }); } $scope.pinShowboard = function (showboard) { showboard.isPinned = !showboard.isPinned; showboard.isTrue = showboard.isPinned; showboardsAdminDataContext.pinShowboard(showboard).then(function (data) { if (showboard.isTrue) { logSuccess("Pinned " + showboard.name); } else { logSuccess("Upinned " + showboard.name); } }); } $scope.likeShowboard = function (showboard) { if (!$scope.likingShowboard) { $scope.likingShowboard = true; showboard.isLiked = !showboard.isLiked; if (showboard.isLiked) { showboard.numLikes = showboard.numLikes + 1 } else { showboard.numLikes = showboard.numLikes - 1 } showboard.isTrue = showboard.isLiked; showboardsAdminDataContext.likeShowboard(showboard).then(function (data) { if (showboard.isTrue) { logSuccess("Liked " + showboard.name); } else { logSuccess("Unliked " + showboard.name); } $scope.likingShowboard = false; }); } } $scope.publishShowboard = function (showboard) { showboard.status = 1; showboardsAdminDataContext.updateShowboard(showboard).then(function (data) { logSuccess("Showboard withdrawn successfully"); getShowboards(); }); } $scope.viewShowboard = function (showboard) { showboardsAdminService.setCurrentShowboard(showboard); $location.path('/showboards/view'); } $scope.shareShowboard = function (showboard) { $modal.open({ templateUrl: templatePath + 'share.html', controller: shareShowboardController, size: 'sm', background: 'static', resolve: { showboard: function () { return showboard; }, } }); } var shareShowboardController = function (common, $scope, $modalInstance, showboard) { $scope.showboard = showboard; $scope.showboardUrl = showboardsUrl; //close the modal $scope.cancel = function () { $modalInstance.dismiss('cancel'); }; } getShowboards(); } }]); app.directive('viewShowboard', ['$window', 'user', '$filter', 'showboardsAdminDataContext', 'showboardsAdminService', 'virusScanModalService', 'common', '$location', '$modal', '$rootScope', function ($window, user, $filter, showboardsAdminDataContext, showboardsAdminService, virusScanModalService, common, $location, $modal, $rootScope) { return { restrict: 'E', templateUrl: templatePath + 'viewshowboard.html', link: link }; function link($scope, elem, attrs) { var getLogFn = common.logger.getLogFn; var logSuccess = getLogFn("showboardsAdmin", "success"); var logError = getLogFn("showboardsAdmin", "error"); $scope.showboard = showboardsAdminService.getCurrentShowboard(); showboardsAdminService.setCurrentShowboard(null); if (!$scope.showboard) { $location.path('/showboards'); } // figure how much space we have to play with and choose the best column layout if ($window.innerWidth > 1366) { $scope.fourColumnLayout = true; } else if ($window.innerWidth > 1024) { $scope.threeColumnLayout = true; } else if ($window.innerWidth > 768) { $scope.twoColumnLayout = true; } else { $scope.singleColumnLayout = true; } // This is a maybe as it slows the page but it may be needed if we need the colums to adjust when the window is resized $(window).on("resize.doResize", function (){ $scope.$apply(function() { // figure how much space we have to play with and choose the best column layout if ($window.innerWidth > 1366) { $scope.fourColumnLayout = true; $scope.threeColumnLayout = false; $scope.singleColumnLayout = false; $scope.twoColumnLayout = false; } else if ($window.innerWidth >= 1024) { $scope.threeColumnLayout = true; $scope.fourColumnLayout = false; $scope.singleColumnLayout = false; $scope.twoColumnLayout = false; } else if ($window.innerWidth > 768) { $scope.twoColumnLayout = true; $scope.fourColumnLayout = false; $scope.threeColumnLayout = false; $scope.singleColumnLayout = false; } else { $scope.singleColumnLayout = true; $scope.threeColumnLayout = false; $scope.fourColumnLayout = false; $scope.twoColumnLayout = false; } }); }); $scope.$on("$destroy",function (){ $(window).off("resize.doResize"); //remove the handler added earlier }); $rootScope.$on("updateItems", function (event, args) { if ($scope.showboardItemsOriginal) { $scope.showboardItemsOriginal.push(args); } }); $scope.orderByPredicate = function (val, reverse) { if (!reverse) { val = '-' + val; } $scope.showboard.showBoardItems = $filter('orderBy')($scope.showboard.showBoardItems, val); } $scope.inView = function (showboardItem, inView) { if (inView) { showboardItem.show = true } else { showboardItem.show = false } } $scope.searchShowboard = function (val, reverse, type) { $scope.showboard.showBoardItems = $scope.showboardItemsOriginal; if (type == 'tag') { $scope.showboard.showBoardItems = $filter('selectedTags')($scope.showboard.showBoardItems, val); $scope.showboard.search = val; if ($scope.showboard.showBoardItems.length == 0) { $scope.noResults = true; } else { $scope.noResults = false; } } else { if (typeof val !== 'object') { $scope.showboard.search = val; $scope.showboard.showBoardItems = $filter('filter')($scope.showboard.showBoardItems, val); if ($scope.showboard.showBoardItems.length == 0) { $scope.noResults = true; } else { $scope.noResults = false; } } if (!reverse) { $scope.showboard.showBoardItems = $filter('filter')($scope.showboard.showBoardItems, val); } else { $scope.showboard.showBoardItems = $filter('filter')($scope.showboard.showBoardItems, ''); } } $scope.orderByPredicate('-dateCreated', true); } if ($scope.showboard) { $scope.showboardItemsOriginal = angular.copy($scope.showboard.showBoardItems); showboardsAdminDataContext.updateShowboardView($scope.showboard); $scope.showboard.numTimesViewed = $scope.showboard.numTimesViewed + 1; user.getProfile().then(function (theUser) { $scope.user = theUser; }); $scope.orderByPredicate('-dateCreated', true); } $scope.getShowboardUser = function (showboard) { showboardsAdminService.getShowboardUserDetails(showboard); } $scope.getReportReason = function (reason) { return showboardsAdminService.getReportReason(reason); } $scope.canUserComment = function (element) { if (element) { if (element.commenting == 0) { return false; } if (element.commenting == 1) { if (!$scope.showboard.isAdmin) { return false; } else { return true; } } if (element.commenting == 2) { if ($scope.user) { if (element.createdBy == $scope.user.userId) { return true; } else if ($scope.showboard.isAdmin) { return true; } else { return false; } } } if (element.commenting == 3) { return true; } } } $scope.favouriteShowboardItem = function (showboardItem) { showboardItem.isFavourite = !showboardItem.isFavourite; showboardItem.isTrue = showboardItem.isFavourite; showboardsAdminDataContext.favouriteShowboardItem(showboardItem).then(function (data) { if (showboardItem.isTrue) { logSuccess("Set " + showboardItem.name + " as a favourite"); } else { logSuccess("Removed " + showboardItem.name + " as favourite"); } }); } $scope.likeShowboardItem = function (showboardItem) { if (!$scope.likingShowboardItem) { $scope.likingShowboardItem = true; showboardItem.isLiked = !showboardItem.isLiked; if (showboardItem.isLiked) { showboardItem.numLikes = showboardItem.numLikes + 1 } else { showboardItem.numLikes = showboardItem.numLikes - 1 } showboardItem.isTrue = showboardItem.isLiked; showboardsAdminDataContext.likeShowboardItem(showboardItem).then(function (data) { if (showboardItem.isTrue) { logSuccess("Liked " + showboardItem.name); } else { logSuccess("Unliked " + showboardItem.name); } $scope.likingShowboardItem = false; }); } } $scope.updateReportItem = function (report, status, showboardItem) { report.status = status showboardsAdminDataContext.updateShowboardItemReport(report).then(function (data) { logSuccess("Showboard item report updated"); for (i in showboardItem.issueReportsClassed.new) { if (showboardItem.issueReportsClassed.new[i].id == report.id) { showboardItem.issueReportsClassed.new.splice(i, 1); if (status == 2) { showboardItem.issueReportsClassed.resolved.push(report); } if (status == 1) { showboardItem.issueReportsClassed.inProgress.push(report); } } } }); } $scope.reportItem = function (reportedItem, type) { $modal.open({ templateUrl: templatePath + 'report.html', controller: reportItemController, size: 'sm', background: 'static', resolve: { reportedItem: function () { return reportedItem; }, type: function () { return type; } } }); } var reportItemController = function (common, $scope, $modalInstance, reportedItem, type) { $scope.reportedItem = reportedItem; $scope.reportItem = function (reason) { if (type == 'showboard') { showboardsAdminDataContext.reportShowboard($scope.reportedItem, reason).then(function (data) { logSuccess("Showboard reported"); $scope.reportSubmitted = true; $scope.reportedItem.hasOpenReport = true; }); } if (type == 'showboardItem') { showboardsAdminDataContext.reportShowboardItem($scope.reportedItem, reason).then(function (data) { logSuccess("Showboard item reported"); $scope.reportSubmitted = true; $scope.reportedItem.hasOpenReport = true; }); } } //close the modal $scope.cancel = function () { $modalInstance.dismiss('cancel'); }; } $scope.removeItem = function (showboardItem) { $modal.open({ templateUrl: templatePath + 'remove.html', controller: removeItemController, size: 'sm', background: 'static', resolve: { showboardItem: function () { return showboardItem; } } }); } var removeItemController = function (common, $scope, $modalInstance, showboardItem) { $scope.showboardItem = showboardItem; $scope.removeItem = function (reason) { $scope.showboardItem.status = 2; showboardsAdminDataContext.withdrawShowboardItem($scope.showboardItem).then(function (data) { logSuccess("Showboard item removed"); $modalInstance.dismiss('cancel'); }); } //close the modal $scope.cancel = function () { $modalInstance.dismiss('cancel'); }; } $scope.viewShowboardItem = function (showboardItem) { $modal.open({ templateUrl: templatePath + 'viewshowboarditem.html', controller: viewShowboardItemController, size: 'lg', background: 'static', windowClass: 'clean-full-modal', resolve: { showboard: function () { return $scope.showboard; }, showboardItem: function () { return showboardItem; }, user: function () { return $scope.user; }, canUserComment: function () { return $scope.canUserComment; } } }); } $scope.goBack = function(path) { showboardsAdminService.goBack(path); } var viewShowboardItemController = function (common, $scope, $modalInstance, showboardItem, user, showboard, canUserComment) { $scope.canUserComment = canUserComment; $scope.user = user; $scope.showboardItem = showboardItem; $scope.showboard = showboard; $scope.showboardItem.commenting = showboard.commenting; $scope.showcaseUrl = myShowcaseSiteUrl + 'showcase/' + $scope.showboardItem.externalId; showboardsAdminDataContext.updateShowboardItemView($scope.showboardItem); $scope.showboardItem.numTimesViewed = $scope.showboardItem.numTimesViewed + 1; //close the modal $scope.cancel = function () { $modalInstance.dismiss('cancel'); }; } $scope.addShowboardItem = function (showboardItem) { $modal.open({ templateUrl: templatePath + 'addshowboarditem.html', controller: addShowboardItemController, size: 'lg', background: 'static', resolve: { showboardItem: function () { return showboardItem; }, showboard: function () { return $scope.showboard; } } }); } var addShowboardItemController = function (common, $scope, $modalInstance, showboardItem, showboard) { $scope.showboard = showboard; $scope.showboardItem = showboardItem; $scope.showcases = []; //get showcases for this user function getShowcases() { showboardsAdminDataContext.getShowcases().then(function (result) { for (var i = 0; i < result.length; i++) { if (result[i].showcaseState == "Published") { $scope.showcases.push(result[i]); } } if ($scope.showcases.length == 0) { $scope.noShowcases = true; } }); } getShowcases(); if (!$scope.showboardItem) { $scope.showboardItem = showboardsAdminService.createBlankShowboardItem(); $scope.showboardItem.commenting = $scope.showboard.commenting; user.getProfile().then(function (theUser) { $scope.showboardItem.user = theUser; if (theUser.avatarDetails) { $scope.showboardItem.user.avatarUrlFull = theUser.avatarDetails.url; } }); $scope.showboardItem.showBoardItemTypeId = $scope.showboard.allowedItemTypes[0].showBoardItemTypeId; } $scope.showboardItem.showBoardId = $scope.showboard.id; $scope.saveShowboardItem = function () { if (!$scope.showboardItem.id) { $scope.showboardItem.status = 1; showboardsDataContext.createShowboardItem($scope.showboardItem).then(function (data) { $scope.showboard.showBoardItems.unshift(data); $rootScope.$broadcast('updateItems', data); logSuccess("Showboard item created successfully"); $modalInstance.dismiss('cancel'); $scope.saving = false; }).catch(function (errorData) { if (errorData === "Virus scan positive.") { virusScanModalService.virusModal(); } else { logError("An error occured saving the item."); } $scope.saving = false; $modalInstance.dismiss('cancel'); }); } else { $scope.showboardItem.status = 1; showboardsDataContext.updateShowboardItem($scope.showboardItem).then(function (data) { $scope.showboardItem.showBoardItemStyle = data.showBoardItemStyle; logSuccess("Showboard item updated successfully"); $modalInstance.dismiss('cancel'); $scope.saving = false; }).catch(function (errorData) { if (errorData === "Virus scan positive.") { virusScanModalService.virusModal(); } else { logError("An error occured saving the item."); } $scope.saving = false; $modalInstance.dismiss('cancel'); }); } } $scope.withdrawShowboardItem = function () { $scope.showboardItem.status = 2; showboardsAdminDataContext.updateShowboardItem($scope.showboardItem).then(function (data) { logSuccess("Showboard item updated successfully"); $modalInstance.dismiss('cancel'); $scope.saving = false; }); } $scope.getShowboardUser = function (showboardItem) { if (showboardItem.createdBy) { showboardsAdminService.getShowboardUserDetails(showboard); } } // Called when image file has been selected $scope.onFileSelect = function (files) { if (files) { $scope.errorMessage = null; $scope.file = files[0]; $scope.file.fileName = $scope.file.name; if ($scope.file.size > 20000000) { $scope.errorMessage = 'File size is too large, max 20MB'; return; } var reader = new FileReader(); reader.onload = function (e) { $scope.$apply(function () { // get loaded data and render preview. var image = new Image(); image.src = e.target.result; $scope.imagePreview = e.target.result; image.onload = function () { var height = this.height; var width = this.width; if (this.width > 450) { $scope.$apply(function () { $scope.showboardItem.showBoardItemStyle.imageHeight = height / (width / 450) + 'px'; }); } else { $scope.$apply(function () { $scope.showboardItem.showBoardItemStyle.imageHeight = height + 'px'; }); } } }); $scope.showboardItem.fileAsBase64 = reader.result; }; // Generate base 64 image for preview reader.readAsDataURL($scope.file); } } $scope.resetHeader = function (color) { $scope.file = null; $scope.showboardItem.showBoardItemStyle.imageHeight = '300px'; $scope.showboardItem.showBoardItemStyle.headerColour = color; $scope.showboardItem.showBoardItemStyle.headerImageUrl = null; $scope.imagePreview = null; } //close the modal $scope.cancel = function () { $modalInstance.dismiss('cancel'); }; } } }]); app.directive('manageShowboard', ['myUsersDataContext', 'showboardsAdminDataContext', 'showboardsAdminService', 'virusScanModalService', 'common', '$location', 'user', '$modal', 'OrganisationAdminService', function (myUsersDataContext, showboardsAdminDataContext, showboardsAdminService, virusScanModalService, common, $location, user, $modal, OrganisationAdminService) { return { restrict: 'E', templateUrl: templatePath + 'manageshowboard.html', link: link }; function link($scope, elem, attrs) { var getLogFn = common.logger.getLogFn; var logSuccess = getLogFn("showboardsAdmin", "success"); var logError = getLogFn("showboardsAdmin", "error"); $scope.showboard = showboardsAdminService.getCurrentShowboard(); showboardsAdminService.setCurrentShowboard(null); $scope.availablePosters = []; $scope.availablePosters.push({ name: 'Anonymous' }); // Watch for changes to the task badges $scope.$watchCollection('showboard.allocatedVisibleGroupIds', function (newValue, oldValue) { if (newValue !== oldValue) { var newArray = []; for (var i = 0; i < $scope.showboard.allocatedVisibleGroupIds; i++) { for (var j = 0; j < $scope.showboard.allocatedAccessibleGroupIds; j++) { if ($scope.showboard.allocatedVisibleGroupIds[i] == $scope.showboard.allocatedAccessibleGroupIds[j]) { newArray.push($scope.showboard.allocatedAccessibleGroupIds[j]); } } } $scope.showboard.allocatedAccessibleGroupIds = newArray; } }, true); if (!$scope.showboard) { $scope.showboard = showboardsAdminService.createBlankShowboard(); user.getProfile().then(function (theUser) { $scope.user = theUser; $scope.user.name = $scope.user.firstName + ' ' + $scope.user.lastName;; $scope.showboard.selectedPoster = theUser; $scope.showboard.selectedPoster.name = theUser.firstName + ' ' + theUser.lastName; $scope.availablePosters.push($scope.showboard.selectedPoster); if (theUser.avatarDetails) { $scope.showboard.selectedPoster.avatarUrlFull = theUser.avatarDetails.url; } }); } else { user.getProfile().then(function (theUser) { $scope.user = theUser; $scope.user.name = $scope.user.firstName + ' ' + $scope.user.lastName;; if ($scope.showboard.displayAsOrganisation) { $scope.availablePosters.push($scope.showboard.postingOrganisation); $scope.availablePosters.push($scope.user); $scope.showboard.selectedPoster = $scope.showboard.postingOrganisation; } else { $scope.user = theUser; $scope.showboard.selectedPoster = theUser; $scope.showboard.selectedPoster.name = theUser.firstName + ' ' + theUser.lastName; $scope.availablePosters.push($scope.showboard.selectedPoster); if (theUser.avatarDetails) { $scope.showboard.selectedPoster.avatarUrlFull = theUser.avatarDetails.url; } } }); } $scope.goBack = function (path) { showboardsAdminService.goBack(path); } $scope.selectPoster = function (poster) { $scope.showboard.isAnonymousPoster = false; if (poster.name == 'Anonymous') { $scope.showboard.isAnonymousPoster = true; return; } if (!angular.isUndefined(poster.type)) { $scope.showboard.selectedPoster = poster; $scope.showboard.displayAsOrganisation = true; $scope.showboard.postingOrganisation = poster; $scope.showboard.postingOrganisationId = poster.id; } else { $scope.showboard.displayAsOrganisation = false; $scope.showboard.selectedPoster = $scope.user; if ($scope.user.avatarDetails) { $scope.showboard.selectedPoster.avatarUrlFull = $scope.user.avatarDetails.url; } } } $scope.saveShowboard = function (publish) { var oldStatus = $scope.showboard.status; if (publish) { $scope.showboard.status = 1; } if (!$scope.showboard.id) { showboardsAdminDataContext.createShowboard($scope.showboard).then(function (data) { logSuccess("Showboard created successfully"); $location.path('/showboards'); }).catch(function (errorData) { $scope.showboard.status = oldStatus; if (errorData === "Virus scan positive.") { virusScanModalService.virusModal(); } else { logError("An error occured saving the item."); } $scope.saving = false; }); } else { showboardsAdminDataContext.updateShowboard($scope.showboard).then(function (data) { logSuccess("Showboard updated successfully"); $location.path('/showboards'); }).catch(function (errorData) { $scope.showboard.status = oldStatus; if (errorData === "Virus scan positive.") { virusScanModalService.virusModal(); } else { logError("An error occured saving the item."); } $scope.saving = false; }); } } $scope.getShowboardUser = function (showboard) { showboardsAdminService.getShowboardUserDetails(showboard); $scope.showboard.selectedPoster = showboard.user; } function getOrgs() { myUsersDataContext.getOrganisationsFull(0).then(function (data) { for (i in data) { $scope.availablePosters.push(data[i]); } }); } getOrgs(); $scope.showboardPreview = function () { $modal.open({ templateUrl: templatePath + 'showboardpreview.html', controller: showboardPreviewController, size: 'lg', windowClass: 'clean-full-modal', resolve: { showboard: function () { return $scope.showboard; } } }); } var showboardPreviewController = function (common, $scope, $modalInstance, showboard) { $scope.showboard = showboard; //close the modal $scope.cancel = function () { $modalInstance.dismiss('cancel'); }; } $scope.setAccessibility = function () { $modal.open({ templateUrl: templatePath + 'setaccessibility.html', controller: setAccessibilityController, size: 'lg', resolve: { showboard: function () { return $scope.showboard; } } }); } var setAccessibilityController = function (common, $scope, $modalInstance, showboard) { $scope.showboard = showboard; //close the modal $scope.cancel = function () { $modalInstance.dismiss('cancel'); }; } $scope.setVisibilty = function () { $modal.open({ templateUrl: templatePath + 'setvisibilty.html', controller: setVisibiltyController, size: 'lg', resolve: { showboard: function () { return $scope.showboard; } } }); } var setVisibiltyController = function (common, $scope, $modalInstance, showboard) { $scope.showboard = showboard; //close the modal $scope.cancel = function () { $modalInstance.dismiss('cancel'); }; } // Called when image file has been selected $scope.onFileSelect = function (files) { if (files) { $scope.errorMessage = null; $scope.file = files[0]; $scope.file.fileName = $scope.file.name; if ($scope.file.size > 20000000) { $scope.errorMessage = 'File size is too large, max 20MB'; return; } var reader = new FileReader(); reader.onload = function (e) { $scope.showboard.fileAsBase64 = reader.result; $scope.$apply(function () { // get loaded data and render preview. $scope.imagePreview = e.target.result; }); }; // Generate base 64 image for preview reader.readAsDataURL($scope.file); // Close the popover. $('[popover]').click(); } } //called when a logo is uploaded function fileUploadSuccess(files, data) { handleUploadResponse(files, data); return; } function handleUploadResponse(files, data) { data.url = data.url.replace(/^http:\/\//i, 'https://'); data.url = data.url.replace(/upload\//i, 'upload/w_1400/'); $scope.showboard.showBoardStyle.headerImageUrl = data.url; if (!$scope.showboard.id) { showboardsAdminDataContext.createShowboard($scope.showboard).then(function (data) { logSuccess("Showboard created successfully"); $location.path('/showboards'); }); } else { showboardsAdminDataContext.updateShowboard($scope.showboard).then(function (data) { logSuccess("Showboard updated successfully"); $location.path('/showboards'); }); } } // Generate the image upload process percentage function UploadProgress(percentComplete) { $scope.progress = percentComplete; $scope.uploadStatus = "Uploading... " + percentComplete + "%"; } function UploadError() { // Throw an error } $scope.checkShowboardValidility = function () { // if ($scope.showboard.publiclyVisible == null || $scope.showboard.publiclyVisible == undefined) { // return true; // } if ($scope.showboard.contributionLevel == null || $scope.showboard.contributionLevel == undefined) { return true; } if ($scope.showboard.commenting == null || $scope.showboard.commenting == undefined) { return true; } } } }]); angular.module('showboardsAdmin').filter('selectedTags', function () { return function (items, tag) { return items.filter(function (item) { for (var i in item.tags) { if (tag.toLowerCase() == item.tags[i].text.toLowerCase()) { return true; } } return false; }); }; }); })();