Skip to content

Instantly share code, notes, and snippets.

Avatar

mohammad-hammal mohammad-hammal

View GitHub Profile
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
<link rel="stylesheet" href="css/style.css">
<title>Calculator</title>
</head>
View webpack.config.js
var path = require('path');
module.exports = {
entry: "./js/index.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: "bundle.js"
}
};
View index.js
var age = calculator.getAge(dateValue);
View index.js
var $ = require('jquery');
var calculator = require('./calculator');
$(function(){
$('form').on('submit', function(event) {
event.preventDefault();
var dateValue = $('.date-input').val();
if (!dateValue) {
alert('Please enter valid value');
return;
View calculator.js
var moment = require('moment');
exports.getAge = function (date) {
return moment().diff(date, 'years');
}
View index.js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
<link rel="stylesheet" href="css/style.css">
<title>Calculator</title>
</head>
View index.js
$(function(){
$('form').on('submit', function(event) {
event.preventDefault();
var dateValue = $('.date-input').val();
if (!dateValue) {
alert('Please enter valid value');
return;
}
var age = moment().diff(dateValue, 'years');
alert(age);
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="https://fonts.googleapis.com/css?family=Lato" rel="stylesheet">
<link rel="stylesheet" href="css/style.css">
<title>Calculator</title>
</head>
View index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<script src="path/to/file1"></script>
You can’t perform that action at this time.