Skip to content
Snippets Groups Projects
Commit a2e254f7 authored by Andy C's avatar Andy C
Browse files

Fixed comments

parent 720b52e7
No related branches found
No related tags found
No related merge requests found
/**
* This function changes the b and i tags to strong and em tags respectively
*
* @param {string} inputhtml
* @param {string} inputhtml Input HTML to be parsed
*/
function clean_up_html_tags(inputhtml) {
return inputhtml
......@@ -13,23 +13,27 @@ function clean_up_html_tags(inputhtml) {
.replace("<font color=\"", "<span style=\"color: ");
}
/**
* jQuery document ready function
*/
$(document).ready(function () {
// Set default paragraph separator to p tag instead of br
document.execCommand("defaultParagraphSeparator", false, "p");
//Let's go!
//console.log('Hi there!');
// Clear out values to start with
$('#input-textarea').text('');
$('#input-textarea').val('');
$('#input-textarea').on('input propertychange', function () {
//console.log('Alteration!')
});
// Update code button in the center of form
$('#update-code').click(function () {
let outputprehtml = $('#input-textarea').html();
$('#output-pre').text(clean_up_html_tags(outputprehtml));
});
// Colour picker needs to be set twice in case they don't change the colour
$("#color-picker")
.click(function () {
......@@ -42,7 +46,10 @@ $(document).ready(function () {
return true;
});
// Create list of buttons used to style the input like bold, italic etc
var buttonList = [{
// Bold button
'type': 'icon',
'icon': 'bold',
'name': 'Bold',
......@@ -54,6 +61,7 @@ $(document).ready(function () {
}
},
{
// Italic button
'type': 'icon',
'icon': 'italic',
'name': 'Italic',
......@@ -65,6 +73,7 @@ $(document).ready(function () {
}
},
{
// Underline button
'type': 'icon',
'icon': 'underline',
'name': 'underline',
......@@ -76,6 +85,7 @@ $(document).ready(function () {
}
},
{
// Align left button
'type': 'icon',
'icon': 'align-left',
'name': 'align-left',
......@@ -87,6 +97,7 @@ $(document).ready(function () {
}
},
{
// Align center button
'type': 'icon',
'icon': 'align-center',
'name': 'align-center',
......@@ -98,6 +109,7 @@ $(document).ready(function () {
}
},
{
// Align right button
'type': 'icon',
'icon': 'align-right',
'name': 'align-right',
......@@ -109,6 +121,7 @@ $(document).ready(function () {
}
},
{
// Paragraph button
'type': 'icon',
'icon': 'paragraph',
'name': 'paragraph',
......@@ -120,6 +133,7 @@ $(document).ready(function () {
}
},
{
// Unordered list button
'type': 'icon',
'icon': 'list-ul',
'name': 'list-ul',
......@@ -131,6 +145,7 @@ $(document).ready(function () {
}
},
{
// Ordered list button
'type': 'icon',
'icon': 'list-ol',
'name': 'list-ol',
......@@ -142,6 +157,7 @@ $(document).ready(function () {
}
},
{
// Hyperlink button
'type': 'icon',
'icon': 'link',
'name': 'link',
......@@ -155,6 +171,7 @@ $(document).ready(function () {
}
},
{
// Font drop down
'type': 'drop',
'id': 'font-faces',
'values': [{
......@@ -204,6 +221,7 @@ $(document).ready(function () {
}
},
{
// Font size drop down
'type': 'drop',
'id': 'font-size',
'values': [{
......@@ -246,6 +264,7 @@ $(document).ready(function () {
},
{
// Heading drop down
'type': 'drop',
'id': 'header',
'values': [{
......@@ -286,8 +305,11 @@ $(document).ready(function () {
];
var $inBtns = $('#input-controls');
$inBtns.html('');
// Loop through and build buttons and drop downs
buttonList.forEach(item => {
switch (item.type) {
// Build button
case 'icon':
var $btn = $('<button>');
//<i class="fas fa-bold"></i>
......@@ -301,8 +323,8 @@ $(document).ready(function () {
$btn.on('click', item.onclick);
$inBtns.append($btn);
break;
// Build drop down
case 'drop':
//console.log(item);
var $select = $('<select>');
$select.attr('id', 'in-sel-' + item.id);
$select.on('input propertychange', item.onchange);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment