class @Notifications IMAGES = success: '<%= image_path "deploy_success.jpg" %>' failed: '<%= image_path "deploy_failed.jpg" %>' error: '<%= image_path "deploy_error.jpg" %>' @init: (outputStream) -> outputStream.addEventListener('status', new this().statusUpdated) statusUpdated: (task) => return if task.status in ['pending', 'running'] return unless $.notifyCheck() == $.NOTIFY_ALLOWED $.notify(@url(task), @title(task), @message(task)) url: (task) -> IMAGES[task.status] message: (task) -> deployShortSha = $('.short-sha').text() switch task.status when 'success' 'Your deploy of ' + deployShortSha + ' was successful!' when 'failed' 'Your deploy of ' + deployShortSha + ' failed.' when 'error' 'Error while deploying ' + deployShortSha + ' .' else 'Your deploy of ' + deployShortSha + ' ended with status: ' + task.status title: (task) -> $('[data-repo-full-name]').attr('data-repo-full-name')