This file contains 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
// Changes to javascript functions are contained in .js files in the "$sync_path" folder | |
$updjs = []; // each element contains a set of synctactically correct javascript statements | |
$maxtime = $lastupd; // save the most recent update sent | |
// List all .js files updated later than $lastupd"); | |
foreach (scandir($sync_path) as $file) { | |
if (is_dir($file) || pathinfo($file,PATHINFO_EXTENSION)!='js') continue; | |
$filetime = date('Y-m-d H:i:s',filemtime("$sync_path/$file")); | |
if ($filetime>$lastupd) { | |
$updjs[] = file_get_contents("$sync_path/$file"); |
This file contains 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
function findCheapest(orders) { | |
var cheapest = 999999999; | |
for (i=0; i<orders.length; i++) { | |
cheapest = Math.min(cheapest, findCheapestItem(orders[i].items) ); | |
} | |
return cheapest; | |
} | |
function findCheapestItem(items) { | |
var cheapest = 999999999; |
This file contains 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
glob = {}; // global object to keep the initial list of properties | |
glob.before = Object.keys(window); // save all window properties before any script is loaded | |
// showDiff shows (on console.log) the list of "new" properties | |
glob.showDiff = function(before,after) { | |
for (let p in after) { | |
if (before[p] === undefined) { | |
console.log(p,': ', after[p], ' = ', window[p]); | |
} |
This file contains 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
glob = {}; // global object to keep the initial list of properties | |
glob.initial = Object.keys(window); // save all window properties before any script is loaded | |
// showDiff shows (on console.log) the list of "new" properties | |
glob.showDiff = function(before,after) { | |
after.forEach( function(prop) { | |
if (before.indexOf(prop)<0) { | |
console.log(prop,': ', window[prop]); | |
} |
This file contains 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
glob.showDiff(glob.afterLoad, Object.keys(window)); |
This file contains 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
glob.afterLoad = Object.keys(window); | |
glob.showDiff(glob.initial,glob.afterLoad); |
This file contains 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 car = { | |
make: 'Ferrari', | |
model: '812GTS', | |
price: 336000, | |
colour: 'rosso corsa', | |
options: {wheels: 'standard rims', seats: 'Daytona seats', interior: 'charcoals'} | |
}; |
This file contains 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 maxPrice = cars.reduce( (prevPrice, current) => prevPrice < current.price ? current.price : prevPrice, 0); |
This file contains 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 car = cars.reduce( (prev, current) => prev.price<current.price ? current:prev, {price:0}); |
This file contains 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 maxPrice = cars.reduce( (prevPrice, current) => prevPrice < current.price ? current.price : prevPrice, 0); |
OlderNewer