Skip to content

Commit fab41ef

Browse files
committedApr 29, 2018
updated_categories
1 parent 9411e62 commit fab41ef

File tree

8 files changed

+72
-76
lines changed

8 files changed

+72
-76
lines changed
 

‎models/Slider.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ var sliderSchema = mongoose.Schema({
3232
section:String
3333

3434
}],
35-
encap:String
35+
encap:String,
36+
categories:[]
3637

3738
});
3839

‎public/javascripts/createSlider.js

+35-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,41 @@
11

22

3-
var sliderName = document.getElementById('sliderName');
4-
var sliderDescription = document.getElementById('sliderDesc');
3+
var catUL = document.getElementById('categoryList');
4+
var newCat = document.getElementById('catLit');
55

6-
function createNewSlider(){
6+
var catCounter = 0;
7+
8+
var catLength;
9+
10+
11+
function addCategory(){
12+
13+
catLength = document.getElementById('categoryList').getElementsByTagName('li').length;
14+
15+
if(catLength <= 2){
16+
17+
if(newCat.value != '' && newCat.value != null){
18+
19+
$(catUL).append("<li>"+newCat.value+" <i class='fa fa-times' aria-hidden='true' style='color: red;' onclick='parentNode.parentNode.removeChild(parentNode));'></i><input type='hidden' name='cats' value='"+newCat.value+"'/></li>");
20+
21+
22+
}else{
23+
window.alert('Please Enter Something VALID for a category');
24+
25+
}
26+
}else{
27+
28+
window.alert('Maximum of three tags at creation time');
29+
730

8-
var slider = {
9-
name:sliderName.value,
10-
description:sliderDescription.value
1131
}
1232

13-
$.post('http://localhost:8080/createNewSlider', slider);
14-
window.location.href = 'https://tronslide.herokuapp.com/mySlides';
15-
}
33+
34+
35+
36+
37+
}
38+
39+
40+
41+

‎routes/index.js

+12-41
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,12 @@ router.get('/home', function(req, res, next) {
8585

8686

8787
router.get('/createNew', function(req, res, next) {
88+
8889
if(!req.user){
8990
res.render('createSlide.ejs', { isLoggedIn: false });
9091

9192
}else{
92-
res.render('createSlide.ejs', { isLoggedIn: true });
93+
res.render('createSlide.ejs', { user:req.user, isLoggedIn: true });
9394
}
9495
});
9596

@@ -176,30 +177,6 @@ router.post('/editSlider', function(req, res){
176177

177178
});
178179

179-
router.post('/createNewSlider', function(req, res, next) {
180-
181-
var currentTime = new Date().toLocaleString();
182-
183-
var newSlider = Slider({
184-
185-
name :req.body.name,
186-
description:req.body.description,
187-
createdOn:currentTime,
188-
noodles:0,
189-
author:'annonymous',
190-
sliderSections:[],
191-
slides:[]
192-
193-
});
194-
195-
newSlider.save(function(err) {
196-
if (err) throw err;
197-
198-
res.redirect('');
199-
200-
});
201-
});
202-
203180
router.post('/addSection', function(req,res){
204181

205182

@@ -272,21 +249,10 @@ router.get('/upload', function(req, res, next) {
272249
});
273250

274251

275-
router.post('/uploadTwo', function(req,res){
276-
277-
if(!req.files){
278-
res.send("Please Sumbit A File.");
279-
}else{
280-
console.log(req.body);
281-
}
282-
283-
284-
});
285-
286252

287-
router.post('/upload', function(req,res){
288-
289-
if(!req.files){
253+
router.post('/createNewSlider', function(req, res, next) {
254+
255+
if(!req.files){
290256
res.send("Please Sumbit A File.");
291257
}else{
292258

@@ -341,7 +307,8 @@ router.post('/upload', function(req,res){
341307
videos:[],
342308
author:req.body.author,
343309
sliderSections:[],
344-
slides:[]
310+
slides:[],
311+
categories:req.body.cats
345312

346313
});
347314

@@ -357,10 +324,14 @@ router.post('/upload', function(req,res){
357324
});
358325
}
359326
}
360-
});
361327

362328

363329

330+
331+
332+
333+
});
334+
364335

365336
// process the signup form
366337
router.post('/signup', passport.authenticate('local-signup', {

‎uploads/logo.png

24.8 KB
Loading

‎views/components/createSlider.ejs

+18-23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<section>
2-
<form enctype="multipart/form-data" method="post" action="/upload">
2+
<form enctype="multipart/form-data" method="post" action="/createNewSlider">
33

44
<div id="head" style="background: url(./img/blur.jpg);">
55
<div class="line">
@@ -23,7 +23,7 @@
2323
<input type='text' class='form-control' id='sliderName' name='sliderName'>
2424
</div>
2525

26-
<div class="col-lg-5">
26+
<div class="col-lg-5 col-lg-offset-1">
2727
<label >Upload Image :</label>
2828
<div class="input-group">
2929
<span class="input-group-btn">
@@ -52,7 +52,7 @@
5252
<div class="row" style="padding-top: 15px;">
5353
<div class="col-lg-6">
5454
<label for="sliderName">Cost (Centralized Currency):</label>
55-
<input type="number" class="form-control" id="costAmount" name='centralizedCost' placeholder="FREE">
55+
<input type="number" class="form-control" id="costAmount" name='centralizedCost' value="0.00">
5656
<select class="selectpicker" style="margin-top: 5px;" name="centralizedCurrency">
5757
<option>USD</option>
5858
<option>EUR</option>
@@ -71,7 +71,7 @@
7171
<div class="col-lg-6">
7272

7373
<label for="sliderName">Cost (De-Centralized Currency):</label>
74-
<input type="number" class="form-control" id="costAmount" name='decentralizedCost' placeholder="FREE">
74+
<input type="number" class="form-control" id="costAmount" name='decentralizedCost' value="0.00">
7575
<select class="selectpicker" style="margin-top: 5px;" name='decentralizedCurrency'>
7676
<option>Bitcoin</option>
7777
<option>Ethereum</option>
@@ -96,37 +96,32 @@
9696
<div class="col-lg-6" style="padding-top: 10px;">
9797

9898
<label for="sliderName">Author:</label>
99-
<input type="text" class="form-control" id="author" name='author' value="Anonymous">
99+
<input type="text" class="form-control" id="author" name='author' value="<%= user.username %>">
100100

101101
</div>
102102
</div>
103-
<div class="row">
103+
104+
<div class="row">
104105
<div class="col-lg-6">
106+
105107
<label for="sliderName">Categories:</label>
106-
<ul>
107-
<li>Test <i class="fa fa-times" aria-hidden="true" style="color: red;"></i></li>
108-
<li>Test <i class="fa fa-times" aria-hidden="true" style="color: red;"></i></li>
109-
<li>Test <i class="fa fa-times" aria-hidden="true" style="color: red;"></i></li>
108+
<ul id='categoryList' name='cats'>
109+
110110
</ul>
111111

112112
<div class="input-group">
113-
<input type="text" class="form-control" placeholder="New Category">
114-
<span class="input-group-btn">
115-
<button type="button" class="btn btn-default">ADD</button>
116-
</span>
117-
</div>
113+
<input type="text" class="form-control" placeholder="New Category" name="catLit" id="catLit">
114+
<span class="input-group-btn">
115+
<button type="button" onClick="addCategory();" class="btn btn-default">ADD</button>
116+
</span>
117+
</div>
118+
118119
</div>
119120
</div>
120121

121-
<div class="row">
122-
<div class="col-lg-6">
123-
<label for="sliderName">Help:</label>
124-
<a href="./help">Click here to learn how to monetize your free Sliders !</a>
125-
</div>
126-
</div>
122+
127123

128124

129-
130125

131126
</div>
132127

@@ -164,7 +159,7 @@
164159

165160

166161

167-
162+
<script src="../javascripts/createSlider.js"></script>
168163

169164

170165

‎views/components/footer.ejs

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
</footer>
1717

1818

19+
20+
21+
1922
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
2023
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js" integrity="sha384-cs/chFZiN24E4KMATLdqdvsezGxaGsi4hLGOzlXwp5UZB1LY//20VyM2taTB4QvJ" crossorigin="anonymous"></script>
2124
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js" integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm" crossorigin="anonymous"></script>

‎views/components/loginPanel.ejs

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
alt="">
1919

2020
<form class="form-signin" action="/signin" method="post">
21-
<input type="text" class="form-control reg" placeholder="Email" required autofocus name="email">
21+
<input type="text" class="form-control reg" placeholder="Email" required autofocus name="email" value="Mr.calebboulio@gmail.com">
2222
<input type="password" class="form-control reg" placeholder="Password" required name="password">
2323
<input type="submit" value="Login" class="btn btn-block reg" style="font-size: 20px;">
2424
<label class="checkbox pull-left">

‎views/devScripts/cdns.ejs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
<script src="../javascripts/file-reader.js"></script>
1414

15-
<script src="https://unpkg.com/truevault@0.3.0/build/index.js"></script>
15+
1616

1717

1818
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.3.7/js/tether.min.js" integrity="sha384-XTs3FgkjiBgo8qjEjBk0tGmf3wPrWtA6coPfQDfFEY8AnYJwjalXCiosYRBIBZX8" crossorigin="anonymous"></script>

0 commit comments

Comments
 (0)
Please sign in to comment.