This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
var htmlEscape = function (value) { | |
var d = document.createElement('div'); | |
d.innerText = value; | |
return d.innerHTML; | |
}; | |
var url = 'https://medium.com/me/'; | |
var getDetail = (postId, startDate, callback) => { | |
const payload = [ | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Product Table</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"> | |
<style> | |
#productTable img { | |
max-width: 100px; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// WebComponent image-carousel, a wrapper for glide.js | |
class ImageCarousel extends HTMLElement { | |
constructor() { | |
super(); | |
} | |
connectedCallback() { | |
// Load glide.js once | |
if (typeof Glide === 'undefined') { // "Glide" does not exists | |
if (!window.jsGlide) { // not already running (no other instance of the same WC) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// WebComponent date-picker, a wrapper for js-datepicker | |
class DatePicker extends HTMLElement { | |
constructor() { | |
super(); | |
} | |
connectedCallback() { | |
// Load the js-datepicker once | |
if (typeof datepicker === 'undefined') { // "datepicker" does not exists | |
if (!window.jsDatepicker) { // not already running (no other instance of the same WC) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let newCars = cars2.slice(0).sort( (a,b) => a.price - b.price ) | |
.map( (item,index) => { | |
item.position = index+1; | |
delete item.colour; | |
return item; | |
} | |
); | |
// RESULT IS | |
[ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let commonCars = cars.filter( item => cars2.findIndex( car => car.id == item.id ) >= 0 ); | |
// RESULT IS: | |
[ | |
{id:2,make:"Ferrari",model:"F8 Spider",price:262000,colour:"giallo modena"}, | |
{id:5,make:"McLaren",make:"New GT",price:203000,colour:"helios orange"}, | |
{id:6,make:"Ferrari",model:"F8 Spider",price:262000,colour:"giallo modena"} | |
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let allCars = cars2.reduce( | |
(result,item) => { | |
if ( cars.findIndex( car => car.id == item.id ) < 0) { | |
result.push(item); | |
} | |
return result; | |
}, | |
cars.slice(0) | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let allCars = cars.concat(cars2); | |
let unique = allCars.filter ( (item,index) => index === allCars.findIndex ( car => car.id === item.id) ); | |
// RESULT IS: | |
[ | |
{id:1,make:"Ferrari",model:"812GTS",price:336000,colour:"rosso corsa"}, | |
{id:2,make:"Ferrari",model:"F8 Spider",price:262000,colour:"giallo modena"}, | |
{id:3,make:"Lamborghini",model:"Aventador S",price:329400,colour:"blu le mans"}, | |
{id:4,make:"Bugatti",model:"Chiron Pur Sport",price:3000000,colour:"blue"}, | |
{id:5,make:"McLaren",model:"New GT",price:203000,colour:"helios orange"}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let cars2 = [ | |
{id: 2, make: 'Ferrari', model: 'F8 Spider', price: 262000, colour: 'giallo modena'}, | |
{id: 5, make: 'McLaren', model: 'New GT', price: 203000, colour: 'helios orange'}, | |
{id: 6, make: 'Ferrari', model: 'F8 Spider', price: 262000, colour: 'giallo modena'}, | |
{id: 9, make: 'Lamborghini', model: 'Huracan', price: 206790, colour: 'green'}, | |
{id: 10, make: 'Bugatti', model: 'Chiron Sport 110 ans', price: 16000000, colour: 'dark gray'}, | |
]; |
NewerOlder