Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Insert products</title>
    <!-- Base style -->
    <link rel="stylesheet" href="style.css">
    <!-- Google fonts -->
    <link href="https://fonts.googleapis.com/css?family=PT+Sans:400,400i,700,700i" rel="stylesheet">

    <!-- Favicon -->
    <link rel="icon" href="https://www.inko-versand.de/media/favicon/default/Inko-versand_favicon.png" type="image/x-icon" />
    <link rel="shortcut icon" href="https://www.inko-versand.de/media/favicon/default/Inko-versand_favicon.png" type="image/x-icon" />

    <!-- Icon Monter library CDN -->
    <link rel="stylesheet" type="text/css" href="https://cdn.iconmonstr.com/1.3.0/css/iconmonstr-iconic-font.min.css">

    <!-- jQuery CDN -->
    <script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ=" crossorigin="anonymous"></script>
</head>
<body>
    <div id="root">
        <div class="root-wrapper">

            <header class="crud-header">
                <h1>Insert products</h1>
                <button class="fr addnew" @click="showingModal = true;">Add New</button>
                <div class="clearfix"></div>
            </header>
            
            <hr>
            <p class="error-message" v-if="errorMessage">{{errorMessage}}</p>
            <p class="success-message" v-if="successMessage">{{successMessage}}</p>

            <table class="list">
                <thead>
                    <tr class="toolbar">
                        <th class="sort-by" @click="sort('id')">ID</th>
                        <th class="sort-by" @click="sort('name')">Name</th>
                        <th class="sort-by" @click="sort('pzn')">PZN</th>
                        <th class="sort-by" @click="sort('price')">Price</th>
                        <th>URL</th>
                        <th>Edit</th>
                        <th>Delete</th>
                    </tr>
                </thead>
                <tbody>
                    <tr v-for="product in sortedProducts">
                        <td>{{product.id}}</td>
                        <td>{{product.name}}</td>
                        <td>{{product.pzn}}</td>
                        <td>{{product.price}}</td>
                        <td>{{product.url}}</td>
                        <td><button @click="showingeditModal = true; selectProduct(product)">Edit</button></td>
                        <td><button @click="showingdeleteModal = true; selectProduct(product)">Delete</button></td>
                    </tr>
                </tbody>
            </table>
            <div class="clearfix"></div>

            <!-- Adding new product -->
            <div class="window" id="addwindow" v-if="showingModal">
                <div class="windowheading">
                    <p class="fl">Add new product</p>
                    <p class="fr close" @click="showingModal = false;">x</p>
                    <div class="clearfix"></div>
                </div>
                <div class="windowbody">
                    <div class="windowcontent">
                        <table class="form">
                            <tr>
                                <th>Name :</th>
                                <td><input type="text" placeholder="Name" v-model="newProduct.name"></td>
                            </tr>
                            <tr>
                                <th>PZN :</th>
                                <td><input type="text" placeholder="PZN" v-model="newProduct.pzn"></td>
                            </tr>
                            <tr>
                                <th>Price :</th>
                                <td><input type="text" placeholder="Price" v-model="newProduct.price"></td>
                            </tr>
                            <tr>
                                <th>URL :</th>
                                <td><input type="text" placeholder="URL" v-model="newProduct.url"></td>
                            </tr>
                        </table>
                        <button class="center"  @click="showingModal = false; saveProduct();" >Add Product</button>
                    </div>
                </div>
            </div>


            <!-- Editing product -->
            <div class="window" id="editwindow" v-if="showingeditModal">
                <div class="windowheading">
                    <p class="fl">Edit product</p>
                    <p class="fr close" @click="showingeditModal = false;">x</p>
                    <div class="clearfix"></div>
                </div>
                <div class="windowbody">
                    <div class="windowcontent">
                        <table class="form">
                            <tr>
                                <th>Name :</th>
                                <td><input type="text" placeholder="Name" v-model="clickedProduct.name"></td>
                            </tr>
                            <tr>
                                <th>PZN :</th>
                                <td><input type="text" placeholder="PZN" v-model="clickedProduct.pzn"></td>
                            </tr>
                            <tr>
                                <th>Price :</th>
                                <td><input type="price" placeholder="Price" v-model="clickedProduct.price"></td>
                            </tr>
                            <tr>
                                <th>URL :</th>
                                <td><input type="text" placeholder="URL"  v-model="clickedProduct.url"></td>
                            </tr>
                        </table>
                        <button class="center"  @click="showingeditModal = false; updateProduct()">Update Product</button>
                    </div>
                </div>
            </div>


            <!-- Deleting product -->
            <div class="window" id="deletewindow" v-if="showingdeleteModal">
                <div class="windowheading">
                    <p class="fl">Delete product</p>
                    <p class="fr close" @click="showingdeleteModal = false;">x</p>
                    <div class="clearfix"></div>
                </div>
                <div class="windowbody">
                    <div class="windowcontent">

                        <h3 class="center">Are you sure to Delete?</h3>
                        <h4 class="center">{{clickedProduct.pzn}}</h4>
                        <div class="delete-buttons center">
                            <button class="fl" @click="showingdeleteModal = false; deleteProduct()">YES</button>
                            <button class="fr" @click="showingdeleteModal = false;">NO</button>
                        </div>
                    </div>
                </div>
            </div>
        </div><!-- End: root-wrapper -->
    </div><!-- END: ID root -->
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.min.js"></script>
</body>
</html>
              
            
!

CSS

              
                *{
	box-sizing: border-box;
	margin: 0;
	padding: 0;
}

html,
body {
	min-height: 100%;
}

body {
    color: #152E71;
    font-family: "PT Sans", sans-serif;
    font-size: 16px;
    margin: 0;
    padding-bottom: 60px;
    position: relative;
    text-align: left;
}

hr {
    border: 0;
    border-top: 1px solid #dadada;
    box-sizing: content-box;
    height: 0;
    margin-bottom: 1rem;
    margin-top: 1rem;
    overflow: visible;
}

.fl{
	float: left;
	display: block;
	overflow: hidden;
}

.fr{
	float: right;
}

.clearfix{
	overflow: hidden;
	clear: both;
}

.center {
    text-align: center;
    display: block;
    margin: 0 auto;
}

.close {
	cursor: pointer;
}

h1{
	font-size: 25px;
}

p {
	line-height: normal;
}

button{
	background: #35992d;
	border: 0;
	color: #fff;
	cursor: pointer;
	font-family: inherit;
	line-height: inherit;
	font-size: inherit;
	outline: 0;
	padding: 5px 15px;
}

.button {
	display: inline-block;
	float: right;
	padding: 5px 10px;
	text-decoration: none;
}

/* ########################################################
 ########################## Page css ######################## */

.page-header {
	background-color: #fff;
	display: block;
	position: fixed;
	width: 100%;

}

.button-logout {
	background: grey;
	color: white;
}

p.welcome {
	float: right;
	margin-right: 20px;
	padding: 5px 10px;
}

#root {
    background: #fff;
    height: 100%;
}

.root-wrapper {
	padding: 50px;
}

.crud-header {
    background: #e0e0e0;
    padding: 20px;
}
.crud-header h1 {
    display: inline-block;
}

p.error-message {
    background: #ffbaba;
    padding: 10px;
    border-left: 5px solid #f06179;
}
p.success-message {
    background: #99C039;
    padding: 10px;
    border-left: 5px solid #016633;
}

table.list{
	width:100%;

}
table.list tr {
	margin: 5px!important;
}
table.list th {
    background: #35992d;
    padding: 2px;
    text-align: center;
}
.sort-by {
    cursor: pointer;
    text-decoration: underline;
}
.sort-by:hover {
	background-color: #4FB347;
    color: #4968BC;
    text-decoration: none;
}
table.list tr td{
	padding: 5px 10px;
	background: #edf6e8;
	overflow: hidden;
	text-align: center;
}

.window {
	background: #edf6e8;
	bottom: 0;
	box-shadow: 0 0 130px 28px #00000073;
	display: block;
	height: 300px;
	left:0;
	margin: auto;
	padding: 0;
	position: fixed;
	right:0;
	top: 0;
}
.windowheading{
	background: #fff;
	font-size: 17px;
	line-height: 32px;
	padding: 10px 20px;
	text-align: center;
}
.windowcontent {
    padding: 20px;
}

table.form {
    width: 100%;
}
.form tr{
	margin-bottom: 5px;
	text-align: center;
}
.form th{
	text-align: right;
}
.form td{
	text-align: left;
}
.form td input {
    padding:5px 10px;
}

#addwindow,
#deletewindow,
#editwindow {
	max-width: 50%;
}

.delete-buttons {
	max-width: 50%;
}

.save-file {
	float: left;
}
.save-file input {
	background: #0087E2;
	border: 0;
	color: #fff;
	cursor: pointer;
	display: block;
	font-size: 16px;
	padding: 5px 10px;
}

.goTotop {
    bottom: 5px;
    cursor: pointer;
    opacity: 0;
    position: fixed;
    right: 5px;
    transition: 0.5s;
    visibility: hidden;
    z-index: 11;
}
.goTotop .im {
    color: #808080;
    font-size: 40px;
}

@media screen and (max-width: 760px) {
	html,
	body {
		height: initial;
	}

	.root-wrapper {
		padding: 50px 10px;
	}
}
              
            
!

JS

              
                var app = new Vue({

	el: "#root",
	data: {
		showingModal:false,
		showingeditModal: false,
		showingdeleteModal: false,
		errorMessage : "",
		successMessage : "",
		products: [],
		newProduct: {name: "", pzn: "", price: "", url: ""},
		clickedProduct: {},
		currentSort:'id',
		currentSortDir:'asc'
	},
	mounted: function () {
		console.log("Welcome Dejan");
		this.getAllProducts();
	},
	methods: {
		getAllProducts: function() {
			axios.get("https://www.inko-versand.de/medizinfuchs/api.php?action=read")
			.then(function(response){
				console.log(response);
				if (response.data.error) {
					app.errorMessage = response.data.message;
				}else{
					app.products = response.data.products;
				}
			});
		},
		sort:function(s) {
			//if s == current sort, reverse
			if(s === this.currentSort) {
				this.currentSortDir = this.currentSortDir==='asc'?'desc':'asc';
			}
			this.currentSort = s;
		},
		saveProduct:function() {
			var formData = app.toFormData(app.newProduct);
			axios.post("https://www.inko-versand.de/medizinfuchs/api.php?action=create", formData).then(function(response) {
				console.log(response);
				app.newProduct = {name: "", pzn: "", price: "", url: ""};
				if (response.data.error) {
					app.errorMessage = response.data.message;
				}else{
					app.successMessage = response.data.message;
					app.getAllProducts();
				}
			});
		},
		updateProduct:function() {
			var formData = app.toFormData(app.clickedProduct);
			axios.post("https://www.inko-versand.de/medizinfuchs/api.php?action=update", formData).then(function(response) {
				console.log(response);
				app.clickedProduct = {};
				if (response.data.error) {
					app.errorMessage = response.data.message;
				} else {
					app.successMessage = response.data.message;
					app.getAllProducts();
				}
			});
		},
		deleteProduct:function() {
			var formData = app.toFormData(app.clickedProduct);
			axios.post("https://www.inko-versand.de/medizinfuchs/api.php?action=delete", formData).then(function(response) {
				console.log(response);
				app.clickedProduct = {};
				if (response.data.error) {
					app.errorMessage = response.data.message;
				} else {
					app.successMessage = response.data.message;
					app.getAllProducts();
				}
			});
		},
		selectProduct(product) {
			app.clickedProduct = product;
		},
		toFormData: function(obj) {
			var form_data = new FormData();
		      for ( var key in obj ) {
		          form_data.append(key, obj[key]);
		      } 
		      return form_data;
		},
		clearMessage: function() {
			app.errorMessage = "";
			app.successMessage = "";
		},
	},
  computed:{
		sortedProducts:function() {
			return this.products.sort((a,b) => {
				let modifier = 1;
				if(this.currentSortDir === 'desc') modifier = -1;
				if(a[this.currentSort] < b[this.currentSort]) return -1 * modifier;
				if(a[this.currentSort] > b[this.currentSort]) return 1 * modifier;
				return 0;
			});
		}
	}
});
              
            
!
999px

Console