/**
* Stringify a JSON object
* @param {*} value JSON value to stringify
* @returns {string} stringify JSON
*/
function stringify(value) {
var result = {};
try {
result = JSON.stringify(value);
} catch (e) {
Logger.error('Error while trying to stringify ' + e);
result = JSON.stringify(result);
}
return result;
}
Stringify a JSON object
// What they did:
var serverCommands = {};
for(var each in commandList.general)
(dmCommands[commandList.general[each].type] ? dmCommands[commandList.general[each].type] +=
(config.prefix + each + (commandList.general[each].args ? ' ' + commandList.general[each].args : '') +
': ' + commandList.general[each].description + '\n') : (dmCommands[commandList.general[each].type] =
'\u200B'+ config.prefix + each + (commandList.general[each].args ? ' ' + commandList.general[each].args : '') +
': ' + commandList.general[each].description + '\n'))
// What they should've done:
let srvrCmds = new Map();
let gldCmds = commandList[message.guild.id];
for (let each in gldCmds) {
const cur = gldCmds[each];
const text = `${config.prefix + each + (cur.args ? " " + cur.args : "")}: ${cur.description}\n`;
const srvrCmdType = srvrCmds.get(cur.type);
srvrCmds.set(cur.type, (srvrCmdType || "\u200B") + text);
}
<div class="scrollContent">
{foreach $animations as $index => $a}
{if $index > 2}
{if $a.filename == '9_1447691013_3726.png'}
{else}
{if $a.filename == '9_1423150010_6441.png'}
{else}
{if $a.filename == '9_1423149959_5909.png'}
{else}
{if $a.filename == '9_1423149908_5874.png'}
{else}
{if $a.filename == '9_1528213223_6374.jpg'}
{else}
{if $a.filename == '9_1527670984_3732.jpg'}
{else}
<div class="spotlightFrame frame{$index+1} contains1" data-index="{$index}">
{if $a.link}<a href="{$a.link}">{/if}
<img src="/upload/{$a.filename}" alt="{$a.title}" />
{if $a.link}</a>{/if}
</div>
{/if}
{/if}
{/if}
{/if}
{/if}
{/if}
{/if}
{/foreach}
</div>
Handovers are great.
$(document).on('click', '.edit-item', function(event) {
let row_id = event.currentTarget.attributes['data-row'].value,
data = dataIndex[
dataIndex.findIndex(i => i.id === Number(row_id))
];
$('.modal-body div:nth-child(1) input').attr('value', data.name)
$('.modal-body div:nth-child(2) input').attr('value', data.category)
$('.modal-body div:nth-child(3) #basicSelect').val(data.status)
$('.modal-body div:nth-child(4) input').attr('value', data.price)
$('.modal-body div:nth-child(5) input').attr('value', data.bju.mass)
$('.modal-body div:nth-child(6) input').attr('value', data.bju.calories)
$('.modal-body div:nth-child(7) input').attr('value', data.bju.proteins)
$('.modal-body div:nth-child(8) input').attr('value', data.bju.fats)
$('.modal-body div:nth-child(9) input').attr('value', data.bju.carbohydrates)
}
)
roots.push(resolver(Config.root, `${pageDir}${path.sep}${page}${path.sep}${page}.html`));
class FileReader extends EventTarget(...READER_EVENTS) {
// [...]
readAsArrayBuffer() {
throw new Error('FileReader.readAsArrayBuffer is not implemented');
}
}
React Native's way of saying they don't support FileReader.readAsArrayBuffer()
for (const order of orders) {
for (const resultItem of results) {
if (resultItem.machine != "TRANSFER") {
shiftsLoop: for (const shift of resultItem.shifts) {
if (shift.products) {
for (const product of shift.products) {
if (product.product == order.product) {
for (const routing of routings) {
if (routing.output == order.product) {
const machinePlant = findMachinePlant(resultItem.machine, machines)
if (routing.type == "ODP") {
if (machinePlant == order.plant) {
const msg = createMessage(order, shift, resultItem.machine, CHOR)
requests.push(buildRequest(msg))
} else {
//CHEE CHIE CHEI
}
break shiftsLoop
} else if (routing.type == "OCL" || routing.type == "RCL") {
const msg = createMessage(order, shift, resultItem.machine, CHCL)
requests.push(buildRequest(msg))
//CHCL
}
}
}
}
}
}
}
}
}
this.props.HeaderStore.setHeader(true, null, false, false, true, true,'dashboardNavigation');
if (cookiesBannerHeight !== 0 && isMobile) {
style = {
top: cookiesBannerHeight === 0 ? 0 : cookiesBannerHeight
}
}
// powtierdzenie decyzji
function zapytaj(pytanie){
if(confirm(pytanie)) return true
else return false;
}
scrollToEl($el.parent().parent().parent());
Someones idea of how to select an element to scroll to.... Please no.
const setFormFlag(state){
state.formFlag ? state.formFlag = false : state.formFlag = true;
}
pageEndReached() {
if (!this.endOfResults) {
//load more pages
this.page++;
this.getPosts();
followerCount: null,
postCount: null,
measurementKeys: ["a", "b", "c", "d", "e"],
showDrafts: false,
};
},
nani
if(typeof(sortOrder) != "boolean"){
return items;
}
filtered.sort(function (a, b) {
if(sortOrder == true){
return (CustomOrder(a.status) > CustomOrder(b.status) ? 1 : -1);
}
else if(sortOrder == false){
return (CustomOrder(a.status) < CustomOrder(b.status) ? 1 : -1);
}
});
The status
property is a string ("Started", "Running", "Failed", "Finished", etc.), and CustomOrder
is a function with a switch that just returns a predefined integer for each string. I switched CustomOrder to just be a simple lookup table object, and the sort call was changed to filtered.sort((a, b) => CustomOrder[a.status] - CustomOrder[b.status]);
let already_in = True;
while (already_in) {
let random_index = Math.floor(arr.length * Math.random());
let already_in = False;
for (ex of exs) {
if (ex.id === arr[random_index].id) {
already_in = True;
}
}
}
Yes, this is JavaScript, and yes it didn't work. Found while reviewing some code