if (color === 'RANDOM') return Math.floor(Math.random() * (0xffffff + 1)); if (color === 'DEFAULT') return 0; color = Colors[color] || parseInt(color.replace('#', ''), 16); } else if (Array.isArray(color)) { color = (color[0] << 16) + (color[1] << 8) + color[2];
/** * Register a prefix override for a specific guild * @arg {String} guildID The ID of the guild to override prefixes for * @arg {String | Array} prefix The bot prefix. Can be either an array of prefixes or a single prefix. "@mention" will be automatically replaced with the bot's actual mention */ registerGuildPrefix(guildID, prefix) { if(!this.preReady) { this.guildPrefixes[guildID] = prefix; } else if(Array.isArray(prefix)) { for(let i = 0; i < prefix.length; ++i) { prefix[i] = prefix[i].replace(/@mention/g, this.user.mention); } this.guildPrefixes[guildID] = prefix; } else { this.guildPrefixes[guildID] = prefix.replace(/@mention/g, this.user.mention); } }
const normalizeJestValidate = function (message) { const messageA = normalizeMessage(message, { colors: false }) const messageB = messageA.replace(EXAMPLE_REGEXP, '') return messageB }
const parseRating = (rating) => { let rounded_rating = Math.round(rating/10); let stars = ['☆','☆','☆','☆','☆'] for(let i = 0; i < rounded_rating; i++) { stars.splice(i, 1); stars.unshift('★'); } stars = stars.toString(); stars = stars.replace(/,/g, ''); return { __html: stars }; }
// number of numbers to get @action getManyDataItems() { // go ask for a bunch of random numbers this.numberList.replace(); // empty the list for (var ctr = 0; ctr < this.listSize; ctr++){ // count to goal this.numberList.push(-1); // make the array the right size setTimeout( this.getRandomForIndex.bind(this,ctr) , // call a service 200+Math.random()*3000 ); // after a random wait } }
export function uniq(first, second) { let ret = []; const collection = first.concat(second); collection.forEach((k) => { var found = ret.findIndex((item) => item.id === k.id); if (found === -1) { ret.push(k); }else{ ret.replace(found, 1, k); } }); return ret; }
@action loadBooks() { this.pendingRequests++; Api.books.all().then(books => { runInAction('loadBooksSuccess', () => { this.books.replace(books); this.pendingRequests--; }); }).catch(e => { runInAction('loadBooksError', () => { this.pendingRequests--; }); return Promise.reject(e); }); }
account (type) { const resource = this.params.resource; const user = resource.replace(/^acct:/, '').split('@')[0]; const origin = this.getOrigin(); const response = { 'links': [ { 'rel': 'remoteStorage', 'api': 'simple', 'auth': origin + '/oauth/' + user, 'template': origin + '/storage/' + user + '/{category}' } ] }; if (type === 'xrd') { this.renderXRD('account.xml', response); } else { this.renderJSON(response, 'jrd+json'); } }
$(document).on('blur input keyup', '#server-list input[type=number], #bouyomi_port', function() { const val = $(this).val(); const valRep = val.replace(/[^0-9]/g, ''); if (valRep === '' || 0 <= Number(valRep) && Number(valRep) < 65536) { $(this).val(valRep); } else { const valSet = (function() { if (Number(valRep) > 65536) return '65535'; return '0'; })(); $(this).val(valSet); if ($('.toast-serverinput').length) return; spawnNotification({ html: '0~65535の値で設定してください', classes: 'toast-serverinput' }); } });
// NGユーザー・ログの数 入力制限(数字以外を削除) $(document).on('blur input keyup', '#blacklist input, #whitelist input, #log_num', function() { const val = $(this).val(); $(this).val(val.replace(/[^0-9]/g, '')); });
// NGユーザー・ログの数 入力制限(数字以外を削除) $(document).on('blur input keyup', '#blacklist input, #whitelist input, #log_num', function() { const val = $(this).val(); $(this).val(val.replace(/[^0-9]/g, '')); });
$(document).on('blur input keyup', '#server-list input[type=number], #bouyomi_port', function() { const val = $(this).val(); const valRep = val.replace(/[^0-9]/g, ''); if (valRep === '' || 0 <= Number(valRep) && Number(valRep) < 65536) { $(this).val(valRep); } else { const valSet = (function() { if (Number(valRep) > 65536) return '65535'; return '0'; })(); $(this).val(valSet); if ($('.toast-serverinput').length) return; spawnNotification({ html: '0~65535の値で設定してください', classes: 'toast-serverinput' }); } });