"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";
/*global define, app, socket, RELATIVE_PATH */
define(['uploader'], function(uploader) {
define(['uploader', 'sounds'], function(uploader, sounds) {
var Settings = {};
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();
};

@ -1,4 +1,5 @@
"use strict";
/* global socket */
define(['buzz'], function(buzz) {
var Sounds = {};
@ -70,5 +71,18 @@ define(['buzz'], function(buzz) {
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;
});

@ -2,16 +2,17 @@
var async = require('async'),
user = require('./../user'),
categories = require('./../categories'),
topics = require('./../topics'),
db = require('./../database'),
events = require('./../events'),
languages = require('./../languages'),
plugins = require('./../plugins'),
widgets = require('./../widgets'),
groups = require('./../groups'),
pkg = require('./../../package.json'),
user = require('../user'),
categories = require('../categories'),
topics = require('../topics'),
meta = require('../meta'),
db = require('../database'),
events = require('../events'),
languages = require('../languages'),
plugins = require('../plugins'),
widgets = require('../widgets'),
groups = require('../groups'),
pkg = require('../../package.json'),
validator = require('validator');
@ -111,7 +112,18 @@ adminController.languages.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) {

Loading…
Cancel
Save