Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html>
<head>
<title><%= title %></title>
<link rel='stylesheet' href='/stylesheets/style.css' />
<link rel="stylesheet" href="/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="/components-font-awesome/css/font-awesome.min.css">
<script src="/jquery/dist/jquery.min.js"></script>
<script src="/bootstrap/dist/js/bootstrap.min.js"></script>
</head>
<html>
<%- include ../partials/head.ejs %>
<body>
<div class="container">
<%- include menu.ejs %>
<div class="row">
<div class="col-sm-12">
<div class="row" style="background: gray; padding: 8px 0; margin: 8px 0;">
<div class="col-sm-3">Photo</div>
<div class="col-sm-2">Name</div>
<html>
<%- include ../partials/head.ejs %>
<body>
<div class="container">
<%- include menu.ejs %>
<div class="row well" style="margin-top: 8px;">
<% if (typeof error !== 'undefined') { %>
<div class="col-sm-12">
<div class="label label-danger">
<%- error.message %>
<% items.forEach(function(item) { %>
<tr>
<td width="200px">
<% if(item.photo) { %>
<img src="/photo/<%- item.photo %>" style="width: 100%; max-height: 100px;">
<% } else { %>
<img src="/img/default.jpg" style="width: 100%; max-height: 100px;">
<% } %>
<input type="file" name="photo">
</td>
<script>
$(document).ready(function () {
var actionForm = $('#actionForm');
var deleteBtn = $('.btn.delete');
var updateBtn = $('.btn.update');
deleteBtn.click(function () {
if (!confirm("are you sure?")) {
return false;
}
<form method="post" action="/admin/item" enctype="multipart/form-data">
<div class="form-group">
<label>種類</label>
<select class="form-control" name="type"> 
<option>特餐</option>
<option>飯類</option>
<option>麵食</option>
<option>水餃</option>
<option>炸物</option>
<option>湯類</option>
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
module.exports = {
name: 'Item',
schema: new Schema({
type: String,
name: String,
price: {
big: Number,
router.post('/update/:id', upload.single('photo'), function (req, res, next) {
var id = req.params.id;
var file = req.file;
var data = req.body;
data.price = {
small: data.priceSmall,
big: data.priceBig
};
$(document).ready(function () {
var vieClick = $('#vieClick');
var account = $('#account');
var password = $('#password');
//var accountFile = $('#account').val(); //放外面,裡面的account:accountFile吃不到
//var passwordFile = $('#password').val(); //同上
//所以要放裡面
vieClick.click(function () {
$(document).ready(function () {
var vieClick = $('#vieClick');
var account = $('#account');
var password = $('#password');
var accountFile = $('#account').val();
var passwordFile = $('#password').val();
vieClick.click(function () {