accurator/commit
looked over objects and made minor corrections
author | Cristina-Iulia Bucur |
---|---|
Thu Mar 24 17:37:24 2016 +0100 | |
committer | Cristina-Iulia Bucur |
Thu Mar 24 17:37:24 2016 +0100 | |
commit | 16219bf45c21982d2b86ee3d965e7cb01343e0c6 |
tree | 52ac7fc634b0e9f40a473032f0c614a4e3999094 |
parent | 2e4749e080d56013b83f2f0e1c0911516bfd4c5f |
Diff style: patch stat
diff --git a/web/js/components/cluster.js b/web/js/components/cluster.js index dcbeed0..d8d055c 100644 --- a/web/js/components/cluster.js +++ b/web/js/components/cluster.js @@ -47,7 +47,7 @@ Cluster.prototype.enrichItems = function() { // a link where it can be (further) annotated and a title var items = []; - for(var i=0; i<data.length; i++) { + for(var i = 0; i < data.length; i++) { items[i] = {}; var uri = data[i].uri; items[i].uri = uri; @@ -65,7 +65,7 @@ Cluster.prototype.addPath = function() { Cluster.prototype.addPagination = function(numberDisplayedItems) { var _cluster = this; - var paginationId = this.id + "Pagination" + var paginationId = this.id + "Pagination"; this.pagination = new Pagination( paginationId, @@ -102,7 +102,7 @@ Cluster.prototype.addThumbnails = function(numberDisplayedItems) { $(this.node).append( $.el.div({'class':'row', 'id':'thumbnailRow' + this.id})); - for (var i=0; i<stop; i++) { + for (var i = 0; i < stop; i++) { var thumbnail = new Thumbnail( this.items[i].uri, this.items[i].title, @@ -134,7 +134,8 @@ Cluster.prototype.changeThumbnails = function(currentPage, nextPage, numberDispl // console.log("start: " + start + " stop: " + stop + " page number: " + nextPage + " current page: " + currentPage + " cluster id: " + this.id + " displayed: " + numberDisplayedItems + " remove: " + remove); var thumbIndex = 0; // index of the thumbnail spots - for (var i=start; i<stop; i++) { + + for (var i = start; i < stop; i++) { var thumbnail = this.thumbnails[thumbIndex]; thumbnail.setImage(this.items[i].thumb); diff --git a/web/js/components/pagination.js b/web/js/components/pagination.js index ef939d8..040bec9 100644 --- a/web/js/components/pagination.js +++ b/web/js/components/pagination.js @@ -27,6 +27,7 @@ Pagination.prototype.getNumberOfPages = function() { } else { numberOfPages = (this.numberOfItems-restPages)/this.numberDisplayedItems+1; } + return numberOfPages; } @@ -35,27 +36,27 @@ Pagination.prototype.html = function() { if (this.numberOfPages == 1) return ""; // init HTML pagination, starting with a disabled left arrow and an active first page - var html = - $.el.ul({'class':'pagination pagination-sm'}, - $.el.li({'class':'disabled left-arrow'}, - $.el.span('\u00ab')), - $.el.li({'class':'active'}, - $.el.span(1)) + var html = $.el.ul({'class':'pagination pagination-sm'}, + $.el.li({'class':'disabled left-arrow'}, + $.el.span('\u00ab')), + $.el.li({'class':'active'}, + $.el.span(1)) ); // add additional pages - for (var i=2; i<=this.numberOfPages; i++) { + for (var i = 2; i <= this.numberOfPages; i++) { // create html for page number var pageNode = $.el.li($.el.span(i)); + this.addClickEvent(pageNode, i); html.appendChild(pageNode); }; // add right arrow to pagination - var rightArrow = - $.el.li({'class':'right-arrow'}, - $.el.span('\u00bb') + var rightArrow = $.el.li({'class':'right-arrow'}, + $.el.span('\u00bb') ); + this.addClickNext(rightArrow); html.appendChild(rightArrow); @@ -73,13 +74,17 @@ Pagination.prototype.addClickEvent = function(pageNode, i) { Pagination.prototype.addClickNext = function(pageNode) { var _page = this; - $(pageNode).on("click pagination", function() {_page.next();}); + $(pageNode).on("click pagination", function() { + _page.next(); + }); } Pagination.prototype.addClickPrevious = function(pageNode) { var _page = this; - $(pageNode).on("click pagination", function() {_page.previous();}); + $(pageNode).on("click pagination", function() { + _page.previous(); + }); } Pagination.prototype.next = function() { diff --git a/web/js/components/path.js b/web/js/components/path.js index cfaf326..6d00127 100644 --- a/web/js/components/path.js +++ b/web/js/components/path.js @@ -13,6 +13,7 @@ function Path(path, parentId) { Path.prototype.init = function() { this.node = this.html(); + if (typeof this.path === 'string' || this.path instanceof String) { this.addTitle(); } @@ -43,20 +44,20 @@ Path.prototype.addTitle = function() { Path.prototype.enrich = function() { var _path = this; - // no need for enriching if we have a title + // no need for enriching if we have a title, e.g. "random" for random objects if (typeof this.path === 'string' || this.path instanceof String) return; return $.ajax({type: "POST", url: "metadata", contentType: "application/json", - data: JSON.stringify({"uris":this.path, "type":"label"})}) + data: JSON.stringify({"uris": this.path, "type": "label"})}) .then(function(labels) { _path.labels = labels; - for (var i=0; i<_path.path.length; i++) { + for (var i = 0; i < _path.path.length; i++) { _path.elements[i] = { - uri:_path.path[i], - label:truncate(_path.labels[i], 50) + uri: _path.path[i], + label: truncate(_path.labels[i], 50) }; } @@ -70,15 +71,15 @@ Path.prototype.unfoldEvent = function() { var _path = this; var pathHtml = $.el.h4(); - for (var i=0; i<this.elements.length; i++) { + for (var i = 0; i < this.elements.length; i++) { // label colouring - if (i==0) { + if (i == 0) { pathHtml.appendChild( $.el.span({'class':'path-label path-literal'}, //TODO: Get the query? // query)); "query")); - } else if (i%2==0) { + } else if (i%2 == 0) { pathHtml.appendChild( $.el.span({'class':'path-label path-resource'}, this.elements[i].label)); @@ -101,3 +102,9 @@ Path.prototype.unfoldEvent = function() { ); }); } + +// TODO fold path in case the user clicks on the unfolded path; +// the path after this function looks the same as the initial one +Path.prototype.foldEvent = function() { + +} diff --git a/web/js/profile.js b/web/js/profile.js index 7d5b93d..9e41611 100644 --- a/web/js/profile.js +++ b/web/js/profile.js @@ -68,6 +68,7 @@ function populateRecentlyAnnotated(user) { function initLabels(labels) { // add retrieved labels to html elements document.title = labels.profilePageTitle; + // check if real name is available if (typeof realName !== 'undefined') { $("#profileHdrSlogan").prepend(labels.profileHdrSlogan + " " + realName + " "); diff --git a/web/js/results.js b/web/js/results.js index 9e6fdc6..f7c5757 100644 --- a/web/js/results.js +++ b/web/js/results.js @@ -2,7 +2,8 @@ Accurator Results Page showing overview of recommender/search results. Uses a lot of code from -pagination.js and thumbnail.js (in web/js/components) . +cluster.js, which in turn uses path.js, pagination.js and thumbnail.js +(in web/js/components). Options: @@ -24,7 +25,8 @@ Layout of the results: *******************************************************************************/ "use strict"; -// Display options deciding how to results get displayed + +// Display options deciding how the results get displayed var display = { layout: "cluster", numberDisplayedItems: 4, @@ -157,6 +159,7 @@ function results(target, labels) { query = "random"; random(query, labels, target, 20); } + localStorage.setItem("query", query); } @@ -218,7 +221,7 @@ function processClusters(data, query, labels) { statusMessage(labels.resultsTxtNoResults + query); return clusters; } else { - for (var i=0; i<data.clusters.length; i++) { + for (var i = 0; i < data.clusters.length; i++) { var uris = []; // uris of items in cluster var id = "cluster" + i; // id of cluster var path = data.clusters[i].path; @@ -228,6 +231,7 @@ function processClusters(data, query, labels) { clusters[i] = new Cluster(id, uris, path); } + return clusters; } } @@ -251,14 +255,14 @@ Display of results and helper functions for the display function drawResults(clusters) { drawRows(clusters); - for (var i=0; i<clusters.length; i++) + for (var i = 0; i < clusters.length; i++) drawCluster(clusters[i], clusters); } // Add rows for cluster items for the list view function drawRows(clusters) { if (display.layout === "cluster") { - for (var i=0; i<clusters.length; i++) { + for (var i = 0; i < clusters.length; i++) { $("#resultsDiv").append( clusters[i].node ); @@ -267,7 +271,7 @@ function drawRows(clusters) { var totalItems = itemsInClusters(clusters, clusters.length); var rows = getNumberOfRows(totalItems); - for (var i=0; i<rows; i++) { + for (var i = 0; i < rows; i++) { $("#resultsDiv").append( $.el.div({'class':'row', 'id':'resultsDivThumbnails' + i}) @@ -280,10 +284,11 @@ function drawRows(clusters) { function itemsInClusters(clusters, clusterIndex) { var totalItems = 0; - for (var i=0; i<clusterIndex; i++){ + for (var i = 0; i < clusterIndex; i++){ // count uris since cluster might not be enriched totalItems += clusters[i].uris.length; } + return totalItems; } @@ -324,7 +329,7 @@ function displayClusterAsList(cluster, clusters) { var itemsAdded = itemsInClusters(clusters, clusters.indexOf(cluster)); //for every item in this cluster, add the thumbnail in the list view - for (var itemIndex=0; itemIndex < cluster.uris.length; itemIndex++) { + for (var itemIndex = 0; itemIndex < cluster.uris.length; itemIndex++) { var rowNumber = parseInt(itemsAdded/display.numberDisplayedItems, 10); var rowId = "resultsDivThumbnails" + rowNumber; var index = itemsAdded%display.numberDisplayedItems; @@ -400,7 +405,7 @@ function resultLayoutButtons(results, labels) { var resultNodes = document.getElementById("resultsDiv"); // use pure javascript removal in order to not remove attached events - while (resultNodes.firstChild) { + while(resultNodes.firstChild) { resultNodes.removeChild(resultNodes.firstChild); }