Commit 9039d266 authored by Tom Käsler's avatar Tom Käsler

fix jshint blarf

parent 1547181d
......@@ -25,11 +25,16 @@
"Template": false,
"ReactiveCountdown": false,
"App": false,
"Papa": true,
"console": false,
"closeSplashscreen": true,
"showSplashscreen": true,
"closeAndRedirectTo": true,
"Braintree": true,
"confirm": true,
"email": true,
"jQuery": true,
"braintree": true,
"BrainTreeConnect": true,
"Npm": true,
"EasySearch": true,
......
......@@ -9,7 +9,7 @@ import {Cards } from '../../api/cards.js';
import {Categories } from '../../api/categories.js';
import {Ratings } from '../../api/ratings.js';
import {Paid } from '../../api/paid.js';
import {Notifications } from '../../api/notifications.js';
import {ReactiveVar} from 'meteor/reactive-var';
import '../card/card.js';
import '../learn/box.js';
......@@ -65,7 +65,7 @@ Template.cardset.rendered = function () {
}
});
}
}
};
Template.cardset.helpers({
'onEditmodalClose': function (id) {
......@@ -101,7 +101,7 @@ Template.cardset.helpers({
return this.owner === Meteor.userId() || hasRole;
},
'isLecturerAndHasRequest': function () {
return (Roles.userIsInRole(Meteor.userId(), 'lecturer') && this.request === true && this.owner !== Meteor.userId())
return (Roles.userIsInRole(Meteor.userId(), 'lecturer') && this.request === true && this.owner !== Meteor.userId());
}
});
......@@ -343,7 +343,7 @@ Template.cardsetDetails.events({
"click #leftCarouselControl, click #rightCarouselControl": function () {
ifCardset();
},
'click .item.active .block a': function () {
'click .item.active .block a': function (evt) {
evt.stopPropagation();
}
});
......@@ -411,7 +411,7 @@ Template.cardsetPreview.events({
"click #leftCarouselControl, click #rightCarouselControl": function () {
ifCardset();
},
'click .item.active .block a': function () {
'click .item.active .block a': function (evt) {
evt.stopPropagation();
}
});
......@@ -518,7 +518,7 @@ Template.cardsetInfo.helpers({
if (this.license.includes('nd')) {licenseString = licenseString.concat('<img src="/img/nd.large.png" alt="Keine Bearbeitung" />'); }
if (this.license.includes('sa')) {licenseString = licenseString.concat('<img src="/img/sa.large.png" alt="Weitergabe unter gleichen Bedingungen" />'); }
return new Spacebars.SafeString(licenseString)
return new Spacebars.SafeString(licenseString);
} else {
return new Spacebars.SafeString('<img src="/img/zero.large.png" alt="Kein Copyright" />');
}
......@@ -556,7 +556,8 @@ Template.cardsetInfo.events({
}
},
'click #exportCardsBtn': function () {
var cardset = Cardsets.findOne(this._id);
//TODO: linked to todo below
/*var cardset = Cardsets.findOne(this._id);
var cards = Cards.find({
cardset_id: this._id
}, {
......@@ -568,18 +569,19 @@ Template.cardsetInfo.events({
}).fetch();
var cardsString = '';
for (var card in cards) {
cardsString += JSON.stringify(cards[card]);
for (var i = 0; i < cards.length; i++) {
cardsString += JSON.stringify(cards[i]);
if (cards.length - 1 > card) {
if (cards.length - 1 > cards[i]) {
cardsString += ", ";
}
}
var exportData = new Blob([cardsString], {
type: "application/json"
});
saveAs(exportData, cardset.name + ".json");
});*/
//TODO: This function is not defined... do something!
//saveAs(exportData, cardset.name + ".json");
}
});
......@@ -701,11 +703,11 @@ Template.cardsetPublicateForm.onRendered(function () {
$('#publicateKind > label').removeClass('active');
$('#publicateKind > label > input').filter(function () {
return this.value === cardset.kind
return this.value === cardset.kind;
}).parent().addClass('active');
$('#publicateKind > label > input').filter(function () {
return this.value === cardset.kind
return this.value === cardset.kind;
}).prop('checked', true);
var kindWithPrice = (cardset.kind === 'edu' || cardset.kind === 'pro');
......@@ -762,7 +764,7 @@ Template.cardsetPublicateForm.events({
Meteor.call("publicateCardset", id, kind, price, visible);
$('#publicateModal').modal('hide');
},
'change #publicateKind': function (evt, tmpl) {
'change #publicateKind': function () {
var kind = $('#publicateKind input[name=kind]:checked').val();
var kindWithPrice = (kind === 'edu' || kind === 'pro');
Session.set('kindWithPrice', kindWithPrice);
......@@ -821,7 +823,9 @@ Template.selectLicenseForm.helpers({
if (cardset !== undefined) {
var licenses = cardset.license;
if (licenses.includes(license)) return true;
if (licenses.includes(license)) {
return true;
}
} else {
return null;
}
......@@ -844,7 +848,7 @@ Template.reportCardsetForm.onRendered(function () {
});
});
Template.reportCardsetForm.events({
'click #reportCardsetSave': function (evt, tmpl) {
'click #reportCardsetSave': function () {
if ($('#reportCardsetText').val().length < 50) {
$('#reportCardsetTextLabel').css('color', '#b94a48');
$('#reportCardsetText').css('border-color', '#b94a48');
......@@ -860,7 +864,7 @@ Template.reportCardsetForm.events({
link_id = this.owner;
} else {
type = "Gemeldeter Kartensatz";
link_id = this._id
link_id = this._id;
}
var target = "admin";
......
......@@ -5,7 +5,6 @@ import {Template } from 'meteor/templating';
import {Session } from 'meteor/session';
import {Cardsets } from '../../api/cardsets.js';
import {Categories } from '../../api/categories.js';
import {Learned } from '../../api/learned.js';
......@@ -70,8 +69,9 @@ Template.learned.helpers({
var learnedCardsets = [];
learnedCards.forEach(function (learnedCard) {
if ($.inArray(learnedCard.cardset_id, learnedCardsets) === -1)
learnedCardsets.push(learnedCard.cardset_id);
if ($.inArray(learnedCard.cardset_id, learnedCardsets) === -1) {
learnedCardsets.push(learnedCard.cardset_id);
}
});
return Cardsets.find({
......@@ -121,7 +121,7 @@ Template.cardsets.events({
$('#newSetCategory').text(categoryName);
tmpl.find('#newSetCategory').value = categoryId;
},
'click #newSetModal .save': function (evt) {
'click #newSetModal .save': function () {
if ($('#newSetName').val() === "") {
$('#newSetNameLabel').css('color', '#b94a48');
$('#newSetName').css('border-color', '#b94a48');
......
......@@ -4,7 +4,6 @@ import {Meteor } from 'meteor/meteor';
import {Template } from 'meteor/templating';
import {Session } from 'meteor/session';
import {Cardsets } from '../../api/cardsets.js';
import {Cards } from '../../api/cards.js';
import {Learned } from '../../api/learned.js';
......
......@@ -4,7 +4,6 @@ import {Meteor } from 'meteor/meteor';
import {Template } from 'meteor/templating';
import {Session } from 'meteor/session';
import {Cardsets } from '../../api/cardsets.js';
import {Cards } from '../../api/cards.js';
import {Learned } from '../../api/learned.js';
......
......@@ -12,7 +12,7 @@ import '../welcome/welcome.js';
import '../impressum/impressum.js';
import '../cardsets/cardsets.js';
import '../pool/pool.js';
import '../profile/profile.js'
import '../profile/profile.js';
import '../admin/admin.js';
import '../access_denied/access_denied.js';
......@@ -63,8 +63,7 @@ Template.main.helpers({
},
searchCategories: function () {
if (Session.get("searchValue")) {
results = CardsetsIndex.search(Session.get("searchValue")).fetch();
return results;
return CardsetsIndex.search(Session.get("searchValue")).fetch();
} else {
return undefined;
}
......
......@@ -5,7 +5,6 @@ import {Template } from 'meteor/templating';
import {Session } from 'meteor/session';
import {Cardsets } from '../../api/cardsets.js';
import {Categories } from '../../api/categories.js';
import {Ratings } from '../../api/ratings.js';
import './pool.html';
......@@ -50,7 +49,7 @@ Template.category.helpers({
return 0;
}
},
getSortUserIcon: function (val) {
getSortUserIcon: function () {
var sort = Session.get('poolSort');
if (sort.username === 1) {
return '<i class="fa fa-sort-asc"></i>';
......@@ -100,7 +99,7 @@ Template.category.helpers({
if (this.license.includes('nd')) {licenseString = licenseString.concat('<img src="/img/nd.large.png" alt="Keine Bearbeitung" />'); }
if (this.license.includes('sa')) {licenseString = licenseString.concat('<img src="/img/sa.large.png" alt="Weitergabe unter gleichen Bedingungen" />'); }
return new Spacebars.SafeString(licenseString)
return new Spacebars.SafeString(licenseString);
} else {
return new Spacebars.SafeString('<img src="/img/zero.large.png" alt="Kein Copyright" />');
}
......
......@@ -12,9 +12,6 @@ import {Learned } from '../../api/learned.js';
import {Ratings } from '../../api/ratings.js';
import {Paid } from '../../api/paid.js';
import {Notifications } from '../../api/notifications.js';
import {userData } from '../../api/userdata.js';
import './profile.html';
......@@ -24,6 +21,162 @@ Meteor.subscribe("notifications");
Meteor.subscribe("userData");
Meteor.subscribe("cardsets");
function getLvl() {
var user = Meteor.users.findOne(Router.current().params._id);
if (user === undefined) {
return null;
}
return user.lvl;
}
function xpForLevel(level) {
var points = 0;
for (var i = 1; i < level; i++) {
points += Math.floor(i + 30 * Math.pow(2, i / 10));
}
return Math.floor(points / 4);
}
function kritiker(rank) {
var ratings = Ratings.find({
user: Meteor.userId()
}).count();
var badge = Badges.findOne("1");
switch (rank) {
case 3:
return ratings / badge.rank3 * 100;
case 2:
return ratings / badge.rank2 * 100;
case 1:
return ratings / badge.rank1 * 100;
default:
return 0;
}
}
function krone(rank) {
var cardsets = Cardsets.find({
owner: Meteor.userId()
});
var count = 0;
cardsets.forEach(function (cardset) {
var ratings = Ratings.find({
cardset_id: cardset._id
});
if (ratings.count() > 1) {
var total = 0;
ratings.forEach(function (rating) {
total += rating.rating;
});
if (total / ratings.count() >= 4.5) {
count++;
}
}
});
var badge = Badges.findOne("2");
switch (rank) {
case 3:
return count / badge.rank3 * 100;
case 2:
return count / badge.rank2 * 100;
case 1:
return count / badge.rank1 * 100;
default:
return 0;
}
}
function stammgast(rank) {
var user = Meteor.users.findOne(Meteor.userId()).daysInRow;
var badge = Badges.findOne("3");
switch (rank) {
case 3:
return user / badge.rank3 * 100;
case 2:
return user / badge.rank2 * 100;
case 1:
return user / badge.rank1 * 100;
default:
return 0;
}
}
function streber(rank) {
var learned = Learned.find({
user_id: Meteor.userId()
}).count();
var badge = Badges.findOne("4");
switch (rank) {
case 3:
return learned / badge.rank3 * 100;
case 2:
return learned / badge.rank2 * 100;
case 1:
return learned / badge.rank1 * 100;
default:
return 0;
}
}
function wohltaeter(rank) {
var cardsets = Cardsets.find({
owner: Meteor.userId(),
visible: true
});
var count = 0;
cardsets.forEach(function (cardset) {
var cards = Cards.find({
cardset_id: cardset._id
});
if (cards.count() >= 5) {
count++;
}
});
var badge = Badges.findOne("5");
switch (rank) {
case 3:
return count / badge.rank3 * 100;
case 2:
return count / badge.rank2 * 100;
case 1:
return count / badge.rank1 * 100;
default:
return 0;
}
}
function bestseller(rank) {
var cardsetsIds = Cardsets.find({
owner: Meteor.userId()
}).map(function (cardset) {return cardset._id; });
var learner = Learned.find({
cardset_id: {$in: cardsetsIds}
}).count();
var badge = Badges.findOne("6");
switch (rank) {
case 3:
return learner / badge.rank3 * 100;
case 2:
return learner / badge.rank2 * 100;
case 1:
return learner / badge.rank1 * 100;
default:
return 0;
}
}
Template.registerHelper("getUser", function () {
var user = Meteor.users.findOne(Router.current().params._id);
Session.set("user", user);
......@@ -80,10 +233,10 @@ Template.profileSidebar.helpers({
*/
Template.profileSettings.events({
"click #profilepublicoption1": function (event) {
"click #profilepublicoption1": function () {
Meteor.call("updateUsersVisibility", true);
},
"click #profilepublicoption2": function (event) {
"click #profilepublicoption2": function () {
Meteor.call("updateUsersVisibility", false);
},
"click #profileSave": function () {
......@@ -156,7 +309,7 @@ Template.profileMembership.rendered = function () {
if ($('#subscribe-form').length) {
Meteor.call('getClientToken', customerId, function (error, clientToken) {
if (error) {
throw new Meteor.Error(err.statusCode, 'Error getting client token from braintree');
throw new Meteor.Error(error.statusCode, 'Error getting client token from braintree');
} else {
braintree.setup(clientToken, "dropin", {
container: "subscribe-form",
......@@ -179,7 +332,7 @@ Template.profileMembership.rendered = function () {
}
});
}
}
};
Template.profileMembership.events({
"click #upgrade": function () {
......@@ -241,7 +394,7 @@ Template.profileBilling.onRendered(function () {
if ($('#paymentMethodDropIn').length) {
Meteor.call('getClientToken', customerId, function (error, clientToken) {
if (error) {
throw new Meteor.Error(err.statusCode, 'Error getting client token from braintree');
throw new Meteor.Error(error.statusCode, 'Error getting client token from braintree');
} else {
braintree.setup(clientToken, "dropin", {
container: "paymentMethodDropIn",
......@@ -487,8 +640,7 @@ Template.profileXp.helpers({
}
}
if (last === undefined)
return null;
if (last === undefined) {return null;}
return name + " (+" + last.value + ")";
},
......@@ -520,23 +672,6 @@ Template.profileXp.helpers({
}
});
function getLvl() {
var user = Meteor.users.findOne(Router.current().params._id);
if (user === undefined) {
return null;
}
return user.lvl;
}
function xpForLevel(level) {
var points = 0;
for (var i = 1; i < level; i++) {
points += Math.floor(i + 30 * Math.pow(2, i / 10));
}
return Math.floor(points / 4);
}
/**
* ############################################################################
* profileBadges
......@@ -584,142 +719,3 @@ Template.profileBadges.helpers({
}
}
});
function kritiker(rank) {
var ratings = Ratings.find({
user: Meteor.userId()
}).count();
var badge = Badges.findOne("1");
switch (rank) {
case 3:
return ratings / badge.rank3 * 100;
case 2:
return ratings / badge.rank2 * 100;
case 1:
return ratings / badge.rank1 * 100;
default:
return 0;
}
}
function krone(rank) {
var cardsets = Cardsets.find({
owner: Meteor.userId()
});
var count = 0;
cardsets.forEach(function (cardset) {
var ratings = Ratings.find({
cardset_id: cardset._id
});
if (ratings.count() > 1) {
var total = 0;
ratings.forEach(function (rating) {
total += rating.rating;
});
if (total / ratings.count() >= 4.5) {
count++;
}
}
});
var badge = Badges.findOne("2");
switch (rank) {
case 3:
return count / badge.rank3 * 100;
case 2:
return count / badge.rank2 * 100;
case 1:
return count / badge.rank1 * 100;
default:
return 0;
}
}
function stammgast(rank) {
var user = Meteor.users.findOne(Meteor.userId()).daysInRow;
var badge = Badges.findOne("3");
switch (rank) {
case 3:
return user / badge.rank3 * 100;
case 2:
return user / badge.rank2 * 100;
case 1:
return user / badge.rank1 * 100;
default:
return 0;
}
}
function streber(rank) {
var learned = Learned.find({
user_id: Meteor.userId()
}).count();
var badge = Badges.findOne("4");
switch (rank) {
case 3:
return learned / badge.rank3 * 100;
case 2:
return learned / badge.rank2 * 100;
case 1:
return learned / badge.rank1 * 100;
default:
return 0;
}
}
function wohltaeter(rank) {
var cardsets = Cardsets.find({
owner: Meteor.userId(),
visible: true
});
var count = 0;
cardsets.forEach(function (cardset) {
var cards = Cards.find({
cardset_id: cardset._id
});
if (cards.count() >= 5) {
count++;
}
});
var badge = Badges.findOne("5");
switch (rank) {
case 3:
return count / badge.rank3 * 100;
case 2:
return count / badge.rank2 * 100;
case 1:
return count / badge.rank1 * 100;
default:
return 0;
}
}
function bestseller(rank) {
var cardsetsIds = Cardsets.find({
owner: Meteor.userId()
}).map(function (cardset) {return cardset._id; });
var learner = Learned.find({
cardset_id: {$in: cardsetsIds}
}).count();
var badge = Badges.findOne("6");
switch (rank) {
case 3:
return learner / badge.rank3 * 100;
case 2:
return learner / badge.rank2 * 100;
case 1:
return learner / badge.rank1 * 100;
default:
return 0;
}
}
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