Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/sevenval/odl-thek
Browse files Browse the repository at this point in the history
Conflicts:
	routes/gadgets.js
	routes/index.js
  • Loading branch information
mmeyer1978 committed May 25, 2014
2 parents 1e45115 + 3fb7d77 commit ef35e3d
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 72 deletions.
4 changes: 2 additions & 2 deletions routes/gadgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var router = express.Router();


router.get('/', helper.ensureAuthenticated, function(req, res) {
var find = { type : "mobile" };
var find = { };
if(req.query.q) {
find.name = {$regex : ".*"+req.query.q+".*", $options: 'i'};
}
Expand Down Expand Up @@ -39,7 +39,7 @@ router.get('/', helper.ensureAuthenticated, function(req, res) {
res.render('gadgets/list', { title: 'ODL: gadgets', gadgets : _result});
})
} else {
res.render('index', { title: 'ODL: gadgets' });
res.render('gadgets/list', { title: 'ODL: gadgets' });
}
})
});
Expand Down
9 changes: 5 additions & 4 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ var count = helper.db.collection('count');
var router = express.Router();

router.get('/', function(req, res) {
gadgets.find({ type : "mobile" }).sort({brand:1}).limit(12).toArray(function(_err,_result){
gadgets.find({ }).sort({brand:1}).toArray(function(_err,_result){
if(_result&&_result!=undefined&&_result.length) {
console.log(_result[0]);
res.render('index', { title: 'ODL: welcome', gadgets : _result });
var length = _result.length;
_result = _result.slice(3,15);
res.render('index', { title: 'ODL: welcome', gadgets : _result , devices : length});
} else {
// res.render('index', { title: 'No devices' });
res.render('index', { title: 'ODL: welcome', gadgets : _result });
res.render('index', { title: 'ODL: welcome', gadgets : _result , devices : 0 });
}
})
});
Expand Down
131 changes: 67 additions & 64 deletions views/gadgets/list.jade
Original file line number Diff line number Diff line change
Expand Up @@ -17,71 +17,74 @@ block content
img(src='/img/add_btn.gif')
.clear
#phones
h1 Smartphones
ul.elements
- each gadget in gadgets
li.element(onmouseover="$(this).find('.hide').show();$(this).find('.cont').hide();",onmouseout="$(this).find('.hide').hide();$(this).find('.cont').show();")
.hide.info
if(gadget.bookings&&gadget.bookings.current&&gadget.bookings.current.status == "handout")
div.traffic_handout
else if(gadget.bookings&&gadget.bookings.current)
div.traffic_reserved
else
div.traffic
.hide.info.grey
.click
div.brand= gadget.brand
div.name= gadget.name
span.isolator
div.os= gadget.os
div.lastBook
if(gadget.bookings&&gadget.bookings.current&&gadget.bookings.current.username)
if(gadget.bookings.current.status=='handout')
span current
else
span reserved
br
span.user= gadget.bookings.current.username
if(!gadgets)
h1 no gadgets for your search
else
h1= gadgets.length+" gadgets"
ul.elements
- each gadget in gadgets
li.element(onmouseover="$(this).find('.hide').show();$(this).find('.cont').hide();",onmouseout="$(this).find('.hide').hide();$(this).find('.cont').show();")
.hide.info
if(gadget.bookings&&gadget.bookings.current&&gadget.bookings.current.status == "handout")
div.traffic_handout
else if(gadget.bookings&&gadget.bookings.current)
div.traffic_reserved
else
if(gadget.bookings&&gadget.bookings.last&&gadget.bookings.last.username)
span last booking
div.traffic
.hide.info.grey
.click
div.brand= gadget.brand
div.name= gadget.name
span.isolator
div.os= gadget.os
div.lastBook
if(gadget.bookings&&gadget.bookings.current&&gadget.bookings.current.username)
if(gadget.bookings.current.status=='handout')
span current
else
span reserved
br
span.user= gadget.bookings.last.username
span.user= gadget.bookings.current.username
else
if(gadget.bookings&&gadget.bookings.last&&gadget.bookings.last.username)
span last booking
br
span.user= gadget.bookings.last.username

if(gadget.bookings&&gadget.bookings.current&&gadget.bookings.current.status == "handout")
div.buttons_handout
.detail
a(href="/gadgets/"+gadget._id) Details
.booking
a(onclick="openBookingLayer('/bookings/"+gadget._id+"/new')") Book
else if(gadget.bookings&&gadget.bookings.current)
div.buttons_reserved
.detail
a(href="/gadgets/"+gadget._id) Details
.booking
a(onclick="openBookingLayer('/bookings/"+gadget._id+"/new')") Book
else
div.buttons
.detail
a(href="/gadgets/"+gadget._id) Details
.booking
a(onclick="openBookingLayer('/bookings/"+gadget._id+"/new')") Book
.cont
if(gadget.image)
img(src="/"+gadget.image)
else
img(src='/img/dummy_device.gif')
if(gadget.bookings&&gadget.bookings.current&&gadget.bookings.current.status == "handout")
div.traffic_handout.smallline
else if(gadget.bookings&&gadget.bookings.current)
div.traffic_reserved.smallline
else
div.traffic.smallline
.click
div.spec

div.brand= gadget.brand
div.name= gadget.name
span.isolator
div.os= gadget.os
if(gadget.bookings&&gadget.bookings.current&&gadget.bookings.current.status == "handout")
div.buttons_handout
.detail
a(href="/gadgets/"+gadget._id) Details
.booking
a(onclick="openBookingLayer('/bookings/"+gadget._id+"/new')") Book
else if(gadget.bookings&&gadget.bookings.current)
div.buttons_reserved
.detail
a(href="/gadgets/"+gadget._id) Details
.booking
a(onclick="openBookingLayer('/bookings/"+gadget._id+"/new')") Book
else
div.buttons
.detail
a(href="/gadgets/"+gadget._id) Details
.booking
a(onclick="openBookingLayer('/bookings/"+gadget._id+"/new')") Book
.cont
if(gadget.image)
img(src="/"+gadget.image)
else
img(src='/img/dummy_device.gif')
if(gadget.bookings&&gadget.bookings.current&&gadget.bookings.current.status == "handout")
div.traffic_handout.smallline
else if(gadget.bookings&&gadget.bookings.current)
div.traffic_reserved.smallline
else
div.traffic.smallline
.click
div.spec
div.brand= gadget.brand
div.name= gadget.name
span.isolator
div.os= gadget.os
div.clear
4 changes: 2 additions & 2 deletions views/index.jade
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ block content
div.welcome
div.introduction Welcome to ODL
span THEK
div.introductionText Login with your GitHub account to rent a device
div.introductionText Login with your GitHub account to rent one of our #{devices} devices
if(!locals.user)
br
div(style="text-align: center;")
a(href="/users/auth/github",class="loginbutton") login
h1 Smartphones
h1 Top Devices
ul.elements
- each gadget in gadgets
li.element
Expand Down

0 comments on commit ef35e3d

Please sign in to comment.