Commit 2a2e687c authored by Max Estefan Mahr's avatar Max Estefan Mahr

Aufgaben Abgabe

parent 6ccc2d31
......@@ -24,5 +24,29 @@
<option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
</formatting-settings>
</DBN-SQL>
<DBN-PSQL>
<case-options enabled="false">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false" />
</DBN-PSQL>
<DBN-SQL>
<case-options enabled="false">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false">
<option name="STATEMENT_SPACING" value="one_line" />
<option name="CLAUSE_CHOP_DOWN" value="chop_down_if_statement_long" />
<option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
</formatting-settings>
</DBN-SQL>
</code_scheme>
</component>
\ No newline at end of file
This diff is collapsed.
......@@ -2,6 +2,10 @@ h1 {
font-family: "Bell MT";
color: blue;
}
h2 {
font-family: "Arial Narrow";
color: chocolate;
}
div {
background-color: beige;
font-family: "Arial Narrow";
......
......@@ -3,12 +3,45 @@
<head>
<meta charset="UTF-8">
<title>Title</title>
<link rel="stylesheet" href="/site/view.css">
<script src="/site/view.js"></script>
<link rel="stylesheet" href="view.css">
<script src="view.js"></script>
</head>
<body>
<h1>Max Mahr</h1>
<h2>Übung 6</h2>
<p id="divplatz"> </p>
<button id="diverstellen" type="button" onclick="divs()">Div Schleife</button>
<h1 id="zahlenraten">Zahlenraten</h1>
<div id="raten">
<input id="text1" type="number" value=" "/>
<input id="Btn1" type="submit" value="Raten1"/>
</div>
<br>
<div id="schummeln">
<div>Passwort:</div><input id="text2" type="text" value=" "/>
<input id="Btn2" type="submit" value="schummeln"/>
</div>
<br>
<div id="zahlsetzen">
<div>Zahl setzen:</div><input id="text3" type="number" value=""/>
<input id="Btn3" type="submit" value="Zahl setzen"/>
</div>
<br>
<div id="result">
Response Server:<span id="data">Platzhalter</span>
</div>
</body>
</body>
</html>
\ No newline at end of file
......@@ -7,4 +7,38 @@ function divs() {
div.textContent = summe.toString();
}
}
$(document).ready(function () {
$('#Btn1').click(function () {
$("#data").html("");
var variable = $("#text1").val();
$.ajax({
url: 'http://localhost:8080/raten/' + variable,
type: 'GET',
success: function (data) { $('#data').text(data + "."); },
error: function (jqXHR, Status, error) { alert(error); }
});
});
$('#button2').click(function () {
$("#data").html("");
var passwort = $("#text2").val();
$.ajax({
url: 'http://localhost:8080/cheat?password=' + passwort,
type: 'GET',
success: function (data) { $('#data').text(data + "."); },
error: function (jqXHR, Status, error) { alert(error); }
});
});
$('#button3').click(function () {
$("#data").html("");
var passwort = $("#text2").val();
var number = $("#text3").val();
$.ajax({
url: 'http://localhost:8080/set',
type: 'POST',
data: { password: passwort, zahl: number },
success: function (data) { $('#data').text(data + "."); },
error: function (jqXHR, Status, error) { alert(error); }
});
});
});
//# sourceMappingURL=view.js.map
\ No newline at end of file
{"version":3,"file":"view.js","sourceRoot":"","sources":["view.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAClB;IAEI,KAAK,IAAI,CAAC,GAAS,CAAC,EAAE,CAAC,IAAE,GAAG,EAAE,CAAC,EAAE,EAAE;QAC/B,IAAI,KAAK,GAAW,CAAC,CAAC;QACtB,IAAI,GAAG,GAAE,QAAQ,CAAC,aAAa,CAAE,KAAK,CAAC,CAAC;QACxC,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QACrD,GAAG,CAAC,WAAW,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;KAEtC;AACL,CAAC"}
\ No newline at end of file
{"version":3,"file":"view.js","sourceRoot":"","sources":["view.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;AAClB;IAEI,KAAK,IAAI,CAAC,GAAS,CAAC,EAAE,CAAC,IAAE,GAAG,EAAE,CAAC,EAAE,EAAE;QAC/B,IAAI,KAAK,GAAW,CAAC,CAAC;QACtB,IAAI,GAAG,GAAE,QAAQ,CAAC,aAAa,CAAE,KAAK,CAAC,CAAC;QACxC,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QACrD,GAAG,CAAC,WAAW,GAAG,KAAK,CAAC,QAAQ,EAAE,CAAC;KAEtC;AACL,CAAC;AACD,CAAC,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC;IAEd,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC;QAEb,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACpB,IAAI,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,CAAC;QAEjC,CAAC,CAAC,IAAI,CAAC;YACH,GAAG,EAAE,8BAA8B,GAAG,QAAQ;YAC9C,IAAI,EAAE,KAAK;YACX,OAAO,EAAE,UAAC,IAAI,IAAO,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,GAAC,GAAG,CAAC,CAAA,CAAC,CAAC;YAChD,KAAK,EAAE,UAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAO,KAAK,CAAC,KAAK,CAAC,CAAA,CAAC,CAAC;SACpD,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAKH,CAAC,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC;QAEhB,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACpB,IAAI,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,CAAC;QAEjC,CAAC,CAAC,IAAI,CAAC;YACH,GAAG,EAAE,uCAAuC,GAAG,QAAQ;YACvD,IAAI,EAAE,KAAK;YACX,OAAO,EAAE,UAAC,IAAI,IAAO,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,GAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACjD,KAAK,EAAE,UAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACrD,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;IAIH,CAAC,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC;QAEhB,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACpB,IAAI,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,CAAC;QACjC,IAAI,MAAM,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC,GAAG,EAAE,CAAC;QAE/B,CAAC,CAAC,IAAI,CAAC;YACH,GAAG,EAAE,2BAA2B;YAChC,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,EAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAC;YACxC,OAAO,EAAE,UAAC,IAAI,IAAO,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,GAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACjD,KAAK,EAAE,UAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAO,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACrD,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
\ No newline at end of file
......@@ -9,3 +9,51 @@ function divs(): void {
}
}
$(document).ready(function() {
$('#Btn1').click(() => {
$("#data").html("");
let variable = $("#text1").val();
$.ajax({
url: 'http://localhost:8080/raten/' + variable,
type: 'GET',
success: (data) => { $('#data').text(data+".") },
error: (jqXHR, Status, error) => { alert(error) }
});
});
$('#button2').click(() => {
$("#data").html("");
let passwort = $("#text2").val();
$.ajax({
url: 'http://localhost:8080/cheat?password=' + passwort,
type: 'GET',
success: (data) => { $('#data').text(data+"."); },
error: (jqXHR, Status, error) => { alert(error); }
});
});
$('#button3').click(() => {
$("#data").html("");
let passwort = $("#text2").val();
let number = $("#text3").val();
$.ajax({
url: 'http://localhost:8080/set',
type: 'POST',
data: {password: passwort, zahl: number},
success: (data) => { $('#data').text(data+"."); },
error: (jqXHR, Status, error) => { alert(error); }
});
});
});
......@@ -24,5 +24,29 @@
<option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
</formatting-settings>
</DBN-SQL>
<DBN-PSQL>
<case-options enabled="false">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false" />
</DBN-PSQL>
<DBN-SQL>
<case-options enabled="false">
<option name="KEYWORD_CASE" value="lower" />
<option name="FUNCTION_CASE" value="lower" />
<option name="PARAMETER_CASE" value="lower" />
<option name="DATATYPE_CASE" value="lower" />
<option name="OBJECT_CASE" value="preserve" />
</case-options>
<formatting-settings enabled="false">
<option name="STATEMENT_SPACING" value="one_line" />
<option name="CLAUSE_CHOP_DOWN" value="chop_down_if_statement_long" />
<option name="ITERATION_ELEMENTS_WRAPPING" value="chop_down_if_not_single" />
</formatting-settings>
</DBN-SQL>
</code_scheme>
</component>
\ No newline at end of file
This diff is collapsed.
......@@ -175,5 +175,4 @@ $(function () {
});
});
} // end of namespace AJAX
......@@ -31,6 +31,7 @@ var BOOTSTRAP;
this.saveBtn = $("#editSaveBtn");
this.editWindow = $("#editWindow");
this.resultWindow = $("#resultWindow");
this.DeleteUser = $("#DeleteBtn");
}
/**
* Creates new User with Attributes from Inputfields
......@@ -181,7 +182,7 @@ var BOOTSTRAP;
this.userTable.empty();
//--- set table header and for each user a table-row
if (userList.length > 0) { // there are users in list -> print header
this.userTable.append($("\n\t\t\t\t\t<div class=\"row bg-info\">\n\t\t\t\t\t\t<div class=\"col-5 justify-content-center\">Vorname</div>\n\t\t\t\t\t\t<div class=\"col-5 justify-content-center\">Nachname</div>\n\t\t\t\t\t\t<div class=\"col-2\"></div>\n\t\t\t\t\t</div>\n\t\t\t\t"));
this.userTable.append($("\n\t\t\t\t\t<div class=\"row bg-info\">\n\t\t\t\t\t\t<div class=\"col-5 justify-content-center\">Vorname</div>\n\t\t\t\t\t\t<div class=\"col-5 justify-content-center\">Nachname</div>\n\t\t\t\t\t<div>\n\t\t\t\t"));
}
var evenRow = true; // row-number is even
for (var _i = 0, userList_1 = userList; _i < userList_1.length; _i++) {
......@@ -243,6 +244,21 @@ var BOOTSTRAP;
this.resultWindow.addClass("bg-success");
}
};
UserList.prototype.deleteallusers = function (id) {
var _this = this;
$.ajax({
url: 'http://localhost:8080/users/',
type: 'DELETE',
dataType: 'json',
error: function (jqXHR) {
_this.renderResult(jqXHR.responseJSON.message, jqXHR.status);
},
success: function (data) {
_this.renderResult(data.message, 0);
_this.renderList(data.userList);
}
});
};
return UserList;
}());
/**********************************************************************************************************************
......@@ -266,11 +282,18 @@ var BOOTSTRAP;
$("#createBtn").on("click", function () {
userList.createUser(event);
});
$("#vornameInput, #nachnameInput").on("keyup", function (event) {
if (event.which === ENTER_KEY) {
userList.createUser(event);
} // only if "enter"-key (=13) is pressed
$("#EditBtn").on("click", function () {
userList.renderEdit(event); // leider verstehe ich nicht wieso der Edit Button nicht das macht was er soll...
});
$("#DeleteBtn").on("click", function () {
userList.deleteallusers(UserList.length); //Delete funktioniert zwar aber leider kommt man immer auf die Startseite...
$("#vornameInput, #nachnameInput, #nutzernameInput, #passwortInput").on("keyup", function (event) {
if (event.which === ENTER_KEY) {
userList.createUser(event);
} // only if "enter"-key (=13) is pressed
});
});
//Server erhält Daten vom Nutzer
});
})(BOOTSTRAP || (BOOTSTRAP = {})); // end of namespace BOOTSTRAP
//# sourceMappingURL=clientBS.js.map
\ No newline at end of file
......@@ -36,6 +36,9 @@ class UserList {
private saveBtn : JQuery = $("#editSaveBtn");
private editWindow : JQuery = $("#editWindow");
private resultWindow : JQuery = $("#resultWindow");
private DeleteUser : JQuery = $("#DeleteBtn");
/**
* Creates new User with Attributes from Inputfields
......@@ -191,8 +194,7 @@ class UserList {
<div class="row bg-info">
<div class="col-5 justify-content-center">Vorname</div>
<div class="col-5 justify-content-center">Nachname</div>
<div class="col-2"></div>
</div>
<div>
`));
}
let evenRow = true; // row-number is even
......@@ -254,9 +256,23 @@ class UserList {
this.resultWindow.addClass("bg-success");
}
}
public deleteallusers(id: number): void {
$.ajax({
url : 'http://localhost:8080/users/',
type : 'DELETE', // DELETE-request for DELETE
dataType : 'json', // expecting json
error : (jqXHR) => {
this.renderResult(jqXHR.responseJSON.message, jqXHR.status)
},
success : (data) => {
this.renderResult(data.message, 0);
this.renderList(data.userList)
},
});
}
}
/**********************************************************************************************************************
* Main Event Listener, that waits until DOM is loaded *
* - handle click on collapsable items in myContent -> hide all that are shown *
......@@ -265,30 +281,37 @@ class UserList {
**********************************************************************************************************************/
$(function () {
//-- instantiate UserList array --------------------------------------------------------------------------------------
let userList: UserList = new UserList();
//-- instantiate UserList array --------------------------------------------------------------------------------------
let userList: UserList = new UserList();
//-- initially read UserList (in case of other client already included users) ----------------------------------------
userList.readUserlist();
//-- initially read UserList (in case of other client already included users) ----------------------------------------
userList.readUserlist();
//-- handle click on collapsable items in myContent -> hide all that are shown ---------------------------------------
// see: https://getbootstrap.com/docs/4.0/components/collapse -> JavaScript
let contentArea: JQuery = $('#contentArea'); // consider only elements in contentArea
contentArea.on('show.bs.collapse', () => { // handles event "show.bs.collapse"
contentArea.find('.collapse.show').collapse('hide'); // find shown and hide them
});
//-- handle click on collapsable items in myContent -> hide all that are shown ---------------------------------------
// see: https://getbootstrap.com/docs/4.0/components/collapse -> JavaScript
let contentArea: JQuery = $('#contentArea'); // consider only elements in contentArea
contentArea.on('show.bs.collapse', () => { // handles event "show.bs.collapse"
contentArea.find('.collapse.show').collapse('hide'); // find shown and hide them
});
//--- define handler for clicking add-button or <cr> respectively ----------------------------------------------------
$("#createBtn").on("click", () => {
userList.createUser(event);
});
$("#EditBtn").on("click", () => {
userList.renderEdit(event); // leider verstehe ich nicht wieso der Edit Button nicht das macht was er soll...
});
$("#DeleteBtn").on("click", () => {
userList.deleteallusers(UserList.length); //Delete funktioniert zwar aber leider kommt man immer auf die Startseite...
//--- define handler for clicking add-button or <cr> respectively ----------------------------------------------------
$("#createBtn").on("click", () => {
userList.createUser(event);
});
$("#vornameInput, #nachnameInput").on("keyup", (event: JQuery.Event) => {
if (event.which === ENTER_KEY) {
userList.createUser(event);
} // only if "enter"-key (=13) is pressed
});
});
$("#vornameInput, #nachnameInput, #nutzernameInput, #passwortInput").on("keyup", (event: JQuery.Event) => {
if (event.which === ENTER_KEY) {
userList.createUser(event);
} // only if "enter"-key (=13) is pressed
});
});
//Server erhält Daten vom Nutzer
} // end of namespace BOOTSTRAP
} // end of namespace BOOTSTRAP
......@@ -19,7 +19,6 @@
</head>
<body>
<!-- Header ---------------------------------------------------------------->
<nav class="navbar navbar-expand-sm navbar-dark bg-dark fixed-top ">
<a class="navbar-brand" href="#">UserMan ClientServer</a>
......@@ -73,6 +72,10 @@
<div class="col-5"> <input id="nutzernameInput" type=text placeholder="nutzername" /> </div>
<div class="col-5"> <input id="passwortInput" type=text placeholder="passwort"/> </div>
<div class="col-2"> <button class="btn btn-info btn-sm" id="createBtn">Add</button> </div>
<div>
<div class="col-2"> <button class="btn btn-info btn-sm" id="EditBtn">Edit</button> </div>
<div class="col-2"> <button class="btn btn-info btn-sm" id="DeleteBtn">Delete</button> </div>
</div>
</form>
</div>
<!-- UserList -->
......@@ -94,6 +97,7 @@
<div class="modal-body">
<input id="editVorname" type="text" title="edit Vorname"/>
<input id="editNachname" type="text" title="edit Nachname"/>
<input id="editPasswort" type="text" title="edit Passwort"/>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
......
<component name="InspectionProjectProfileManager">
<settings>
<option name="PROJECT_PROFILE" />
</settings>
</component>
\ No newline at end of file
This diff is collapsed.
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Übung 6</title>
<link rel="stylesheet" href="/site/style.css">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
<script src="/jquery/jquery.js"></script>
<script src="/site/script.js"></script>
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css">
</head>
<body>
<h1>Sessions</h1>
<div id="form">
<div> ersteVariable: </div> <input id="erstevariableinput" title='' type='number' name='erstevariable' value='' /> (read/update/delete)<br/>
<br />
<div></div>
<button id='createBtn' type='submit'> create variable </button>
<button id='readBtn' type='submit'> read variable </button>
<button id='updateBtn' type='submit'> update variable </button>
<button id='deleteBtn' type='submit'> delete variable </button>
<br />
<br />
<div></div>
<button id='readListBtn' type='submit'> read variables </button>
<button id='deleteListBtn' type='submit'> delete variables </button>
<div>
<h3>Session</h3>
<div>
<button id="getSessionBtn" class="btn btn-info">
Session abrufen
</button>
<div id="SessionCode" class="code">
<code></code>
</div>
</div>
<div>
<button id="deleteSessionBtn" class="btn btn-info">
Session löschen
</button>
</div>
<hr>
<h3>Variable</h3>
<div>
<div>
<input type="text" id="KeyAnlegen">
<label for="KeyAnlegen">Key</label>
</div>
<div>
<input type="text" id="Variableanlegen">
<label for="Variableanlegen">Wert</label>
</div>
<button id="VariableBtn" class="btn btn-info">
Variable anlegen
</button>
</div>
<div>
<div>
<input type="text" id="deleteVariableKey">
<label for="deleteVariableKey">Key</label>
</div>
<button id="deleteVariableBtn" class="btn btn-info">
Variable löschen
</button>
</div>
<hr>
<h3>MaxAge</h3>
<div>
<div>
<input type="text" id="Zeit">
<label for="Zeit">Zeit [Sekunden]</label>
</div>
<button id="ZeitsetzenBtn" class="btn btn-info">
Zeit setzen
</button>
</div>
<div>
<button id="ZeitlöschenBtn" class="btn btn-info">
Zeit löschen
</button>
</div>
</div>
<div id="container"></div>
<div id="data"></div>
<button id="demoBtn" type="button" class="btn btn-info">Demo</button>
<button class="btn btn-info" type="button"></button>
</div>
<script>
(function() {
'use strict';
let Container = document.querySelector('#demo');
let Button = document.querySelector('#demoBtn');
Button.addEventListener('click', function() {
'use strict';
let data = {message: document.querySelector('#demo').getAttribute('msg')};
Container.show(data);
});
}());
</script>
<script language="javascript" type="text/javascript" src="script.js"></script>
</body>
</html>
\ No newline at end of file
$(function () {
$("#container").text("jQuery läuft...");
});
var AJAX;
(function (AJAX) {
/**********************************************************************************************************************
* Class "User": represents all data of a user in the userList - class is exported (needs ES6) *
**********************************************************************************************************************/
var session = /** @class */ (function () {
function session() {
function getSession() {
$.ajax({
url: 'http://localhost:8080/session',
type: 'GET',
dataType: 'json',
success: function (data) {
console.log("getSession", data);
$('#SessionCode').find('code').html(JSON.stringify(data));
},
error: function (jqXHR) {
$('#demo').attr({ msg: jqXHR.responseJSON.message });
$('#demo').click();
}
return session;
}());
function render(message, session) {
var buffer = "";
//--- render message --------------------------------------------------------
buffer += "<div id='serverMessage'> " + message + "</div>\n";
//--- render table (only if userData exists) --------------------------------
if (erstevariable.length > 0) {
buffer += "<div id='userList'>\n";
buffer += " <table>\n";
buffer += " <tr>\n";
buffer += " <th style='width:20px '> id </th>\n";
buffer += " <th style='width:100px'> vorname </th>\n";
buffer += " <th style='width:100px'> nachname </th>\n";
buffer += " <th style='width:100px'> nutzername </th>\n";
buffer += " <th style='width:100px'> passwort </th>\n";
buffer += " </tr>\n";
for (var _i = 0, userList_1 = userList; _i < userList_1.length; _i++) {
var user = userList_1[_i];
if (user != null) { // ignore array-elements that have been deleted
buffer += " <tr id=user'" + user.id + "'>\n";
buffer += " <td> " + user.id + " </td>\n";
buffer += " <td> " + user.vorname + " </td>\n";
buffer += " <td> " + user.nachname + " </td>\n";
buffer += " <td> " + user.nutzername + " </td>\n";
buffer += " <td> " + user.passwort + " </td>\n";
buffer += " </tr>\n";
}
}
});
}
function deleteSession() {
$.ajax({
url: 'http://localhost:8080/session',
type: 'DELETE',
dataType: 'json',
success: function (data) {
console.log("deleteSession", data);
getSession();
$('#demo').attr({ msg: "Session gelöscht!" });
$('#demo').click();
},
error: function (jqXHR) {
$('#demo').attr({ msg: jqXHR.responseJSON.message });
$('#demo').click();
}
//--- close table (and div) ------------------------------------------------
buffer += " </table>\n";
buffer += "</div>";
//--- put buffer-string into message and userlist --------------------------
$('#data').html(buffer);
$(function () {
//--- click on the create button --------------------------------------------
$('#createBtn').on("click", function () {
var erstevariable = $('#erstevariableinput').val().trim();
var data = { "erstevariable": erstevariable };
$.ajax({
url: 'http://localhost:8080//variable/:key/:value',
type: 'POST',
data: JSON.stringify(data),
contentType: 'application/json',
dataType: 'json',
success: function (data) { render(data.erstevariable, data); },
error: function (jqXHR) { render(jqXHR.responseJSON.message, []); }
});
});
});
}
function Variablesetzen() {
var key = $('#deleteVariableKey');
var val = $('#Variableanlegen');
if (key.val() != "" && val.val() != "") {
$.ajax({
url: 'http://localhost:8080/variable/' + key.val() + '/' + val.val(),
type: 'POST',
dataType: 'json',
success: function (data) {
console.log("setVariable", data);
getSession();
key.val("").parent().removeClass('is-dirty');
val.val("").parent().removeClass('is-dirty');
$('#demo').attr({ msg: "Session-Variable gesetzt!" });
$('#demo').click();
},
error: function (jqXHR) {
$('#demo').attr({ msg: jqXHR.responseJSON.message });
$('#demo').click();
}
});
}
})(AJAX || (AJAX = {}));
}
function Variablelöschen() {
var key = $('#deleteVariableKey');
if (key.val() != "") {
$.ajax({
url: 'http://localhost:8080/variable/' + key.val(),
type: 'DELETE',
dataType: 'json',
success: function (data) {
console.log("deleteVariable", data);
getSession();
key.val("").parent().removeClass('is-dirty');