Commit c58190ac authored by Gradl, Tobias's avatar Gradl, Tobias
Browse files

1005: Visualize coherence within individual group

Task-Url: https://pm.winseda.de/issues/1005
parent 55bfa974
var groupView;
$(document).ready(function() {
groupView = new GroupView();
});
function GroupView() {
this.auth = $("#uauth").val()=='true';
this.groupId = $("#groupid").val();
this.query();
this.options = {
wordcloud : {
selector: "#significant-terms-cloud",
tagcount: 100,
animate: true,
animateDirection: "topDown",
height: 500,
width: 700,
tagsize: {
factor: 80,
offset: 7
}
},
};
};
GroupView.prototype = new Basesearch();
GroupView.prototype.query = function() {
var _this = this;
$("#search-loading-indicator").removeClass("fade");
$.ajax({
url: window.location.pathname + "/query",
type: "GET",
encoding:"UTF-8",
dataType:"json",
contentType: "application/json; charset=UTF-8",
success: function(data) {
_this.processSearchResponse(data);
_this.loadSignificantTerms();
$("#search-loading-indicator").addClass("fade");
},
error: function() {
$("#search-loading-indicator").addClass("fade");
}
});
};
GroupView.prototype.processSearchResponse = function(data) {
$("#search-results").html("");
if (data!=null && data.results!=null && data.results.length>0) {
$("#search-result-stats").html("Angezeigt werden <strong>" + data.results.length + "</strong> von <strong>" + data.totalHits + "</strong> Treffern");
for (var i=0; i<data.results.length; i++) {
this.showSearchResponseItem(data.results[i]);
}
$(".wordcloud").hide();
} else {
$("#search-result-stats").html("");
$("#search-results").html("Keine Personen für <strong>" + $("#queryExpression").val() + "</strong> im angegebenen Zeitraum gefunden.");
$(".wordcloud").show();
}
};
GroupView.prototype.loadSignificantTerms = function() {
var _this = this;
$.ajax({
url: __util.composeUrl("groups/" + _this.groupId + "/significantTerms?size=" + _this.options.wordcloud.tagcount),
type: "GET",
dataType: "json",
success: function(data) { _this.fillSignificantTerms(data); },
error: __util.processServerError
});
};
GroupView.prototype.fillSignificantTerms = function(data) {
var _this = this;
var tags = [];
for (var i=0; i<data.length; i++) {
tags.push({
text: data[i].term,
size: (data[i].weight * _this.options.wordcloud.tagsize.factor) + _this.options.wordcloud.tagsize.offset,
title: data[i].count + " occurences"
});
}
tagCloud = new TagCloud({
tags: tags,
containerSelector: _this.options.wordcloud.selector,
animateTransform: _this.options.wordcloud.animate,
animateTransformDir: _this.options.wordcloud.animateDirection,
w: _this.options.wordcloud.width,
h: _this.options.wordcloud.height,
textClickEvent: function(tag) { _this.handleTagTextClicked(tag); }
});
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment