Skip to content

Instantly share code, notes, and snippets.

@mikekavouras
Forked from jeffrafter/slack.js
Last active December 21, 2015 00:59
Show Gist options
  • Save mikekavouras/6224786 to your computer and use it in GitHub Desktop.
Save mikekavouras/6224786 to your computer and use it in GitHub Desktop.
// What?! http://stackoverflow.com/a/5571069/700536
function multiline(f) {
return f.toString().
replace(/^[^\/]+\/\*!?/, '').
replace(/\*\/[^\/]+$/, '');
}
var overrides = multiline(function() {/*!
*/});
$('head').append("<style>"+overrides+"</style>");
// Leave reset false when you say something
function say(message, skipReset) {
if (!skipReset) {
window.channels = [];
$('a.channel_name').each(function() {
window.channels.push($(this).attr('href').replace('/channels/', ''));
});
}
setTimeout(function() {
if (window.channels.length == 0) return;
var chan = window.channels.pop();
$('#message-input').val('/open '+chan);
$('#message-input').parents('form').submit();
setTimeout(function() {
$('#message-input').val(message);
$('#message-input').parents('form').submit();
say(message, true);
}, 100);
}, 100);
}
function setDefaultSound(src) {
var audio = document.createElement('audio');
$(audio).attr('src', src);
TS.ui.sounds.new_message = audio;
TS.ui.playSound('new_message');
}
function resetSound() {
TS.ui.sounds.new_message = TS.ui.sounds.old_message;
TS.ui.playSound('old_message');
}
TS.ui.sounds.old_message = TS.ui.sounds.new_message;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment