diff --git a/app.js b/app.js index 614a9dd5cd..e448a6a534 100644 --- a/app.js +++ b/app.js @@ -20,11 +20,11 @@ global.configuration = {}; if (data.categories.length === 0) { console.log('Setting up default categories...'); - fs.readFile(config.ROOT_DIRECTORY + '/install/data/categories.json', function(err, categories) { - categories = JSON.parse(categories); + fs.readFile(config.ROOT_DIRECTORY + '/install/data/categories.json', function(err, default_categories) { + default_categories = JSON.parse(default_categories); - for (var category in categories) { - categories.create(categories[category]); + for (var category in default_categories) { + categories.create(default_categories[category]); } }); diff --git a/public/src/app.js b/public/src/app.js index 4dd812a330..e2bda92774 100644 --- a/public/src/app.js +++ b/public/src/app.js @@ -280,7 +280,33 @@ var socket, }, false); // Posting + var formattingBar = document.getElementById('formatting-bar'), + postContentEl = document.getElementById('post_content'); jQuery('#post_window').slideToggle(0); + formattingBar.addEventListener('click', function(e) { + if (e.target.nodeName === 'I') { + switch(e.target.className) { + case 'icon-bold': + var cursorEnd = postContentEl.value.length; + postContentEl.value = postContentEl.value + '**bolded text**'; + postContentEl.selectionStart = cursorEnd+2; + postContentEl.selectionEnd = postContentEl.value.length - 2; + break; + case 'icon-italic': + var cursorEnd = postContentEl.value.length; + postContentEl.value = postContentEl.value + '*italicised text*'; + postContentEl.selectionStart = cursorEnd+1; + postContentEl.selectionEnd = postContentEl.value.length - 1; + break; + case 'icon-list': + var cursorEnd = postContentEl.value.length; + postContentEl.value = postContentEl.value + "\n\n* list item"; + postContentEl.selectionStart = cursorEnd+4; + postContentEl.selectionEnd = postContentEl.value.length; + break; + } + } + }, false); }) diff --git a/public/templates/header.tpl b/public/templates/header.tpl index af5707b826..e46d640e9f 100644 --- a/public/templates/header.tpl +++ b/public/templates/header.tpl @@ -61,10 +61,10 @@