выдает ошибку не могу понять из за чего
SyntaxError: Unexpected token 'catch' in C:\xampp\htdocs\mysite.local\views\index.ejs while compiling ejs
If the above error is not helpful, you may want to try EJS-Lint: https://github.com/RyanZim/EJS-Lint Or, if you meant to create an async function, pass `async: true` as an option. at new Function (<anonymous>) at Template.compile (C:\xampp\htdocs\mysite.local\node_modules\ejs\lib \ejs.js:661:12) at Object.compile (C:\xampp\htdocs\mysite.local\node_modules\ejs\lib \ejs.js:396:16) at handleCache (C:\xampp\htdocs\mysite.local\node_modules\ejs\lib \ejs.js:233:18) at tryHandleCache (C:\xampp\htdocs\mysite.local\node_modules\ejs\lib \ejs.js:272:16) at View.exports.renderFile [as engine] (C:\xampp\htdocs\mysite.local\node_modules\ejs\lib \ejs.js:489:10) at View.render (C:\xampp\htdocs\mysite.local\node_modules\express \lib\view.js:135:8) at tryRender (C:\xampp\htdocs\mysite.local\node_modules\express \lib\application.js:640:10) at Function.render (C:\xampp\htdocs\mysite.local\node_modules\express \lib\application.js:592:3) at ServerResponse.render (C:\xampp\htdocs\mysite.local\node_modules\express \lib\response.js:1012:7) app.get('/smart', function(req, res) { var order; var side; var prmin; var prmax; if(!order){order='name';} if(!side){side='ASC';} if(order=='price'){ side=req.cookies.sideprice; }else if(order=='popularity'){ side=req.cookies.sidepopularity; }else if(order=='tsale'){ side=req.cookies.side.sidesale; } var query; var smartphopneList=[]; // Connect to MySQL database. var connection = getMySQLConnection(); // Do the query to get data. connection.connect(); quer='SELECT `id`,`prod`,`name`,`description`,`photo`,`price`,`popularity`,`sale`,(`price` -`price` / 100 * `sale`) AS `tsale` FROM `smartphone` ORDER BY `tsale` ASC'; connection.query(quer, function(err, rowes, fields) { // Loop check on each row prmin=rowes[0].tsale; prmax=rowes[(rowes.length-1)].tsale; // Render index.pug page using array }); if(req.cookies.prmin){ prmin=req.cookies.prmin; } if(req.cookies.prmax){ prmax=req.cookies.prmax; } if(!prmin){prmin=7000;} if(!prmax){prmax=20000;} var otherwhere=''; if(req.cookies.vprodaj=='checked'){ otherwhere=otherwhere+' AND WHERE count>0 '; } if(req.cookies.soskidkoi=='checked'){ otherwhere=otherwhere+' AND WHERE (`price` -`price` / 100 * `sale`) >0 '; } if(req.cookies.dbesplat=='checked'){ otherwhere=otherwhere+' AND WHERE `dbesplat`=1 '; } if(req.cookies.promokodi=='checked'){ otherwhere=otherwhere+' AND WHERE `promokodi`=1 '; } if(req.cookies.presents=='checked'){ otherwhere=otherwhere+' AND WHERE `presents`=1 '; } if(req.cookies.newtov=='checked' ){ otherwhere=otherwhere+' AND WHERE `newtov`=1 '; } if(req.cookies.uctov=='checked'){ otherwhere=otherwhere+' AND WHERE `uctov`=1 '; } if(req.cookies.garantprod=='checked'){ otherwhere=otherwhere+' AND WHERE `soskidkoi`>0 '; } if(req.cookies.oswin=='checked'){ otherwhere=otherwhere+' AND WHERE `oswin`=1 '; } if(req.cookies.osios=='checked'){ otherwhere=otherwhere+' AND WHERE `osios`=1 '; } if(req.cookies.osandrod=='checked'){ otherwhere=otherwhere+' AND WHERE `checked`=1 '; } if(!otherwhere){ var where='WHERE (`price` -`price` / 100 * `sale`) >= '+prmin+' AND (`price` -`price` / 100 * `sale`) <= '+prmax; }else{ var where='WHERE (`price` -`price` / 100 * `sale`) >= '+prmin+' AND (`price` -`price` / 100 * `sale`) <= '+prmax +otherwhere; } query='SELECT `id`,`prod`,`name`,`description`,`photo`,`price`,`popularity`,`sale`,`dbesplat`,`promokodi`,`presents`,`newtov`,`garantprod`,(`price` -`price` / 100 * `sale`) AS `tsale` FROM `smartphone` '+where+' ORDER BY '+order +' '+side; connection.query(query, function(err, rows, fields) { if (err) { res.status(500).json({"status_code": 500,"status_message": "internal server error"}); console.log(err); } else { // Loop check on each row var rowlenght=rows.length+1; for (var i = 0; i < rows.length; i++) { // Create an object to save current row's data var smartphopne = { 'id':rows[i].id, 'prod':rows[i].prod, 'name':rows[i].name, 'photo':rows[i].photo, 'description':rows[i].description, 'price':rows[i].price, 'sale':rows[i].sale, 'len':rowlenght, 'tsale':rows[i].tsale, 'prmin':prmin, 'prmax':prmax, 'cprmin':req.cookies.prmin, 'cprmax':req.cookies.prmax, 'vprodaj':req.cookies.vprodaj, 'soskidkoi':req.cookies.soskidkoi, 'dbesplat':req.cookies.dbesplat, 'promokodi':req.cookies.promokodi, 'presents':req.cookies.presents, 'newtov':req.cookies.newtov, 'uctov':req.cookies.uctov, 'garantprod':req.cookies.garantprod, 'oswin':req.cookies.oswin, 'osios':req.cookies.osios, 'osandrod':req.cookies.osandrod, }; // Add object into array smartphopneList.push(smartphopne); } // Render index.pug page using array res.render('index', {"smartphopneList": smartphopneList}); } }); // Close the MySQL connection connection.end(); }); |
<html> <header> <title>Smartphones</title> </header> <body> <table class="index top"> <tr> <td><a href='' style="color:green;margin-left:200px;border:1px solid black;padding:4px;" >Сортировать по: </a><a href="http://localhost:3000/set-cookie/price/" style="color:black;border:1px solid black;padding:4px;border-radius:3px;font-weight:bold;margin-left:5px"> По Цене</a><a href="http://localhost:3000/set-cookie/tsale/" style="color:white;border:1px solid black;background-color:blue;padding:4px;border-radius:3px;font-weight:bold;margin-left:5px"> По Размеру Скидки</a><a href="http://localhost:3000/set-cookie/popularity/" style="color:white;border:1px solid black;background-color:red;padding:4px;border-radius:3px;font-weight:bold;margin-left:5px"> По Популярности </a></td> </tr> </table> <table class="index"> <tr> <td style="width:200px;height:50px;"></td> <td style="width:700px;height:50px;"></td> <td style="width:150px;height:50px;"></td> <td class="rightfacet" rowspan="<%=smartphopneList[0].len;%>" style="height:50px;"> <table class="menu" style="width:350px"> <tr> <td><b>Цена</b></td> <td></td> </tr> <!-----><tr> <td>Мин. <%if(smartphopneList[0]['cprmin']){%> <input class="bradius" id="prmin" type="text" name="prmin" placeholder="" value="<%=smartphopneList[0]['cprmin']%>" onblur="jsprmin()"/> <%}else{%> <input class="bradius" id="prmin" type="text" name="prmin" placeholder="" value="<%=smartphopneList[0]['prmin']%>" onblur="jsprmin()"/> <%}%> </td> <td>Мин. <%if(smartphopneList[0]['cprmax']){%> <input class="bradius" id="prmin" type="text" name="prmin" placeholder="" value="<%=smartphopneList[0]['cprmax']%>" onblur="jsprmin()"/> <%}else{%> <input class="bradius" id="prmin" type="text" name="prmin" placeholder="" value="<%=smartphopneList[0]['prmax']%>" onblur="jsprmin()"/> <%}%> </td>> </tr> <tr> <td style="height:20px"></td> <td></td> </tr> <tr> <td>В продаже <%if(smartphopneList[0]['vprodaj']=='checked'){%> <input type="checkbox" id="vprodaj" onclick="vprodaj()" name="vpr" placeholder="" value="insele" checked/> <%}else{%> <input type="checkbox" id="vprodaj" onclick="vprodaj()" name="vpr" placeholder="" value="insele"/> <%}%> </td> <td></td> </tr> <tr> <td style="height:20px"></td> <td></td> </tr> <tr> <td>Со <%if(smartphopneList[0]['soskidkoi']=='checked'){%> <input type="checkbox" id='soskidkoi' onclick="soskidkoi()" name="ssale" placeholder="" value="widthsale" checked/> <%}else{%> <input type="checkbox" id='soskidkoi' onclick="soskidkoi()" name="ssale" placeholder="" value="widthsale"/> <%}%> </td> <td></td> </tr> <tr> <td style="height:20px"></td> <td></td> </tr> <tr> <td><b>Стоимость доставки</b></td> <td></td> </tr> <tr> <td style="height:20px"></td> <td></td> </tr> <tr> <td>Бесплатно <%if(smartphopneList[0]['dbesplat']=='checked'){%> <input type="checkbox" id="dbesplat" onclick="dbesplat()" name="deliveryfree" placeholder="" value="widthsale" checked/> <%}else{%> <input type="checkbox" id="dbesplat" onclick="dbesplat()" name="deliveryfree" placeholder="" value="widthsale"/> <%}%> </td> <td></td> </tr> <tr> <td style="height:20px"></td> <td></td> </tr> <tr> <td><b>Скидки и акции</b></td> <td></td> </tr> <tr> <td style="height:20px"></td> <td></td> </tr> <tr> <td>Промоколды</td> <td> <%if(smartphopneList[0]['promokodi']=='checked'){%> <input type="checkbox" id="promokodi" onclick="promokodi()" name="deliveryfree" placeholder="" value="widthsale"checked/> <%}else{%> <input type="checkbox" id="promokodi" onclick="promokodi()" name="deliveryfree" placeholder="" value="widthsale"/> <%}%> </td> </tr> <tr> <td>Подарки за покупку</td> <td> <%if(smartphopneList[0]['presents']=='checked'){%> <input type="checkbox" name="deliveryfree" id="presents" onclick="presents()" placeholder="" value="widthsale" checked/> <%}else{%> <input type="checkbox" name="deliveryfree" id="presents" onclick="presents()" placeholder="" value="widthsale"/> <%}%> </td> </tr> <tr> <td style="height:20px"></td> <td></td> </tr> <tr> <td><b>Состояни товара</b></td> <td></td> </tr> <tr> <td style="height:20px"></td> <td></td> </tr> <tr> <td>Новый</td> <td> <%if(smartphopneList[0]['newtov']=='checked'){%> <input type="checkbox" id="newtov" onclick="newtov()" name="deliveryfree" placeholder="" value="widthsale" checked/> <%}else{%> <input type="checkbox" id="newtov" onclick="newtov()" name="deliveryfree" placeholder="" value="widthsale"/> <%}%> </td> </tr> <tr> <td>Уцененный</td> <td> <%if(smartphopneList[0]['uctov']=='checked'){%> <input type="checkbox" id="uctov" onclick="uctocv()" name="deliveryfree" placeholder="" value="widthsale" checked/> <%}else{%> <input type="checkbox" id="uctov" onclick="uctocv()" name="deliveryfree" placeholder="" value="widthsale"/> <%}%> </td> </tr> <tr> <td style="height:20px"></td> <td></td> </tr> <tr> <td><b>Гарантия производителя</b></td> <td> <%if(smartphopneList[0]['garantprod']=='checked'){%> <input type="checkbox" id="garantprod" onclick="garantov()" name="deliveryfree" placeholder="" value="widthsale" checked/> <%}else{%> <input type="checkbox" id="garantprod" onclick="garantov()" name="deliveryfree" placeholder="" value="widthsale"/> <%}%> </td> </tr> <tr> <td style="height:20px"></td> <td></td> </tr> <tr> <td><b>Операционная система</b></td> <td></td> </tr> <tr> <td style="height:20px"></td> <td></td> </tr> <tr> <td>Windows</td> <td> <%if(smartphopneList[0]['oswin']=='checked'){%> <input type="checkbox" id="oswin" onclick="oswin()" name="deliveryfree" placeholder="" value="widthsale" checked/> <%}else{%> <input type="checkbox" id="oswin" onclick="oswin()" name="deliveryfree" placeholder="" value="widthsale"/> <%%}> </td> </tr> <tr> <td>IOS</td> <td> <%if(smartphopneList[0]['osios']=='checked'){%> <input type="checkbox" id="osios" onclick="osios()" name="deliveryfree" placeholder="" value="widthsale" checked/> <%}else{%> <input type="checkbox" id="osios" onclick="osios()" name="deliveryfree" placeholder="" value="widthsale" /> <%}%> </td> </tr> <tr> <td>Android</td> <td> <%if(smartphopneList[0]['osandroid']=='checked'){%> <input type="checkbox" id="osandroid" onclick="osandroid()" name="deliveryfree" placeholder="" value="widthsale" checked/> <%}else{%> <input type="checkbox" id="osandroid" onclick="osandroid()" name="deliveryfree" placeholder="" value="widthsale"/> <%}%> </td> </tr> </table> </td> <% for(var i=0;i<smartphopneList.length;i++){ %> <tr> <td class="leftitem" style="padding:10px;border-left:1px solid silver;border-top:1px solid silver;border-bottom:1px solid silver;"> <img class="imgind" style="height:200px;width:200px"src="<%= smartphopneList[i]['photo'];%>"> <p> Производитель: <%= smartphopneList[i]['prod'];%><br> Модель: <%= smartphopneList[i]['name'];%><br> Цена: <%= smartphopneList[i]['price'];%><br> Цена со скидкой: <%= smartphopneList[i]['tsale'];%> </p> </td> <td class="rightitem" style="border-top:1px solid silver;border-bottom:1px solid silver;"> <%= smartphopneList[i]['description'];%> </td> <td style="text-align:center;border-right:1px solid silver;border-top:1px solid silver;border-bottom:1px solid silver;"> <p><a href="/somesmart/<%= smartphopneList[i]['id'];%>" style="color:white;background-color:orange;padding:4px;border-radius:3px;font-weight:bold;">Подробнее</a></p> <p><a href="/basket/<%= smartphopneList[i]['id'];%>" style="color:white;background-color:green;padding:4px;border-radius:3px;font-weight:bold;">В Корзину</a></p> </td> </tr> <%}%> </tr> </table> </body> </html> <script> function jsprmin(){ var a=document.getElementById("prmin").value; document.location.href = "http://localhost:3000/set-menu-cookie/prmin/"+a+"/"; } function jsprmax(){ var a=document.getElementById("prmax").value; document.location.href = "http://localhost:3000/set-menu-cookie/prmax/"+a+"/"; } function vprodaj(){ if (document.getElementById("vprodaj").checked) { document.location.href = "http://localhost:3000/set-menu-cookie |
/vprodaj/checked/"; }else{ document.location.href = "http://localhost:3000/set-menu-cookie/vprodaj/unchecked/"; } } function soskidkoi(){ if (document.getElementById("soskidkoi").checked) { document.location.href = "http://localhost:3000/set-menu-cookie/soskidkoi/checked/"; }else{ document.location.href = "http://localhost:3000/set-menu-cookie/soskidkoi/unchecked/"; } } function akcii(){ if (document.getElementById("skidki").checked) { document.location.href = "http://localhost:3000/set-menu-cookie/akcii/checked/"; }else{ document.location.href = "http://localhost:3000/set-menu-cookie/akcii/unchecked/"; } } function promokodi(){ if (document.getElementById("promokodi").checked) { document.location.href = "http://localhost:3000/set-menu-cookie/promokodi/checked/"; }else{ document.location.href = "http://localhost:3000/set-menu-cookie/promokodi/unchecked/"; } } function presents(){ if (document.getElementById("presents").checked) { document.location.href = "http://localhost:3000/set-menu-cookie/presents/checked/"; }else{ document.location.href = "http://localhost:3000/set-menu-cookie/presents/unchecked/"; } } function newtov(){ if (document.getElementById("newtov").checked) { document.location.href = "http://localhost:3000/set-menu-cookie/newtov/checked/"; }else{ document.location.href = "http://localhost:3000/set-menu-cookie/newtov/unchecked/"; } } function uctov(){ if (document.getElementById("uctov").checked) { document.location.href = "http://localhost:3000/set-menu-cookie/uctov/checked/"; }else{ document.location.href = "http://localhost:3000/set-menu-cookie/uctov/unchecked/"; } } function garantprod(){ if (document.getElementById("garantprod").checked) { document.location.href = "http://localhost:3000/set-menu-cookie/garantprod/checked/"; }else{ document.location.href = "http://localhost:3000/set-menu-cookie/garantprod/unchecked/"; } } function oswin(){ if (document.getElementById("garantprod").checked) { document.location.href = "http://localhost:3000/set-menu-cookie/oswin/checked/"; }else{ document.location.href = "http://localhost:3000/set-menu-cookie/oswin/unchecked/"; } } function osios(){ if (document.getElementById("osios").checked) { document.location.href = "http://localhost:3000/set-menu-cookie/osios/checked/"; }else{ document.location.href = "http://localhost:3000/set-menu-cookie/osios/unchecked/"; } } function osandroid(){ if (document.getElementById("garantprod").checked) { document.location.href = "http://localhost:3000/set-menu-cookie/osandroid/checked/"; }else{ document.location.href = "http://localhost:3000/set-menu-cookie/osandroid/unchecked/"; } } </script> |
у меня некликабельная
|
Часовой пояс GMT +3, время: 22:24. |