Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cosc320-une
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Joshua Barlin
cosc320-une
Commits
a2e254f7
Commit
a2e254f7
authored
6 years ago
by
Andy C
Browse files
Options
Downloads
Patches
Plain Diff
Fixed comments
parent
720b52e7
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
js/application.js
+240
-218
240 additions, 218 deletions
js/application.js
with
240 additions
and
218 deletions
js/application.js
+
240
−
218
View file @
a2e254f7
/**
* 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
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment