Skip to content
Snippets Groups Projects
Commit 45f4c5f0 authored by Julian Dehne's avatar Julian Dehne
Browse files

- created refactoring branch

- started working on group finding prototyp (basic group management prototyp for development - not advanced groupfinding i.e. mirjams project)
parent eed4122c
No related branches found
No related tags found
No related merge requests found
Showing
with 898 additions and 40 deletions
<%--
Created by IntelliJ IDEA.
User: dehne
Date: 12.09.2018
Time: 12:06
To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>dozent-view-alternativ slider</title>
<link rel="stylesheet" href="../../assets/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Ubuntu:400,700">
<link rel="stylesheet" href="../../assets/css/Login-Form-Clean.css">
<link rel="stylesheet" href="../../assets/css/Navigation-with-Button1.css">
<link rel="stylesheet" href="../../assets/css/Sidebar-Menu.css">
<link rel="stylesheet" href="../../assets/css/Sidebar-Menu1.css">
<link rel="stylesheet" href="../../assets/css/styles.css">
<link rel="stylesheet" type="text/css" href="../../assets/jQuery-Tags-Input-master/src/jquery.tagsinput.css"/>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript" src="../../assets/jQuery-Tags-Input-master/src/jquery.tagsinput.js"></script>
<script src="../assets/js/config.js"></script>
<script src="../assets/js/newProject.js"></script>
<script src="../../assets/js/utility.js"></script>
<script src="../../assets/bootstrap/js/bootstrap.min.js"></script>
<script src="../../assets/js/Sidebar-Menu.js"></script>
</head>
<body>
<p id="user" hidden><?php echo $userName; ?></p>
<div class="loader-inactive" id="loader">
<div class="sk-cube1 sk-cube"></div>
<div class="sk-cube2 sk-cube"></div>
<div class="sk-cube4 sk-cube"></div>
<div class="sk-cube3 sk-cube"></div>
</div>
<div id="wrapper" style="margin:0px;">
<?php
include_once 'menu.php'
?>
<div class="page-content-wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-md-12">
<div>
<p></p>
<h3> Erstellen Sie ein neues Projekt.</h3>
</div>
</div>
</div>
</div>
</div>
<div class="contact-clean">
<p>Name des Projekts</p>
<div class="alert alert-danger" role="alert" style="width:475px" id="projectNameExists">
Dieser Projektname exisitiert bereits.
</div>
<div class="alert alert-danger" role="alert" style="width:475px" id="exactNumberOfTags">
Es müssen genau 5 Tags eingegeben werden.
</div>
<div class="alert alert-danger" role="alert" style="width:475px" id="specialChars">
Der Projektname darf keine Sonderzeichen enthalten.
</div>
<div class="alert alert-danger" role="alert" style="width:475px" id="projectIsMissing">
Tragen sie einen Projektnamen ein.
</div>
<div class="form-group"><input class="form-control" name="name" placeholder="Name"
style="width:286px;margin-left:50px;" id="nameProject"></div>
<p> Passwort zum Teilnehmen (optional) </p>
<div class="form-group"><input class="form-control" name="password" placeholder="Passwort"
style="width:287px;margin-left:51px;" id="passwordProject"></div>
<p> Passwort zum Löschen (sonst: 1234) </p>
<div class="form-group"><input class="form-control" name="adminpassword" placeholder="Passwort"
style="width:287px;margin-left:51px;" id="adminPassword"></div>
<p>Tags </p>
<div id="tagHelper" class="alert alert-warning" style="width:475px;">
Fügen sie zudem 5 Tags zu ihrem Projekt hinzu, welche ihr Projekt inhaltlich umreißen.
</div>
<div class="form-group"><input class="tags" data-role="tags" name="Tags" placeholder="Tags"
id="tagsProject">
</div>
<label>An Kurs selbst teilnehmen <input type="checkbox" id="Teilnehmer"></label>
<div class="form-group">
<button class="btn btn-primary" style="margin-left:129px;" id="sendProject">erstellen</button>
</div>
</div>
</div>
</body>
</html>
.tagLabel {
color: #000 !important;
text-shadow: none !important;
-webkit-box-shadow: none !important;
box-shadow: none !important;
display: inline !important;;
padding: .2em .6em .3em !important;
margin: 3px !important;
font-size: 75% !important;;
font-weight: 700 !important;;
line-height: 1 !important;;
color: #fff !important;;
text-align: center !important;;
white-space: nowrap !important;;
vertical-align: baseline !important;;
border-radius: .25em !important;;
background-color: #5cb85c !important;
}
.label {
border: 1px solid #000;
}
$("#menu-toggle").click(function(e) {
e.preventDefault();
$("#wrapper").toggleClass("toggled");
});
\ No newline at end of file
//var compbaseUrl = "https://esb.uni-potsdam.de:8243/services/competenceBase";
//var compbaseUrl = "http://fleckenroller.cs.uni-potsdam.de/app/competence-database-prod";
var compbaseUrl = "https://apiup.uni-potsdam.de/endpoints/competenceAPI";
/**
* Created by fides-WHK on 15.03.2018.
*/
$(document).ready(function () {
var projectName = getProjectByToken();
getTags(projectName);
$("#competencies0").focus();
$("#studentFormSubmit").on("click", function () {
takesPartInProject();
});
$("#addCompetenceButton").on("click", function () {
addInput("competencies"); //creates a new input-Field with the ID 'competenciesX' where X is number of elements with 'competencies' as ID
});
$("#subtractCompetenceButton").on("click", function () {
deletInput("competencies"); //deletes latest input-Field with the ID 'competenciesX' where X is number of elements with 'competencies' as ID
});
$("#addResearchQuestionButton").on("click", function () {
addInput("researchQuestion"); //creates a new input-Field with the ID 'researchQuestionX' where X is number of elements with 'researchQuestion' as ID
});
$("#subtractCResearchQuestionButton").on("click", function () {
deletInput("researchQuestion"); //deletes the latest input-Field with ID 'researchQuestionX' where X is number of elements with 'researchQuestion' as ID
});
});
function getProjectByToken(){
return $('#projectName').text().trim();
}
function addInput(name) { //creates a new input-Field with the ID 'nameX' where X is number of elements with 'name' as ID
var i = document.getElementsByName(name).length;
var newInput = document.createElement("span");
newInput.innerHTML = "<input class='form-control' " +
"type='text' " +
"name='" + name + "' " +
"id='" + name + i + "' " +
"style='max-width:417px;margin-left:14px;padding-top:10px;margin-top:2px;margin-bottom:13px;'>";
var div = document.getElementById(name);
div.appendChild(newInput);
}
function deletInput(name) { //deletes latest input-Field with the ID 'nameX' where X is number of elements with 'name' as ID
var i = document.getElementsByName(name).length;
if (i > 1) {
var lastEntry = document.getElementById(name + "" + (i - 1));
lastEntry.parentNode.removeChild(lastEntry);
}
}
function getTags(projectName) {
var url = "../database/getTags.php?project=" + projectName;
$.ajax({
url: url,
Accept: "text/plain; charset=utf-8",
contentType: "text/plain",
success: function (response) {
response = JSON.parse(response);
var tagList = [];
var i = 0;
for (i = 0; i < response.length; i++)
tagList.push(response[i].tag);
for (i = 0; i < tagList.length; i++) {
var newInput = document.createElement("label");
newInput.innerHTML =
"<div class='checkbox checkbox-primary' >"
+ "<input id='tag" + i + "' " + " class='styled' " + "name='tag'" + "type='checkbox' " + ">"
+ "<label for='tag" + i + "' "+ ">" + tagList[i] + "</label>"
+ "</div>";
var div = document.getElementById('tags');
div.appendChild(newInput);
}
},
error: function (a, b, c) {
console.log(a);
}
});
}
function takesPartInProject() {
var userID = $("#user").text().trim();
var projectID = $("#projectName").text().trim();
document.getElementById('loader').className = "loader";
document.getElementById('wrapper').className = "wrapper-inactive";
var allTheTags = [];
var allTheCompetencies = [];
var allTheResearchQuestions = [];
for (i = 0; i < document.getElementsByName("competencies").length; i++) { //goes through all competencies and adds them to allTheCompetencies
allTheCompetencies.push(document.getElementsByName("competencies")[i].value);
}
for (i = 0; i < document.getElementsByName("researchQuestions").length; i++) { //goes through all competencies and adds them to allTheResearchQuestions
allTheResearchQuestions.push(document.getElementsByName("researchQuestions")[i].value);
}
for (i = 0; i < document.getElementsByName("tag").length; i++) { //goes through all tags and adds them to allTheTags
if (document.getElementById("tag" + i).checked) {
allTheTags.push(document.getElementById("tag" + i).value);
}
if ($("#tag"+i).prop("checked"))
allTheCompetencies.push("Die Studierenden interessieren sich für " + $("#tag" + i).val()); //todo: Die Tags werden hinter der Schnittstelle noch nicht verwertet, daher diese schnelle Lösung
}
if (allTheTags.length > 2) {
//alert('Sie haben zu viele Tags ausgewählt');
$(".alert").css('background-color', 'lightcoral');
allTheTags = [];
document.getElementById('loader').className = "loader-inactive";
document.getElementById('wrapper').className = "wrapper";
return false;
}
if (allTheTags.length < 2) {
//alert('Sie haben zu wenig Tags ausgewählt');
$(".alert").css('background-color', 'lightcoral');
allTheTags = [];
document.getElementById('loader').className = "loader-inactive";
document.getElementById('wrapper').className = "wrapper";
return false;
}
var data = { //JSON object 'data' collects everything to send
"competences": allTheCompetencies,
"researchQuestions": allTheResearchQuestions,
"tagsSelected": allTheTags
};
var dataString = JSON.stringify(data); //to send correctly, data needs to be stringified
var url = compbaseUrl + "/api2/user/" + userID + "/projects/" + projectID + "/preferences";
$.ajax({
url: url,
type: 'PUT',
Accept: "text/plain; charset=utf-8",
contentType: "application/json",
data: dataString,
success: function (response) {
console.log(response);
document.getElementById('loader').className = "loader-inactive";
document.getElementById('wrapper').className = "wrapper";
var parts = window.location.search.substr(1).split("&");
var $_GET = {};
for (var i = 0; i < parts.length; i++) {
var temp = parts[i].split("=");
$_GET[decodeURIComponent(temp[0])] = decodeURIComponent(temp[1]);
}
location.href = "projects.php?token=" + $_GET['token'];
},
error: function (a, b, c) {
console.log(a);
}
});
}
\ No newline at end of file
/**
* Created by dehne on 28.03.2018.
*/
$(document).ready(function () {
$("#projectWrongPassword").hide();
$("#projectIsMissing").hide();
$("#deleteProject").on('click', function () {
deleteProject($('#projectName').val().trim());
});
});
function deleteProject(projectName) {
var token = getUserTokenFromUrl();
var url = "../database/deleteProject.php?project=" + projectName + "&password=" + document.getElementById('projectPassword').value.trim() + "&token=" + token;
if (projectName === "") {
return false;
} else {
$.ajax({
url: url,
projectName: projectName,
Accept: "text/plain; charset=utf-8",
contentType: "text/plain",
success: function (response) {
if (response === "project missing") {
$("#projectIsMissing").show();
} else {
if (response !== "wrong password") { //if response !== project missing and not wrong password, its the projectToken
$.ajax({
url: compbaseUrl+"/api1/courses/"+projectName,
Accept: "text/plain; charset=utf-8",
type: 'DELETE',
contentType: "text/plain",
async: false,
success: function (response) {
},
error: function (a, b, c) {
console.log(a);
}
});
window.location.href = " ../pages/projects.php?token="+getUserTokenFromUrl();
} else {
$("#projectIsMissing").hide();
$('#projectWrongPassword').show();
}
}
},
error: function (a, b, c) {
console.log(a);
}
});
}
}
/**
* Created by dehne on 28.03.2018.
*/
function getProjectsOfAuthor(author, printedProjects, handleProjects) {
var url = "../database/getProjectsOfAuthor.php?author=" + author;
$.ajax({
url: url,
Accept: "text/plain; charset=utf-8",
contentType: "text/plain",
success: function (response) {
var authoredProjects = JSON.parse(response);
if (authoredProjects != null) {
if (printedProjects != null) {
for (var i = 0; i < printedProjects.length; i++) {
authoredProjects = authoredProjects.filter(function (el) {
return el !== printedProjects[i];
});
}
handleProjects(authoredProjects, printedProjects.length);
} else {
handleProjects(authoredProjects, 0);
}
}
},
error: function (a, b, c) {
console.log(a);
}
});
}
\ No newline at end of file
/**
* Created by fides-WHK on 22.01.2018.
*/
$(document).ready(function () {
//todo: Buttons im Eventhandler steuern und nicht auf der HTML-Seite.
getProjects(document.getElementById('user').innerHTML);
//getMembers($('#projectDropdown').innerHTML,$('#user').innerHTML);
});
function printProjectDropdown(projects, numberOfProjectsPrinted) {
var menu = document.getElementById("dropdownOptions"); //the unordered list of buttons called by the dropdown button
var limit = projects.length;
for (var i = 0; i < limit; i++) { //show every project a student takes
// part in
var option = document.createElement("SPAN"); //and create a span, containing a button with it
option.innerHTML = "<button class='dropdown-item' " + //which carries the event onClick, the name of the group and a design
"onClick=" +
'"showProject(' + "'" + projects[i] + "',document.getElementById('user').innerHTML);" + '"' + ">"
+ projects[i] +
"</button>";
menu.appendChild(option);
}
}
function getProjects(user) {
var url = compbaseUrl + "/api2/user/" + user + "/projects";
$.ajax({
url: url,
user: user,
type: 'GET',
contentType: "application/json",
dataType: "json",
success: function (data) {
if (data.length !== 0) {
var projects = [];
if (data.data != null) {
projects = data.data;
printProjectDropdown(projects, 0);
}
getProjectsOfAuthor(user, projects, printProjectDropdown)
} else {
document.getElementById("projectDropdown").innerHTML = "keine Projekte verfügbar"; //no projects of the students where found
}
}
});
}
function printGroupTable(student1, student2, student3, student4) {
var innerurl = "../database/getAdresses.php?student1=" + student1 + "&student2=" + student2 + "&student3=" + student3 + "&student4=" + student4;
/*if (student4) {
innerurl = innerurl + "&student4=" + student4;
}*/
$.ajax({ //get email adresses in this ajax.
student1: "" + student1,
student2: "" + student2,
student3: "" + student3,
student4: "" + student4,
url: innerurl,
type: 'GET',
contentType: "application/json",
dataType: "json",
success: function (innerData) {
var tableStart = '<table class="table table-striped table-bordered table-list"' +
' style="width: 40%;margin-top:' +
' 10px;"> <thead id="tableHead"> ' +
' <tr>' +
' <th class="hidden-xs">Student</th>' +
' <th>E-Mail</th>' +
' </tr>';
var tableFinish = '</thead>' + '</table>';
for (var k2 = 0; k2 < innerData.length; k2++) {
if (innerData[k2].name === student1) {
tableStart = tableStart + ("<tr><td>" + student1 + "</td><td><a" +
" href='mailto:" + innerData[k2].email + "'>" + innerData[k2].email + "</a></td></tr>");
} else if (innerData[k2].name === student2) {
tableStart = tableStart + ("<tr><td>" + student2 + "</td><td><a" +
" href='mailto:" + innerData[k2].email + "'>" + innerData[k2].email + "</a></td></tr>");
} else if (innerData[k2].name === student3) {
tableStart = tableStart + ("<tr><td>" + student3 + "</td><td><a" +
" href='mailto:" + innerData[k2].email + "'>" + innerData[k2].email + "</a></td></tr>");
} else if (innerData[k2].name === student4 && (student4 != null)) {
tableStart = tableStart + ("<tr><td>" + student4 + "</td><td><a" +
" href='mailto:" + innerData[k2].email + "'>" + innerData[k2].email + "</a></td></tr>");
}
}
var tableString = tableStart + tableFinish;
$("#tablesHolder").append(tableString);
}
});
return innerurl;
}
function getMembers(project, user) { //gets all Members in the chosen Project user is a part of with email adresses
$("#tablesHolder").empty();
var url = compbaseUrl + "/api2/groups/" + project; //this API is used, since fleckenroller has security issues
// with CORS
// and stuff
$.ajax({
url: url,
user: user,
type: 'GET',
contentType: "application/json",
dataType: "json", //{groups: [id, users:[]] }
success: function (data) {
for (var i = 0; i < data.groups.length; i++) {
var student1 = data.groups[i].users[0];
var student2 = data.groups[i].users[1];
var student3 = data.groups[i].users[2];
var student4 = data.groups[i].users[3];
printGroupTable(student1, student2, student3, student4);
}
},
error: function(data) {
$("#tablesHolder").append("<p>Es wurden keine Gruppen gefunden. Das Projekt muss mehr als 5 Teilnehmer haben!</p>")
}
});
}
function showProject(project, user) { //will display the chosen option in the dropdown button and show all students in a unordered list
$("#projectDropdown").text(project); //the dropdown button
getMembers(project, user); //the students
}
\ No newline at end of file
/**
* Created by fides-WHK on 19.02.2018.
*/
$(document).ready(function () {
var allTheTags = [];
$("#nameProject").focus();
$('#projectNameExists').hide();
$('#projectIsMissing').hide();
$('#exactNumberOfTags').hide();
$('#specialChars').hide();
$(function () {
$('#tagsProject').tagsInput({
width: '475px',
onAddTag: function (tag) {
allTheTags.push(tag);
},
onRemoveTag: function (tag) {
allTheTags.pop(); //todo: löscht noch nicht den gewählten tag sondern den letzten
}
});
});
$('#sendProject').on('click', function () {
var activ = "1";
createNewProject(allTheTags, activ);
});
});
function createNewProject(allTheTags, activ) {
$("#nameProject").focus();
$('#projectNameExists').hide();
$('#projectIsMissing').hide();
$('#exactNumberOfTags').hide();
$('#specialChars').hide();
var projectName = $("#nameProject").val().trim();
var password = $("#passwordProject").val().trim();
var adminPassword = $("#adminPassword").val().trim();
if (adminPassword == "") {
adminPassword = "1234";
}
var reguexp = /^[a-zA-Z0-9äüöÄÜÖ\ ]+$/;
if (!reguexp.test(projectName)) {
$('#specialChars').show();
return false;
}
if (projectName === "") { //project has no name, so abort function
$('#projectIsMissing').show();
return false;
}
document.getElementById('loader').className = "loader";
document.getElementById('wrapper').className = "wrapper-inactive";
var localurl = "../database/getProjects.php?project=" + projectName;
if (allTheTags.length !== 5) {
document.getElementById('tagHelper').className = "alert alert-warning";
} else {
document.getElementById('tagHelper').className = "";
}
$('#projectIsMissing').hide();
$.ajax({ //check local DB for existence of projectName
url: localurl,
projectName: projectName,
activ: activ,
Accept: "text/plain; charset=utf-8",
contentType: "text/plain",
success: function (response) {
if (response !== "project missing") {
$('#projectNameExists').show();
document.getElementById('loader').className = "loader-inactive";
document.getElementById('wrapper').className = "wrapper";
return true;
} else {
$('#projectNameExists').hide();
if (allTheTags.length !== 5) {
document.getElementById('tagHelper').className = "alert alert-warning";
document.getElementById('loader').className = "loader-inactive";
document.getElementById('wrapper').className = "wrapper";
$('#exactNumberOfTags').show();
return false;
}
document.getElementById('tagHelper').className = "";
var obj = {
"courseId": projectName,
"printableName": projectName,
"competences": allTheTags
};
var url = compbaseUrl + "/api1/courses/" + $("#nameProject").val();
var dataString = JSON.stringify(obj);
var addProjectNeo4j = $.ajax({
url: url,
contentType: 'application/json',
activ: activ,
type: 'PUT',
data: dataString,
success: function (response) {
console.log(response);
document.getElementById('loader').className = "loader-inactive";
document.getElementById('wrapper').className = "wrapper";
},
error: function (a, b, c) {
console.log(a);
document.getElementById('loader').className = "loader-inactive";
document.getElementById('wrapper').className = "wrapper";
return false;
}
});
$.when(addProjectNeo4j, addProjectToLocalDB(allTheTags, projectName, password, activ, adminPassword)).done(function () {
document.getElementById('loader').className = "loader-inactive";
document.getElementById('wrapper').className = "wrapper";
if ($('#Teilnehmer').prop("checked")) { //if author wants to join the course, he needs to be redirected to preferences.php
var url = "../database/getProjects.php?project=" + projectName + "&password=" + document.getElementById('passwordProject').value;
$.ajax({
url: url,
projectName: projectName,
Accept: "text/plain; charset=utf-8",
contentType: "text/plain",
success: function (response) {
location.href = "preferences.php?token=" + getUserTokenFromUrl() + "&projectToken=" + response;
},
error: function (a, b, c) {
console.log(a);
}
});
} else { //if author is just author and not member, he will be directed to projects.php
location.href = "projects.php?token=" + getUserTokenFromUrl();
}
});
}
},
error: function (a, b, c) {
console.log(a);
document.getElementById('loader').className = "loader-inactive";
document.getElementById('wrapper').className = "wrapper";
return true;
}
});
}
function addProjectToLocalDB(allTheTags, projectName, password, activ, adminPassword) {
var tags = JSON.stringify(allTheTags);
var author = $("#user").text().trim();
var url = "../database/putProject.php?project=" + projectName + "&password=" + password + "&activ=" + activ + "&token=" + getUserTokenFromUrl() + "&adminpassword=" + adminPassword + "&author=" + author;
return $.ajax({
url: url,
//contentType: 'application/json',
type: 'POST',
data: tags,
success: function (response) {
console.log("Tags were added to local DB");
},
error: function (a, b, c) {
console.log(a);
}
});
}
\ No newline at end of file
/**
* Created by fides-WHK on 02.03.2018.
*/
$(document).ready(function () {
getProjectOverview(document.getElementById('user').innerHTML);
//getMembers($('#projectDropdown').innerHTML,$('#user').innerHTML);
});
function printProjects(projects, offset) {
var table = document.getElementById("projectTable");
var i = 0;
if (projects != null) {
for (i = 0; i < projects.length; i++) {
var project = projects[i];
var content = document.createElement("TR");
content.role = "button";
content.style = "cursor:pointer;";
content.id = project;
//'<a class="btn btn-default"><em class="fa fa-pencil" ></em></a>' +
//'<button id="deleteButton' +i+ '" class="btn btn-danger fa fa-trash deleteButton"></button>' +
content.innerHTML = '<td align="center">' +
'<a href="deleteProject.php?token='+getUserTokenFromUrl()+'" class="btn btn-danger fa fa-trash"></a>' +
'</td>' +
'<td class="hidden-xs" href="#Div_Promo_Carousel" data-slide="next">' + projects[i] + '</td>' +
'<td id="projectTags' + (i + offset) + '" href="#Div_Promo_Carousel" data-slide="next"></td>';
table.appendChild(content);
getTags(project, i + offset);
$('#' + project).click(function () {
getGroups(this.id);
});
}
}
//$('#deleteModal').modal('show');
}
function getProjectOverview(user) {
var url = compbaseUrl + "/api2/user/" + user + "/projects";
$.ajax({
url: url,
user: user,
type: 'GET',
contentType: "application/json",
dataType: "json",
success: function (data) {
var projects = data.data;
printProjects(projects, 0);
getProjectsOfAuthor(user, projects, printProjects);
},
error: function (a, b, c) {
console.log(a);
}
});
}
function getTags(projectName, number) {
var url = "../database/getTags.php?project=" + projectName;
$.ajax({
url: url,
Accept: "text/plain; charset=utf-8",
contentType: "text/plain",
success: function (response) {
response = JSON.parse(response);
var tagString = "";
var i = 0;
var table = document.getElementById("projectTags" + number);
for (i = 0; i < response.length; i++) {
tagString += "<label class=\"tagLabel\">" + response[i].tag + "</label>";
;
//tagString += response[i].tag + " ";
}
table.innerHTML = tagString;
//table.innerHTML = tagHtml;
},
error: function (a, b, c) {
console.log(a);
}
});
}
function getGroups(projectName) {
var pathName = document.getElementsByName("pathProject");
pathName[0].innerHTML = projectName;
pathName[1].innerHTML = projectName;
var url = compbaseUrl + "/api2/groups/" + projectName; //this API is used, since fleckenroller has security
// issues with
// CORS and stuff
$.ajax({
url: url,
type: 'GET',
contentType: "application/json",
dataType: "json",
success: function (data) {
var table = document.getElementById("groupTable");
table.innerHTML = '';
for (var i = 0; i < data.groups.length; i++) {
var content = document.createElement("TR");
content.role = "button";
content.style = "cursor:pointer;";
content.id = 'Gruppe' + data.groups[i].id;
var groupMembers = '<td align="center">' +
'<a class="btn btn-default"><em class="fa fa-pencil"></em></a>' +
'<a class="btn btn-danger"><em class="fa fa-trash"></em></a>' +
'</td>' +
'<td class="hidden-xs" href="#Div_Promo_Carousel" data-slide="next">Gruppe' + data.groups[i].id + '</td>' +
'<td id="memberOf' + content.id + '" href="#Div_Promo_Carousel" data-slide="next">';
for (var j = 0; j < data.groups[i].users.length; j++) {
groupMembers += data.groups[i].users[j] + "&nbsp;";
}
groupMembers += '</td>';
content.innerHTML = groupMembers;
table.appendChild(content);
$('#Gruppe' + data.groups[i].id).click(function () {
var memberString = $('#memberOf' + this.id).html();
getDetailsOfMembers(this.id, memberString);
});
}
},
error: function (a, b, c) {
console.log(a);
var table = document.getElementById("groupTable");
table.innerHTML = '';
var content = document.createElement("TR");
content.innerHTML = '<td align="center">' +
'</td>' +
'<td class="hidden-xs">Es liegen noch keine Gruppen vor</td>' +
'<td></td>';
table.appendChild(content);
}
});
}
function getDetailsOfMembers(group, studentString) {
var pathName = document.getElementsByName("pathGruppe");
pathName[0].innerHTML = group;
var students = studentString.split("&nbsp;");
var innerurl = "../database/getAdresses.php?student1=" + students[0] + "&student2=" + students[1] + "&student3=" + students[2] + "&student4=" + students[3] + "&student5=" + students[4];
$.ajax({
student1: "" + students[0],
student2: "" + students[1],
student3: "" + students[2],
student4: "" + students[3],
student5: "" + students[4],
url: innerurl,
type: 'GET',
contentType: "application/json",
dataType: "json",
success: function (response) {
var table = document.getElementById("studentTable");
table.innerHTML = '';
var k;
for (k = 0; k < response.length; k++) {
var content = document.createElement("TR");
content.innerHTML = '<td align="center">' +
'<a class="btn btn-default"><em class="fa fa-pencil"></em></a>' +
'<a class="btn btn-danger"><em class="fa fa-trash"></em></a>' +
'</td>' +
'<td class="hidden-xs">' + response[k].name + '</td>' +
'<td> <a href="mailto:' + response[k].email + '">' + response[k].email + '</a></td>';
table.appendChild(content);
}
},
error: function (a, b, c) {
console.log(a);
}
});
}
/**
* Created by dehne on 23.02.2018.
*/
$(document).ready(function () {
$("")
});
/**
* Created by fides-WHK on 09.01.2018.
*/
$(document).ready(function () {
$("#projectWrongPassword").hide();
$("#projectIsMissing").hide();
$("#projectName").keypress(function (e) {
if (e.which == 13) {
document.getElementById("projectPassword").focus();
}
});
$("#projectPassword").keypress(function (e) {
if (e.which == 13) {
seeProject($('#projectName').val());
}
});
$("#seeProject").on('click', function () {
seeProject($('#projectName').val());
});
});
function seeProject(projectName) {
var url = "../database/getProjects.php?project=" + projectName + "&password=" + document.getElementById('projectPassword').value;
if (projectName === "") {
return false;
} else {
$.ajax({
url: url,
projectName: projectName,
Accept: "text/plain; charset=utf-8",
contentType: "text/plain",
success: function (response) {
if (response === "project missing") {
$("#projectIsMissing").show();
} else {
if (response !== "wrong password") { //if response !== project missing and not wrong password, its the projectToken
location.href="preferences.php?token="+getUserTokenFromUrl()+"&projectToken="+response;
} else {
$("#projectIsMissing").hide();
$('#projectWrongPassword').show();
}
}
},
error: function (a, b, c) {
console.log(a);
}
});
}
}
\ No newline at end of file
function getUserTokenFromUrl() {
var parts = window.location.search.substr(1).split("&");
var $_GET = {};
for (var i = 0; i < parts.length; i++) {
var temp = parts[i].split("=");
$_GET[decodeURIComponent(temp[0])] = decodeURIComponent(temp[1]);
}
return $_GET['token'];
}
<taglib>
<tlib-version>1.0</tlib-version>
<jsp-version>2.0</jsp-version>
<short-name>hiddenUserTag</short-name>
<tag>
<name>hiddenUserTag</name>
<tag-class>unipotsdam.gf.core.management.user.HiddenUserTag</tag-class>
<body-content>empty</body-content>
</tag>
<tag>
<name>menu</name>
<tag-class>unipotsdam.gf.core.management.user.Menu</tag-class>
<body-content>empty</body-content>
</tag>
<tag>
<<<<<<< HEAD
<name>headLine</name>
<tag-class>unipotsdam.gf.core.management.user.headLine</tag-class>
=======
<name>session</name>
<tag-class>unipotsdam.gf.core.session.SessionTag</tag-class>
>>>>>>> origin/session_management
<body-content>empty</body-content>
</tag>
<tag>
<<<<<<< HEAD
<name>omniDependencies</name>
<tag-class>unipotsdam.gf.core.management.user.omniDependencies</tag-class>
=======
<name>context</name>
<tag-class>unipotsdam.gf.core.session.ContextTag</tag-class>
>>>>>>> origin/session_management
<body-content>empty</body-content>
</tag>
</taglib>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment