Skip to content
This repository was archived by the owner on Jun 16, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/js/services/fs-xhr.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ define('services/fs-xhr',['q','jquery'],function(Q,$) {
this._get(url).done(function(data) {
def.resolve(data);
}).fail(function(data) {
if(data.statusText === "error"){ //status text given when server is inaccessible
alert("Server is inaccessible!")
}
def.reject(data);
});

Expand All @@ -31,6 +34,9 @@ define('services/fs-xhr',['q','jquery'],function(Q,$) {
this._post(url,data).done(function(data) {
def.resolve(data);
}).fail(function(data) {
if(data.statusText === "error"){ //status text given when server is inaccessible
alert("Server is inaccessible!")
}
def.reject(data);
});
return def.promise;
Expand All @@ -40,6 +46,9 @@ define('services/fs-xhr',['q','jquery'],function(Q,$) {
var def = Q.defer();
var url = baseurl+path;
this._delete(url).done(function(data) {
if(data.statusText === "error"){ //status text given when server is inaccessible
alert("Server is inaccessible!")
}
def.resolve(data);
}).fail(function(data) {
def.reject(data);
Expand Down
5 changes: 4 additions & 1 deletion src/js/services/ng-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ define('services/ng-message',[
var ws;

function init() {
if (ws) {
if (ws && ws.readyState === 1) {//the socket has to be open to work
return $q.when(ws);
}
return $settings.init().then(function(settings) {
Expand All @@ -32,6 +32,9 @@ define('services/ng-message',[
def.resolve(ws);
};
ws.onerror = function(e){
if(e.type === "error"){
alert("mhub server is inaccessible!")
}
log("socket error", e);
};
ws.onclose = function() {
Expand Down