Browse Source

Outsource global variables into 'initGlobals.js'

master
Erik Römmelt 5 years ago
parent
commit
783938821c

+ 1
- 2
public/index.html View File

@@ -69,6 +69,7 @@
<script src="lib/jquery-3.3.1.min.js"></script>

<!-- NOTE: Include .js Routes -->
<script src="routes/initGlobals.js"></script>
<script src="routes/auth.js"></script><!-- Must load before profile.js -->
<script src="routes/home.js"></script>
<script src="routes/files.js"></script>
@@ -76,8 +77,6 @@
<script src="routes/bookmark.js"></script>
<script src="routes/profil.js"></script>
<script src="routes/msgCard.js"></script>
<script src="routes/messageData.js"></script>
<script src="routes/tagData.js"></script>
<script src="routes/majorData.js"></script>
<script src="routes/profilCard.js"></script>
<script src="routes/navRoutes.js"></script>

+ 0
- 2
public/routes/auth.js View File

@@ -1,5 +1,3 @@
var auth = {};

function clearAuthState() {
auth.user = ''; // Login name
auth.name = ''; // Full name

+ 2
- 4
public/routes/createMessage.js View File

@@ -1,4 +1,3 @@
var tagArray = [];
const CreateMsgRouter = {
template: `
<div class="content">
@@ -73,7 +72,6 @@ const CreateMsgRouter = {

data: function () {
return {
auth: auth,
isDisabled: false,
selected: [],
searchtext : "",
@@ -92,14 +90,14 @@ const CreateMsgRouter = {
},
methods: {
saveTagsToArray: function() {
tagArray = this.selected;
tagArray = this.selected;
console.info(tagArray);
},
createMsg: function () {
var _subject = $("#subject").val();
var _message = $("#message").val();
var _tag = tagArray;
var _user = auth.name ? auth.name : $("#user").val();
var _user = auth.name != '' ? auth.name : $("#user").val();
//console.log("Message Created: " + _tag + " " + _message + " " + _user);
$.ajax({
url: "api/msg",

+ 0
- 2
public/routes/files.js View File

@@ -1,5 +1,3 @@
var tagArray = [];

const FileRouter = {
template: `
<div class="content">

+ 0
- 63
public/routes/home.js View File

@@ -24,47 +24,9 @@ const HomeRouter = {
};
},
methods: {
/*refresh_messages: function () {
_messages.push({ //////// alt
id: 42,
subject: "xxx",
message: "warum habt ihr auch so viel",
user: "nobody",
tags: "foo"
});
},*/
list_messages: function() {
messages();
}
/*list_messages: function () {
$.ajax({url: "api/msg/ids", method: "GET"})
.done(jd => {
// NICHT SO wg. Vue: _messagelist = jd;
_messagelist.splice(0, _messagelist.length);
_messagelist.push.apply(_messagelist, jd);
//console.log("jd: "+jd);
for (var e in jd) {
if (!_messages[jd[e]]) {
get_insert_message(jd[e]);
}
}
if(!($".om-searchbar" = "")){
for (var e in jd) {
if (!_messages[jd[e]]) {
get_insert_message(jd[e]);
}
}
}else{
for (var e in jd) {
if (!_messages[jd[e]]) {
get_search_message(jd[e]);
}
}
}
}).fail(function (e, f, g) {
console.log("list_msg: err: " + e + f + g);
});
}*/
},

mounted: function () {
@@ -80,28 +42,3 @@ function get_insert_message(id) {
console.log("cannot load " + id + ".json: " + e + f + g);
})
}

/*function get_search_message(phrase) {
$.ajax({ url: "api/msg/search/"+phrase, method: "GET" }).done(function (msg) {
Vue.set(_messages, id, msg);
}).fail(function (e, f, g) {
console.log("cannot load " + id + ".json: " + e + f + g);
})
}
$(document).ready(function () {
console.log("egal");
$.get('list.json').done(function (jd) {
// _messagelist = jd;
_messagelist.splice(0, _messagelist.length);
_messagelist.push.apply(_messagelist, jd);
console.log("egal2");
//$('#xxx').text(jd[0]);
for (var e in jd) {
if (!_messages[jd[e]]) {
get_insert_message(jd[e]);
}
}
}).fail(function (e, f, g) {
console.log("egal3: " + e + f + g);
});
});*/

+ 18
- 0
public/routes/initGlobals.js View File

@@ -0,0 +1,18 @@
// Global Variables
// User
var auth = {},
majorList = [],

// Message
_messagelist = [],
_messages = {},

// Tag
_taglist = [],
_tags = [],
tagArray = [],

// Search
isSearchActive = false,
data = [],
search_data = [];

+ 1
- 1
public/routes/majorData.js View File

@@ -1,4 +1,4 @@
var majorList = [
majorList = [
{id:'B-AC',name:'Bachelor Angewandte Chemie'},
{id:'B-AMP',name:'Bachelor Angewandte Mathematik und Physik'},
{id:'B-TJ',name:'Bachelor Technikjournalismus/Technik-PR'},

+ 0
- 2
public/routes/messageData.js View File

@@ -1,2 +0,0 @@
_messagelist = [];
_messages = {};

+ 0
- 2
public/routes/tagData.js View File

@@ -1,2 +0,0 @@
_taglist = [];
_tags = [];

+ 0
- 6
public/search.js View File

@@ -1,9 +1,3 @@
var isSearchActive = false,
tagArray = ["lorem"];

const data=[],
search_data = [];

Vue.component('search',{
template: `
<form class="om-searchbar" @submit.prevent="search()">

Loading…
Cancel
Save