mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-06 22:15:48 +01:00
fireEvent reflection socket call, tweaks to Sounds page in ACP
This commit is contained in:
@@ -214,8 +214,11 @@ var socket,
|
|||||||
alert = $('<div id="' + alert_id + '" class="alert alert-dismissable alert-' + params.type +'"></div>');
|
alert = $('<div id="' + alert_id + '" class="alert alert-dismissable alert-' + params.type +'"></div>');
|
||||||
|
|
||||||
alert.append($('<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>'))
|
alert.append($('<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>'))
|
||||||
.append($('<strong>' + title + '</strong>'))
|
.append($('<strong>' + title + '</strong>'));
|
||||||
.append($('<p>' + params.message + '</p>'));
|
|
||||||
|
if (params.message) {
|
||||||
|
alert.append($('<p>' + params.message + '</p>'));
|
||||||
|
}
|
||||||
|
|
||||||
if (!params.location) {
|
if (!params.location) {
|
||||||
params.location = 'alert_window';
|
params.location = 'alert_window';
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
/* global define */
|
/* global define, socket */
|
||||||
|
|
||||||
define(['sounds', 'settings'], function(Sounds, Settings) {
|
define(['sounds', 'settings'], function(Sounds, Settings) {
|
||||||
var SoundsAdmin = {};
|
var SoundsAdmin = {};
|
||||||
@@ -19,7 +19,11 @@ define(['sounds', 'settings'], function(Sounds, Settings) {
|
|||||||
// Saving of Form Values
|
// Saving of Form Values
|
||||||
var saveEl = $('#save');
|
var saveEl = $('#save');
|
||||||
saveEl.on('click', function() {
|
saveEl.on('click', function() {
|
||||||
Settings.save('sounds', $('.sounds form'));
|
Settings.save('sounds', $('.sounds form'), function() {
|
||||||
|
socket.emit('admin.fireEvent', {
|
||||||
|
name: 'event:sounds.reloadMapping'
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -229,7 +229,6 @@ define(['taskbar', 'string', 'sounds'], function(taskbar, S, sounds) {
|
|||||||
msg = msg +'\n';
|
msg = msg +'\n';
|
||||||
socket.emit('modules.chats.send', { touid:chatModal.touid, message:msg});
|
socket.emit('modules.chats.send', { touid:chatModal.touid, message:msg});
|
||||||
chatModal.find('#chat-message-input').val('');
|
chatModal.find('#chat-message-input').val('');
|
||||||
console.log('outgoing');
|
|
||||||
sounds.play('chat-outgoing');
|
sounds.play('chat-outgoing');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,8 +28,9 @@ define(function() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
Settings.save = function(hash, formEl) {
|
Settings.save = function(hash, formEl, callback) {
|
||||||
var formEl = $(formEl);
|
formEl = $(formEl);
|
||||||
|
|
||||||
if (formEl.length) {
|
if (formEl.length) {
|
||||||
var values = formEl.serializeObject();
|
var values = formEl.serializeObject();
|
||||||
|
|
||||||
@@ -39,12 +40,13 @@ define(function() {
|
|||||||
}, function(err) {
|
}, function(err) {
|
||||||
app.alert({
|
app.alert({
|
||||||
title: 'Settings Saved',
|
title: 'Settings Saved',
|
||||||
message: 'Restarting NodeBB <i class="fa fa-spin fa-refresh"></i>',
|
|
||||||
type: 'success',
|
type: 'success',
|
||||||
timeout: 2500
|
timeout: 2500
|
||||||
});
|
});
|
||||||
|
|
||||||
socket.emit('admin.restart');
|
if (typeof callback === 'function') {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log('[settings] Form not found.');
|
console.log('[settings] Form not found.');
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
/* global socket */
|
/* global define, socket */
|
||||||
|
|
||||||
define(['buzz'], function(buzz) {
|
define(['buzz'], function(buzz) {
|
||||||
var Sounds = {};
|
var Sounds = {};
|
||||||
@@ -11,7 +11,10 @@ define(['buzz'], function(buzz) {
|
|||||||
Sounds.init = function(callback) {
|
Sounds.init = function(callback) {
|
||||||
var ready = false,
|
var ready = false,
|
||||||
onComplete = function() {
|
onComplete = function() {
|
||||||
|
Sounds.initialised = true;
|
||||||
|
if (typeof callback === 'function') {
|
||||||
callback();
|
callback();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
loadFiles(function() {
|
loadFiles(function() {
|
||||||
@@ -29,6 +32,11 @@ define(['buzz'], function(buzz) {
|
|||||||
ready = true;
|
ready = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Listen for reload message
|
||||||
|
socket.on('event:sounds.reloadMapping', function() {
|
||||||
|
loadMapping();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
var loadFiles = function(callback) {
|
var loadFiles = function(callback) {
|
||||||
@@ -45,8 +53,6 @@ define(['buzz'], function(buzz) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.initialised = true;
|
|
||||||
|
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -54,7 +60,9 @@ define(['buzz'], function(buzz) {
|
|||||||
var loadMapping = function(callback) {
|
var loadMapping = function(callback) {
|
||||||
socket.emit('modules.sounds.getMapping', function(err, mapping) {
|
socket.emit('modules.sounds.getMapping', function(err, mapping) {
|
||||||
Sounds.mapping = mapping;
|
Sounds.mapping = mapping;
|
||||||
|
if (typeof callback === 'function') {
|
||||||
callback();
|
callback();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -67,8 +75,11 @@ define(['buzz'], function(buzz) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!this.initialised) this.init(ready);
|
if (!this.initialised) {
|
||||||
else ready();
|
this.init(ready);
|
||||||
|
} else {
|
||||||
|
ready();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Sounds.playFile = function(fileName) {
|
Sounds.playFile = function(fileName) {
|
||||||
@@ -80,9 +91,13 @@ define(['buzz'], function(buzz) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!this.initialised) this.init(ready);
|
if (!this.initialised) {
|
||||||
else ready();
|
this.init(ready);
|
||||||
|
} else {
|
||||||
|
ready();
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Sounds.init();
|
||||||
return Sounds;
|
return Sounds;
|
||||||
});
|
});
|
||||||
@@ -349,7 +349,7 @@ var fs = require('fs'),
|
|||||||
};
|
};
|
||||||
|
|
||||||
Meta.sounds.getMapping = function(callback) {
|
Meta.sounds.getMapping = function(callback) {
|
||||||
db.getObject('sounds', function(err, sounds) {
|
db.getObject('settings:sounds', function(err, sounds) {
|
||||||
if (err || !sounds) {
|
if (err || !sounds) {
|
||||||
// Send default sounds
|
// Send default sounds
|
||||||
var defaults = {
|
var defaults = {
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ SocketAdmin.restart = function(socket, data, callback) {
|
|||||||
meta.restart();
|
meta.restart();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
SocketAdmin.getVisitorCount = function(socket, data, callback) {
|
SocketAdmin.getVisitorCount = function(socket, data, callback) {
|
||||||
var terms = {
|
var terms = {
|
||||||
day: 86400000,
|
day: 86400000,
|
||||||
@@ -68,7 +67,11 @@ SocketAdmin.getVisitorCount = function(socket, data, callback) {
|
|||||||
db.sortedSetCount('ip:recent', 0, now, next);
|
db.sortedSetCount('ip:recent', 0, now, next);
|
||||||
}
|
}
|
||||||
}, callback);
|
}, callback);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
SocketAdmin.fireEvent = function(socket, data, callback) {
|
||||||
|
index.server.sockets.emit(data.name, data.payload || {});
|
||||||
|
};
|
||||||
|
|
||||||
/* Topics */
|
/* Topics */
|
||||||
SocketAdmin.topics.getMore = function(socket, data, callback) {
|
SocketAdmin.topics.getMore = function(socket, data, callback) {
|
||||||
@@ -405,7 +408,6 @@ SocketAdmin.settings.get = function(socket, data, callback) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
SocketAdmin.settings.set = function(socket, data, callback) {
|
SocketAdmin.settings.set = function(socket, data, callback) {
|
||||||
console.log('setting', data);
|
|
||||||
meta.settings.set(data.hash, data.values, callback);
|
meta.settings.set(data.hash, data.values, callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user