Resolve code quality issues

parent 9ded229c
......@@ -17,24 +17,24 @@
"MathJax": false,
"buzz": false,
"Router": false,
"TAPi18n": false,
"Bert": false,
"Spacebars": false,
"Roles": false,
"Meteor": false,
"Template": false,
"TAPi18n": false,
"Bert": false,
"Spacebars": false,
"Roles": false,
"Meteor": false,
"Template": false,
"ReactiveCountdown": false,
"App": false,
"Papa": true,
"Papa": true,
"console": false,
"closeSplashscreen": true,
"showSplashscreen": true,
"closeAndRedirectTo": true,
"Braintree": true,
"confirm": true,
"email": true,
"jQuery": true,
"braintree": true,
"confirm": true,
"email": true,
"jQuery": true,
"braintree": true,
"BrainTreeConnect": true,
"Npm": true,
"EasySearch": true,
......
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="icon" sizes="192x192" href="/img/icon192.png">
<link rel="apple-touch-icon" href="/img/icon192.png">
<title>THMcards</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<link rel="icon" sizes="192x192" href="/img/icon192.png">
<link rel="apple-touch-icon" href="/img/icon192.png">
<title>THMcards</title>
<script src="https://js.braintreegateway.com/v2/braintree.js"></script>
<script src="https://js.braintreegateway.com/v2/braintree.js"></script>
<script>
window.cookieconsent_options = {
"message":"THMcards is a web app that uses cookies to ensure you get the best experience.",
"dismiss":"Got it!",
"learnMore":" More about data privacy",
"link": "/datenschutz",
"theme":"light-top"
};
</script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/1.0.9/cookieconsent.min.js"></script>
<script>
window.cookieconsent_options = {
"message": "THMcards is a web app that uses cookies to ensure you get the best experience.",
"dismiss": "Got it!",
"learnMore": " More about data privacy",
"link": "/datenschutz",
"theme": "light-top"
};
</script>
<script type="text/javascript"
src="//cdnjs.cloudflare.com/ajax/libs/cookieconsent2/1.0.9/cookieconsent.min.js"></script>
</head>
This diff is collapsed.
This diff is collapsed.
import {Meteor } from 'meteor/meteor';
import {Cardsets } from './cardsets.js';
import {Meteor} from 'meteor/meteor';
import {Cardsets} from './cardsets.js';
if (Meteor.isServer) {
Meteor.publish("allUsers", function () {
......
import {Meteor } from 'meteor/meteor';
import {Meteor} from 'meteor/meteor';
export const Badges = new TAPi18n.Collection("badges");
......
import {Meteor} from 'meteor/meteor';
import {Cardsets } from './cardsets.js';
import {Cardsets} from './cardsets.js';
var Future = Npm.require('fibers/future');
......@@ -38,7 +38,7 @@ Meteor.methods({
btGetPaymentMethod: function () {
var btPayment = new Future();
var user = Meteor.users.findOne(this.userId);
var user = Meteor.users.findOne(this.userId);
Meteor.call('btFindCustomer', user.customerId, function (error, customer) {
if (error) {
btPayment.return(error);
......@@ -81,7 +81,7 @@ Meteor.methods({
},
btCreateTransaction: function (nonceFromTheClient, cardset_id) {
var cardset = Cardsets.findOne(cardset_id);
var cardset = Cardsets.findOne(cardset_id);
var btCreateTransaction = new Future();
// Create our customer.
Meteor.call('btCreateCustomer', nonceFromTheClient, function (error, btCustomer) {
......@@ -117,7 +117,7 @@ Meteor.methods({
},
btCreateCredit: function (nonceFromTheClient) {
var user = Meteor.users.findOne(this.userId);
var user = Meteor.users.findOne(this.userId);
var btCreateCredit = new Future();
// Create our customer.
Meteor.call('btCreateCustomer', nonceFromTheClient, function (error, btCustomer) {
......@@ -223,7 +223,7 @@ Meteor.methods({
email: user.email,
paymentMethodNonce: nonce
};
var btCustomer = new Future();
var btCustomer = new Future();
// Calling the Braintree API to create our customer!
gateway.customer.create(customerData, function (error, result) {
if (error) {
......@@ -295,7 +295,7 @@ Meteor.methods({
} else {
// get customer's last subscription
var subscriptionId = result.paymentMethods[0].subscriptions;
var last = subscriptionId.slice(-1)[0];
var last = subscriptionId.slice(-1)[0];
btUserSubscription.return(last);
}
......@@ -307,7 +307,7 @@ Meteor.methods({
btCancelSubscription: function () {
var btCancelSubscription = new Future();
var user = Meteor.userId();
var user = Meteor.userId();
var getUser = Meteor.users.findOne({
"_id": user
}, {
......
......@@ -135,7 +135,7 @@ Meteor.methods({
Meteor.call('checkLvl');
},
deleteCard: function (card_id) {
var card = Cards.findOne(card_id);
var card = Cards.findOne(card_id);
var cardset = Cardsets.findOne(card.cardset_id);
if (!Meteor.userId() || cardset.owner !== Meteor.userId() || Roles.userIsInRole(this.userId, 'blocked')) {
......@@ -188,7 +188,7 @@ Meteor.methods({
}
},
updateCard: function (card_id, front, back) {
var card = Cards.findOne(card_id);
var card = Cards.findOne(card_id);
var cardset = Cardsets.findOne(card.cardset_id);
if (!Roles.userIsInRole(this.userId, [
......
......@@ -112,7 +112,7 @@ CardsetsIndex = new EasySearch.Index({
// Filter selector
const selector = {};
selector.$and = [
selector.$and = [
defSelector,
{
$or: [
......@@ -208,14 +208,14 @@ Meteor.methods({
var relevance = 0;
var ratings = Ratings.find({cardset_id: cardset_id});
var count = ratings.count();
var count = ratings.count();
if (count !== 0) {
var amount = 0;
ratings.forEach(function (rate) {
amount = amount + rate.rating;
});
var result = (amount / count).toFixed(2);
relevance = Number(result);
relevance = Number(result);
}
var kind = Cardsets.findOne(cardset_id).kind;
......
......@@ -24,10 +24,10 @@ if (Meteor.isServer) {
Meteor.methods({
checkLvl: function () {
var pts = 0;
var pts = 0;
var points = 0;
var output = 0;
var lvl = 1;
var lvl = 1;
var allXp = Experience.find({
owner: Meteor.userId()
......
import {Meteor} from 'meteor/meteor';
import {Mongo} from 'meteor/mongo';
import {Cardsets } from './cardsets.js';
import {Cardsets} from './cardsets.js';
export const Learned = new Mongo.Collection("learned");
......@@ -74,11 +74,11 @@ Meteor.methods({
// (3) Set interval to 0, lower the EF, reps + 1 (repeat card today)
// (4-5) Reps + 1, interval is calculated using EF, increasing in time.
var learned = Learned.findOne(learned_id), ef = learned.ef, reps = learned.reps, nextDate = new Date();
var learned = Learned.findOne(learned_id), ef = learned.ef, reps = learned.reps, nextDate = new Date();
var interval = 0;
if (grade < 3) {
reps = 0;
reps = 0;
interval = 0;
} else {
ef = ef + (0.1 - (5 - grade) * (0.08 + (5 - grade) * 0.02));
......
......@@ -26,11 +26,11 @@ Meteor.methods({
try {
// If the string is UTF-8, this will work and not throw an error.
front = decodeURIComponent(encodeURIComponent(item.front));
back = decodeURIComponent(encodeURIComponent(item.back));
back = decodeURIComponent(encodeURIComponent(item.back));
} catch (e) {
// If it isn't, an error will be thrown, and we can assume that we have an ISO string.
front = item.front;
back = item.back;
back = item.back;
}
if (item.front !== "") {
......
......@@ -84,7 +84,7 @@ Meteor.methods({
});
},
checkUsersName: function (name, id) {
name = name.trim();
name = name.trim();
var userExists = Meteor.users.findOne({"profile.name": name});
if (userExists && userExists._id !== id) {
......@@ -146,7 +146,7 @@ Meteor.methods({
},
increaseUsersBalance: function (user_id, lecturer_id, amount) {
if (amount < 10) {
var user_amount = Math.round((amount * 0.7) * 100) / 100;
var user_amount = Math.round((amount * 0.7) * 100) / 100;
var lecturer_amount = Math.round((amount * 0.05) * 100) / 100;
Meteor.users.update(user_id, {$inc: {balance: user_amount}});
......
......@@ -3,7 +3,7 @@ import {Session} from 'meteor/session';
//------------------------ GET LANGUAGE FROM USER
getUserLanguage = function () {
return navigator.language.substr(0,2);
return navigator.language.substr(0, 2);
};
......
......@@ -7,7 +7,7 @@ import {Cards} from '../../api/cards.js';
Template.registerHelper("hasPermission", function () {
if (Roles.userIsInRole(Meteor.userId(), 'lecturer')) {
return this.owner === Meteor.userId() || this.visible === true || this.request === true;
} else {
} else {
return this.owner === Meteor.userId() || this.visible === true;
}
});
......@@ -69,8 +69,7 @@ Template.registerHelper("getCategories", function () {
// Return the name of a Category
Template.registerHelper("getCategory", function (value) {
if (value !== null)
{
if (value !== null) {
var id = value.toString();
if (id.length === 1) {
id = "0" + id;
......
......@@ -208,7 +208,7 @@ var initBadges = function () {
Meteor.startup(function () {
var categories = initCategories();
var badges = initBadges();
var badges = initBadges();
if (Categories.find().count() === 0) {
for (var category in categories) {
if (categories.hasOwnProperty(category)) {
......
This diff is collapsed.
This diff is collapsed.
......@@ -3,7 +3,7 @@
import {Meteor} from 'meteor/meteor';
import {Template} from 'meteor/templating';
import {Notifications } from '../../api/notifications.js';
import {Notifications} from '../../api/notifications.js';
import './admin.html';
......
......@@ -17,20 +17,20 @@ body {
line-height: 45px;
float: left;
a {
display: block;
text-decoration: none;
padding-left: 15px;
padding-right: 15px;
color: #999999;
&:hover, &.active {
display: block;
text-decoration: none;
padding-left: 15px;
padding-right: 15px;
color: #999999;
&:hover, &.active {
text-decoration: none;
color: #fff;
background: rgba(255,255,255,0.2);
}
i {
background: rgba(255, 255, 255, 0.2);
}
i {
display: inline;
padding-right: 5px;
}
}
}
}
}
......@@ -68,56 +68,56 @@ body {
border-top: 4px solid white;
border-bottom: 4px solid white;
.clearfix {
border-bottom: 1px solid #ddd;
.reactive-table-options {
border-bottom: 1px solid #ddd;
.reactive-table-options {
float: left !important;
.reactive-table-filter {
float: left !important;
margin-bottom: 20px;
float: left !important;
margin-bottom: 20px;
}
}
}
}
table {
border-bottom: 1px solid #ddd;
.getpointer {
border-bottom: 1px solid #ddd;
.getpointer {
cursor: pointer;
}
}
}
.reactive-table-navigation {
.page-number {
.page-number {
margin-right: 20px;
}
}
}
}
.dashboard-box {
a:hover {
text-decoration: none;
text-decoration: none;
}
.small-box {
border-radius: 3px;
border: 1px solid #ddd;
position: relative;
display: block;
margin-bottom: 20px;
background-color: white;
.inner {
border-radius: 3px;
border: 1px solid #ddd;
position: relative;
display: block;
margin-bottom: 20px;
background-color: white;
.inner {
padding: 10px;
h3 {
font-size: 38px;
font-weight: bold;
margin: 0 0 10px 0;
white-space: nowrap;
padding: 0;
span {
font-size: 38px;
font-weight: bold;
margin: 0 0 10px 0;
white-space: nowrap;
padding: 0;
span {
font-size: 18px;
font-weight: normal;
}
}
}
p {
font-size: 15px;
font-size: 15px;
}
}
.small-box-footer {
}
.small-box-footer {
position: relative;
text-align: center;
padding: 3px 0;
......@@ -125,7 +125,7 @@ body {
z-index: 10px;
background-color: #f5f5f5;
text-decoration: none;
}
}
}
}
}
......@@ -137,21 +137,21 @@ body {
.box-body-admin {
padding: 10px;
.box-button-admin {
border-top: 1px solid #ddd;
padding-top: 20px;
border-top: 1px solid #ddd;
padding-top: 20px;
}
.reactive-table-filter {
padding-top: 10px;
padding-top: 10px;
}
#cc-modules-admin img {
width: 30px;
width: 30px;
}
}
}
.reactive-table-navigation {
.page-number {
label:last-child {
margin-right: 21px;
margin-right: 21px;
}
}
}
......@@ -159,7 +159,7 @@ body {
}
}
@media(min-width:768px) {
@media(min-width: 768px) {
body {
#wrapper {
#admin-sidebar-wrapper {
......@@ -170,15 +170,15 @@ body {
.sidebar-nav {
float: none;
li {
float: none;
text-indent: 20px;
a {
float: none;
text-indent: 20px;
a {
padding: 0;
border-left: 3px solid transparent;
&:hover, &.active {
border-left-color: #3d9c19;
border-left-color: #3d9c19;
}
}
}
}
}
}
......
<template name="admin_card">
<div class="content-header">
<h1>
{{_ "admin.card.header"}}
<small>{{_ "admin.card.edit"}} {{_id}}</small>
</h1>
</div>
<div class="content box-admin">
<div class="box-body-admin">
<form id="admin_card_update">
<div class="panel panel-default">
<div class="panel-heading">{{_ "admin.card.info"}}</div>
<div class="panel-body">
<div class="form-group">
<label id="editCardUserLabelAdmin">{{_ "admin.card.username"}}</label>
{{#if userExistsCard cardset_id}}
<a href="/admin/user/{{getUserId cardset_id}}">{{getUsernameCard cardset_id}}</a>
{{else}}
{{getUsernameCard cardset_id}} ({{_ "admin.deleted"}})
{{/if}}
</div>
<div class="form-group">
<label id="editCardCardsetnameLabelAdmin">{{_ "admin.card.cardsetname"}}</label>
<a href="/admin/cardset/{{cardset_id}}">{{getCardsetname cardset_id}}</a>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">{{_ "admin.card.settings"}}</div>
<div class="panel-body">
<div id="frontAdmin" class="cardtext col-lg-6 col-xs-12">
<div class="form-group">
<label id="editCardFrontLabelAdmin">{{_ "admin.card.front"}}</label>
<textarea id="editCardFrontAdmin" class="form-control" type="text" name="content" data-provide="markdown" rows="10">{{front}}</textarea>
{{getFront front}}
<span id="helpEditCardFrontAdmin" class="help-block front"></span>
</div>
</div>
<div id="backAdmin" class="cardtext col-lg-6 col-xs-12">
<div class="form-group">
<label id="editCardBackLabelAdmin">{{_ "admin.card.back"}}</label>
<textarea id="editCardBackAdmin" class="form-control" type="text" name="content" data-provide="markdown" rows="10">{{back}}</textarea>
{{getBack back}}
<span id="helpEditCardBackAdmin" class="help-block back"></span>
</div>
</div>
</div>
</div>
</form>
<div class="box-button-admin">
<button id="cardCancelAdmin" class="btn btn-default">{{_ "admin.card.cancel"}}</button>
<button id="cardSaveAdmin" class="btn btn-primary">{{_ "admin.card.save"}}</button>
<button id="cardDeleteAdmin" class="btn btn-danger btn-setDelete pull-right" style="width:150px">{{_ "admin.card.delete"}}</button>
<button id="cardConfirmAdmin" class="btn btn-warning pull-right" style="width:150px; display:none">{{_ "admin.card.confirm"}}</button>
</div>
</div>
</div>
<div class="content-header">
<h1>
{{_ "admin.card.header"}}
<small>{{_ "admin.card.edit"}} {{_id}}</small>
</h1>
</div>
<div class="content box-admin">
<div class="box-body-admin">
<form id="admin_card_update">
<div class="panel panel-default">
<div class="panel-heading">{{_ "admin.card.info"}}</div>
<div class="panel-body">
<div class="form-group">
<label id="editCardUserLabelAdmin">{{_ "admin.card.username"}}</label>
{{#if userExistsCard cardset_id}}
<a href="/admin/user/{{getUserId cardset_id}}">{{getUsernameCard cardset_id}}</a>
{{else}}
{{getUsernameCard cardset_id}} ({{_ "admin.deleted"}})
{{/if}}
</div>
<div class="form-group">
<label id="editCardCardsetnameLabelAdmin">{{_ "admin.card.cardsetname"}}</label>
<a href="/admin/cardset/{{cardset_id}}">{{getCardsetname cardset_id}}</a>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">{{_ "admin.card.settings"}}</div>
<div class="panel-body">
<div id="frontAdmin" class="cardtext col-lg-6 col-xs-12">
<div class="form-group">
<label id="editCardFrontLabelAdmin">{{_ "admin.card.front"}}</label>
<textarea id="editCardFrontAdmin" class="form-control" type="text" name="content"
data-provide="markdown" rows="10">{{front}}</textarea>
{{getFront front}}
<span id="helpEditCardFrontAdmin" class="help-block front"></span>
</div>
</div>
<div id="backAdmin" class="cardtext col-lg-6 col-xs-12">
<div class="form-group">
<label id="editCardBackLabelAdmin">{{_ "admin.card.back"}}</label>
<textarea id="editCardBackAdmin" class="form-control" type="text" name="content"
data-provide="markdown" rows="10">{{back}}</textarea>
{{getBack back}}
<span id="helpEditCardBackAdmin" class="help-block back"></span>
</div>
</div>
</div>
</div>
</form>
<div class="box-button-admin">
<button id="cardCancelAdmin" class="btn btn-default">{{_ "admin.card.cancel"}}</button>
<button id="cardSaveAdmin" class="btn btn-primary">{{_ "admin.card.save"}}</button>
<button id="cardDeleteAdmin" class="btn btn-danger btn-setDelete pull-right" style="width:150px">{{_
"admin.card.delete"}}</button>
<button id="cardConfirmAdmin" class="btn btn-warning pull-right" style="width:150px; display:none">{{_
"admin.card.confirm"}}</button>
</div>
</div>
</div>
</template>
//------------------------ IMPORTS
import {Meteor } from 'meteor/meteor';
import {Template } from 'meteor/templating';
import {Session } from 'meteor/session';
import {Meteor} from 'meteor/meteor';
import {Template} from 'meteor/templating';
import {Session} from 'meteor/session';
import {Cardsets } from '../../../api/cardsets.js';
import {Cardsets} from '../../../api/cardsets.js';
import './admin_card.html';
/**
* ############################################################################
* Functions
* ############################################################################
*/
* ############################################################################
* Functions
* ############################################################################
*/
function tex(e) {
// Give/remove ** surround the selection
var chunk, cursor, selected = e.getSelection(),
content = e.getContent();
content = e.getContent();
if (selected.length === 0) {
// Give extra word
......@@ -43,7 +43,7 @@ function tex(e) {
function image(e) {
// Give ![] surround the selection and prepend the image link
var chunk, cursor, selected = e.getSelection(),
link;
link;
if (selected.length === 0) {
// Give extra word
......@@ -67,10 +67,10 @@ function image(e) {
}
/**
* ############################################################################
* admin_card
* ############################################################################
*/
* ############################################################################
* admin_card
* ############################################################################
*/
Template.admin_card.helpers({
getUsernameCard: function (cardset_id) {
......@@ -109,12 +109,12 @@ Template.admin_card.helpers({
Session.set('frontText', front);
if (front !== "") {
Meteor.promise("convertMarkdown", front)
.then(function (rendered) {
$("#frontAdmin .md-footer").html(rendered);
})
.catch(function (error) {
throw new Meteor.Error(error, "Can't convert to Markdown");
});
.then(function (rendered) {
$("#frontAdmin .md-footer").html(rendered);
})
.catch(function (error) {
throw new Meteor.Error(error, "Can't convert to Markdown");
});
}
} else {
return null;
......@@ -125,12 +125,12 @@ Template.admin_card.helpers({
Session.set('backText', back);
if (back !== "") {
Meteor.promise("convertMarkdown", back)
.then(function (rendered) {
$("#backAdmin .md-footer").html(rendered);
})
.catch(function (error) {
throw new Meteor.Error(error, "Can't convert to Markdown");
});
.then(function (rendered) {
$("#backAdmin .md-footer").html(rendered);
})
.catch(function (error) {
throw new Meteor.Error(error, "Can't convert to Markdown");
});