diff --git a/LICENSE b/LICENSE
index 8b23445..6e23713 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
MIT License
-Copyright (c) 2019
+Copyright (c) 2019 Josua Robson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/scripts/communications.js b/scripts/communications.js
index 489f942..7b6e111 100644
--- a/scripts/communications.js
+++ b/scripts/communications.js
@@ -416,7 +416,6 @@ function connect(profile, connection_id)
}
// Connect to the server
- console.log(profile.mode, port, hostname, client)
client.connect(port, hostname, function()
{
console.log("Connected", profile.mode);
@@ -426,6 +425,13 @@ function connect(profile, connection_id)
});
});
+ // Catch errors
+ client.on("error", function(e)
+ {
+ // Tell the user
+ console.log("Connection failed with error ", e);
+ });
+
// Create the recieve ordered memory model
var recieve_ordered_memory = {
buffer: new Buffer.alloc(0),
@@ -501,18 +507,11 @@ function connect(profile, connection_id)
g.users = data.users;
g.chats = data.chats;
- // Remove the disabled class
- $("#profile_button_"+connection_id).removeClass("disabled");
+ // Save some global varibles
+ g.logged_in = true;
- // Set onclick
- $("#profile_button_"+connection_id).on("click", function()
- {
- // Switch to the profile id
- profile_switch_to(connection_id);
- });
-
- // Set the href
- document.getElementById("profile_button_"+connection_id).href = "#";
+ // Reload the profiles
+ profiles_reload();
// Switch to this chat
profile_switch_to(connection_id);
diff --git a/scripts/profiles.js b/scripts/profiles.js
index 875fc98..ed38b70 100644
--- a/scripts/profiles.js
+++ b/scripts/profiles.js
@@ -91,17 +91,14 @@ function profile_connect(id)
// Is the profile set
if(profiles[id])
{
- // Connect to the server
- var server = connect(profiles[id], connections.length);
-
- // Add the server to the active connections
- connections.push(server);
+ // Reconnect to the server
+ connections[id] = connect(profiles[id], id);
}
else
{
- // Push an empty connection
- connections.push(undefined);
+ // Set an empty connection
+ connections[id] = undefined;
}
}
@@ -360,8 +357,22 @@ function profiles_reload()
// Create a list item
var profile = document.createElement("li");
+ // Create the disabled class
+ var disabled_class = "class='disabled'";
+
+ // Is there a connection to the server
+ if(connections[i])
+ {
+ // Is the connection logged in
+ if(connections[i].logged_in)
+ {
+ // Remove the disabled class and make the link clickable
+ disabled_class = "href='#' onclick='profile_switch_to("+i+")'";
+ }
+ }
+
// Set the html for the list item
- profile.innerHTML = ""+title(i)+"";
+ profile.innerHTML = ""+title(i)+"";
// Add the profile to the menu
chat_menu.appendChild(profile);