Fixed many bugs, added disconnect notifying
This commit is contained in:
parent
402ad15fce
commit
dda553c9f0
@ -1450,3 +1450,72 @@ textarea.clickModify {
|
||||
-ms-transform: rotate(6deg);
|
||||
transform: rotate(6deg);
|
||||
}
|
||||
|
||||
#disconnect {
|
||||
width: 90%;
|
||||
height: 100%;
|
||||
padding: 5%;
|
||||
|
||||
background-color: #222328;
|
||||
display: none;
|
||||
opacity: 0;
|
||||
|
||||
z-index: 99;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
|
||||
cursor: default;
|
||||
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
#disconnect h3 {
|
||||
font-size: 5vh;
|
||||
font-weight: 400;
|
||||
margin-top: 20vh;
|
||||
text-align: center;
|
||||
|
||||
-webkit-filter: drop-shadow(7px 7px 5px #111);
|
||||
filter: drop-shadow(7px 7px 5px #111);
|
||||
}
|
||||
|
||||
#disconnect h4 {
|
||||
font-size: 4vh;
|
||||
font-weight: 200;
|
||||
text-align: center;
|
||||
|
||||
-webkit-filter: drop-shadow(7px 7px 5px #111);
|
||||
filter: drop-shadow(7px 7px 5px #111);
|
||||
}
|
||||
|
||||
#disconnect h5 {
|
||||
font-size: 3vh;
|
||||
font-weight: 200;
|
||||
width: 15vh;
|
||||
padding: 1vh;
|
||||
margin: auto;
|
||||
margin-top: 2%;
|
||||
|
||||
border: 1px solid #FFF;
|
||||
|
||||
-moz-border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
border-radius: 3px;
|
||||
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
|
||||
-webkit-transition: background-color 0.4s ease;
|
||||
-moz-transition: background-color 0.4s ease;
|
||||
-ms-transition: background-color 0.4s ease;
|
||||
transition: background-color 0.4s ease;
|
||||
}
|
||||
|
||||
#disconnect h5:hover {
|
||||
background-color: rgba(0,0,0,0.1);
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ var calWorkDate = null;
|
||||
var dragging = false;
|
||||
var clicked = false;
|
||||
var workChanger = false;
|
||||
var disconnect= false;
|
||||
|
||||
// Reactive variables.
|
||||
Session.set("user", {}); // Stores user preferences.
|
||||
@ -31,6 +32,28 @@ Session.set("confirmText", ""); // Stores text for confirmations.
|
||||
|
||||
// On render actions
|
||||
|
||||
Meteor.autorun(function () {
|
||||
if (Meteor.status().status !== "connected" && Meteor.status().status !== "connecting" && !disconnect) {
|
||||
disconnect = true;
|
||||
var div = document.createElement("div");
|
||||
div.id = "disconnect";
|
||||
var h = document.createElement("h3");
|
||||
h.appendChild(document.createTextNode("Uh Oh. We can't reach you right now!"));
|
||||
var h2 = document.createElement("h4");
|
||||
h2.appendChild(document.createTextNode("Please check your connection, or reload the page!"));
|
||||
var h5 = document.createElement("h5");
|
||||
h5.appendChild(document.createTextNode("Reload!"));
|
||||
h5.onclick = function() {
|
||||
location.reload();
|
||||
}
|
||||
div.appendChild(h);
|
||||
div.appendChild(h2);
|
||||
div.appendChild(h5);
|
||||
document.getElementsByTagName("body")[0].appendChild(div);
|
||||
$("#disconnect").velocity("fadeIn", 150);
|
||||
}
|
||||
});
|
||||
|
||||
Template.login.rendered = function() {
|
||||
Accounts._loginButtonsSession.set('dropdownVisible', true);
|
||||
};
|
||||
@ -43,6 +66,7 @@ Template.main.created = function() {
|
||||
$(document).on('keyup', (e) => {
|
||||
if(event.keyCode === 27 && $(".overlay").css("display") !== "none") {
|
||||
$(".overlay").velocity("fadeOut", 150);
|
||||
Session.set("currentWork", null);
|
||||
}
|
||||
});
|
||||
|
||||
@ -498,6 +522,7 @@ Template.main.events({
|
||||
var res = Session.get("restrictText");
|
||||
res[Object.keys(res)[0]] = "";
|
||||
Session.set("restrictText", res);
|
||||
Session.set("currentWork", null);
|
||||
}
|
||||
}
|
||||
|
||||
@ -774,6 +799,7 @@ Template.main.events({
|
||||
serverData = Session.get("currentWork");
|
||||
sendData("createWork");
|
||||
$(".overlay").velocity("fadeOut", 150);
|
||||
Session.set("currentWork", null);
|
||||
} else {
|
||||
var message = no.reduce(function(a, b) {
|
||||
return (b === no[no.length - 1]) ? a + ((no.length === 2) ? " and " : ", and ") + b : a + ", " + b;
|
||||
@ -790,6 +816,7 @@ Template.main.events({
|
||||
serverData = Session.get("currentWork")._id;
|
||||
sendData("deleteWork");
|
||||
$(".overlay").velocity("fadeOut", 150);
|
||||
Session.set("currentWork", null);
|
||||
},
|
||||
'click #markDone' () { // Click done button.
|
||||
serverData = [Session.get("currentWork")._id, "done"];
|
||||
@ -860,6 +887,7 @@ sendData = function(funcName) { // Call Meteor function, and do actions after fu
|
||||
if(funcName === "editWork") workChanger = true;
|
||||
if(funcName === "editProfile") filterWork();
|
||||
Meteor.call(funcName, serverData, function(error, result) {
|
||||
if(funcName === "createWork") Session.set("currentWork", null);
|
||||
serverData = null;
|
||||
if (error !== undefined) {
|
||||
console.log(funcName);
|
||||
@ -1046,13 +1074,22 @@ updateWork = function(id, fields, type) {
|
||||
workObj.shortname = (workObj.name.length <= 20) ? workObj.name : workObj.name.substring(0,20) + "...";
|
||||
workObj.className = (workObj.classid === Meteor.userId()) ? "Personal" : classes.findOne({_id: workObj.classid}).name;
|
||||
|
||||
workObj.dateWord = moment(workObj.dueDate).calendar(null, {
|
||||
workObj.dateWord = (!(Meteor.Device.isPhone() || Meteor.Device.isTablet())) ?
|
||||
moment(workObj.dueDate).calendar(null, {
|
||||
sameDay: '[Today]',
|
||||
nextDay: '[Tomorrow]',
|
||||
nextWeek: 'dddd',
|
||||
lastDay: '[Yesterday]',
|
||||
lastWeek: '[Last] dddd',
|
||||
sameElse: 'MMMM Do'
|
||||
}) :
|
||||
moment(workObj.dueDate).calendar(null, {
|
||||
sameDay: '[Today]',
|
||||
nextDay: '[Tomorrow]',
|
||||
nextWeek: 'dddd',
|
||||
lastDay: '[Yesterday]',
|
||||
lastWeek: '[Last] ddd[.]',
|
||||
sameElse: 'MMMM Do'
|
||||
});
|
||||
|
||||
workObj.shortdesc = (workObj.description === undefined) ? "" : (workObj.description.length <= 30 ) ? workObj.description : workObj.description.substring(0,30) + "...";
|
||||
|
||||
@ -370,7 +370,7 @@ Template.joinClass.helpers({
|
||||
subscribers: -1
|
||||
}
|
||||
}, {
|
||||
limit: 20
|
||||
limit: 100
|
||||
}).fetch();
|
||||
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
|
||||
@ -246,6 +246,7 @@ Template.mClassDisplay2.rendered = function() {
|
||||
|
||||
function joinClass(num) {
|
||||
var joining = Session.get("profile").classes;
|
||||
if(joining.length === 0) return;
|
||||
Meteor.call("joinClass", [joining[num], ""], function(err, result) {
|
||||
if(err !== undefined) {
|
||||
sAlert.error(err.message, {
|
||||
|
||||
@ -485,6 +485,7 @@ var created = 0;
|
||||
|
||||
function joinClass(num) {
|
||||
var joining = Session.get("profile").classes;
|
||||
if(joining.length === 0) return;
|
||||
Meteor.call("joinClass", [joining[num], ""], function(err, result) {
|
||||
if(err !== undefined) {
|
||||
sAlert.error(err.message, {
|
||||
@ -501,6 +502,7 @@ function joinClass(num) {
|
||||
|
||||
function createClass(num) {
|
||||
var creating = Session.get("newClasses");
|
||||
if(creating.length === 0) return;
|
||||
Meteor.call("createClass", creating[num], function(error, result) {
|
||||
if(error !== undefined) {
|
||||
sAlert.error(error.message, {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user