"Sounds" tab in Settings page... WIP, needs fixing.

v1.18.x
Julian Lam 11 years ago
parent 97a64122b4
commit 6d03f713c5

@ -1,10 +1,16 @@
"use strict"; "use strict";
/*global define, app, socket, RELATIVE_PATH */ /*global define, app, socket, RELATIVE_PATH */
define(['uploader'], function(uploader) { define(['uploader', 'sounds'], function(uploader, sounds) {
var Settings = {}; var Settings = {};
Settings.init = function() { Settings.init = function() {
// Sounds tab
$('#sounds').find('button[data-action="play"]').on('click', function() {
var fileName = $(this).parent().siblings('select').val();
sounds.playFile(fileName);
});
Settings.prepare(); Settings.prepare();
}; };

@ -1,4 +1,5 @@
"use strict"; "use strict";
/* global socket */
define(['buzz'], function(buzz) { define(['buzz'], function(buzz) {
var Sounds = {}; var Sounds = {};
@ -70,5 +71,18 @@ define(['buzz'], function(buzz) {
else ready(); else ready();
}; };
Sounds.playFile = function(fileName) {
var ready = function() {
if (Sounds.loaded[fileName]) {
Sounds.loaded[fileName].play();
} else {
console.log('[sounds] Not found:', name);
}
};
if (!this.initialised) this.init(ready);
else ready();
}
return Sounds; return Sounds;
}); });

@ -2,16 +2,17 @@
var async = require('async'), var async = require('async'),
user = require('./../user'), user = require('../user'),
categories = require('./../categories'), categories = require('../categories'),
topics = require('./../topics'), topics = require('../topics'),
db = require('./../database'), meta = require('../meta'),
events = require('./../events'), db = require('../database'),
languages = require('./../languages'), events = require('../events'),
plugins = require('./../plugins'), languages = require('../languages'),
widgets = require('./../widgets'), plugins = require('../plugins'),
groups = require('./../groups'), widgets = require('../widgets'),
pkg = require('./../../package.json'), groups = require('../groups'),
pkg = require('../../package.json'),
validator = require('validator'); validator = require('validator');
@ -111,7 +112,18 @@ adminController.languages.get = function(req, res, next) {
}; };
adminController.settings.get = function(req, res, next) { adminController.settings.get = function(req, res, next) {
res.render('admin/settings', {}); meta.sounds.getLocal(function(err, sounds) {
// There has GOT to be a better way!
sounds = Object.keys(sounds).map(function(name) {
return {
name: name
};
});
res.render('admin/settings', {
sounds: sounds
});
});
}; };
adminController.logger.get = function(req, res, next) { adminController.logger.get = function(req, res, next) {

Loading…
Cancel
Save