Skip to content

Commit

Permalink
repaired add-ins toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay9596 committed Mar 5, 2017
1 parent 4b4f515 commit 0c63328
Showing 1 changed file with 68 additions and 17 deletions.
85 changes: 68 additions & 17 deletions editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,46 +236,74 @@ function addScript () {
let jsSpan = jsMenu.querySelectorAll('span')
var ScrFlags = [0, 0, 0, 0]
jsButtons[0].addEventListener('click', function (e) {
toggleStatus(0, jsSpan)
var aniStr = "<script src='lib/anime.min.js'></script>"
if (ScrFlags[0] === 0) {
var bootjsStr = "<script src='lib/anime.min.js'></script>"
scripts += bootjsStr
scripts += aniStr
ScrFlags[0] = 1
console.log('Anime added!')
toggleStatus(0, jsSpan)
}
else
{
scripts = scripts.replace(aniStr,'')
ScrFlags[0] = 0
console.log('Anime removed!')
toggleStatus(0, jsSpan)
}
})
jsButtons[1].addEventListener('click', function (e) {
toggleStatus(1, jsSpan)
toggleStatus(2, jsSpan)
var jQStr = "<script src='lib/jquery-3.1.1.min.js'>"
var bootjsStr = "</script><script src='lib/bootstrap.min.js'></script>"
if (ScrFlags[2] === 0) {
var jQStr = "<script src='lib/jquery-3.1.1.min.js'>"
toggleStatus(2, jsSpan)
scripts += jQStr
ScrFlags[2] = 1
console.log('jQuery added!')
}
if (ScrFlags[2] === 1) {
var bootjsStr = "</script><script src='lib/bootstrap.min.js'></script>"
if (ScrFlags[1] === 0) {
scripts += bootjsStr
ScrFlags[1] = 1
console.log('Bootstrap added!')
toggleStatus(1, jsSpan)
}
else
{
scripts = scripts.replace(bootjsStr,'')
ScrFlags[1] = 0
console.log('Bootstrap removed!')
toggleStatus(1, jsSpan)
}
})
jsButtons[2].addEventListener('click', function (e) {
toggleStatus(2, jsSpan)
var jQStr = "<script src='lib/jquery-3.1.1.min.js'></script>"
if (ScrFlags[2] === 0) {
var jQStr = "<script src='lib/jquery-3.1.1.min.js'></script>"
scripts += jQStr
ScrFlags[2] = 1
console.log('jQuery added!')
toggleStatus(2, jsSpan)
}
else if(ScrFlags[1] !== 1)
{
scripts = scripts.replace(jQStr,'')
ScrFlags[2] = 0
console.log('jQuery removed!')
toggleStatus(2, jsSpan)
}
})
jsButtons[3].addEventListener('click', function (e) {
toggleStatus(3, jsSpan)
var js3Str = "<script src='lib/three.min.js'></script>"
if (ScrFlags[3] === 0) {
var js3Str = "<script src='lib/three.min.js'></script>"
scripts += js3Str
ScrFlags[3] = 1
console.log('Three.js added!')
toggleStatus(3, jsSpan)
}
else
{
scripts = scripts.replace(js3Str,'')
ScrFlags[3] = 0
console.log('Three.js removed!')
toggleStatus(3, jsSpan)
}
})
};
Expand All @@ -286,30 +314,53 @@ function addStyle () {
let cssSpan = cssMenu.querySelectorAll('span')
var StyFlags = [0, 0, 0]
cssButtons[0].addEventListener('click', function (e) {
toggleStatus(0, cssSpan)
var aniStr = "<link rel='stylesheet' type='text/css' href='lib/animate.css'>"
if (StyFlags[0] === 0) {
var aniStr = "<link rel='stylesheet' type='text/css' href='lib/animate.css'>"
styles += aniStr
StyFlags[0] = 1
console.log('Animate added!')
toggleStatus(0, cssSpan)
}
else
{
styles = styles.replace(aniStr,'')
StyFlags[0] = 0
console.log('Animate removed!')
toggleStatus(0, cssSpan)
}
})
cssButtons[1].addEventListener('click', function (e) {
toggleStatus(1, cssSpan)
var bootStr = "<link rel='stylesheet' type='text/css' href='lib/bootstrap.min.css'>"

if (StyFlags[1] === 0) {
var bootStr = "<link rel='stylesheet' type='text/css' href='lib/bootstrap.min.css'>"
styles += bootStr
StyFlags[1] = 1
console.log('Bootstrap added!')
toggleStatus(1, cssSpan)
}
else
{
styles = styles.replace(bootStr,'')
StyFlags[1] = 0
console.log('Bootstrap removed!')
toggleStatus(1, cssSpan)
}
})
cssButtons[2].addEventListener('click', function (e) {
toggleStatus(2, cssSpan)
var faStr = "<link rel='stylesheet' type='text/css' href='lib/font-awesome.min.css'>"
if (StyFlags[2] === 0) {
var faStr = "<link rel='stylesheet' type='text/css' href='lib/font-awesome.min.css'>"
styles += faStr
StyFlags[2] = 1
console.log('Font Awesome added!')
toggleStatus(2, cssSpan)
}
else
{
styles = styles.replace(faStr,'');
StyFlags[2] = 0
console.log('Font Awesome removed!')
toggleStatus(2, cssSpan)
}
})
};

0 comments on commit 0c63328

Please sign in to comment.