Skip to content
This repository has been archived by the owner on Jul 8, 2023. It is now read-only.

Commit

Permalink
eslint: prefer-arrow-callback
Browse files Browse the repository at this point in the history
  • Loading branch information
standy committed Feb 19, 2017
1 parent 82d6f29 commit 8c8b4b5
Show file tree
Hide file tree
Showing 28 changed files with 67 additions and 70 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
},
"rules": {
"comma-dangle": ["error", "always-multiline"],
"prefer-arrow-callback": "error",
"prefer-const": "error",
"no-var": "error",
"camelcase": "off",
Expand Down
8 changes: 4 additions & 4 deletions source/js/auto/initAuto.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import {subscribe} from '../utils/pubsub';
import {checkHero} from './checkHero';
import {checkQuest} from './checkQuest';

subscribe('newTurn', function(messagesNew, gameData) {
window.setTimeout(function() {
subscribe('newTurn', (messagesNew, gameData) => {
window.setTimeout(() => {
checkHero(gameData);
}, 1000);
});

subscribe('newMessages', function(messagesNew, gameData) {
window.setTimeout(function() {
subscribe('newMessages', (messagesNew, gameData) => {
window.setTimeout(() => {
checkQuest(gameData);
}, 1000);
});
4 changes: 1 addition & 3 deletions source/js/draw/archive/addArchiveGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ export function addArchiveGroup(group) {
}
if (!isInArr) {
archiveGroups.push(archiveGroup);
archiveGroups.sort(function(a, b) {
return a.ts[0] - b.ts[0];
});
archiveGroups.sort((a, b) => a.ts[0] - b.ts[0]);
// console.log('add to millde', archiveGroup);
}
}
Expand Down
10 changes: 5 additions & 5 deletions source/js/draw/archive/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {messagesGrouped} from '../group/messagesGrouped';
* */


subscribe('init', function() {
subscribe('init', () => {
loadArchiveGroups();
for (let i = 1; i < messagesGrouped.length; i++) {
const gr = messagesGrouped[i];
Expand All @@ -26,11 +26,11 @@ subscribe('init', function() {
saveArchiveGroups();


subscribe('newMessages', function() {
subscribe('newMessages', () => {
const group = messagesGrouped[messagesGrouped.length - 1];
addArchiveGroup(group);
});
subscribe('groupFinished', function(group, index) {
subscribe('groupFinished', (group, index) => {
addArchiveGroup(group);
saveArchiveGroups();
});
Expand All @@ -42,8 +42,8 @@ elements.getTabInner('archive').on('click', '.group-title', function() {
console.log('archive>', archiveGroups[index], index, new Date(ts[0] * 1000));
});

subscribe('newTurn', function(messagesNew) {
window.setTimeout(function() {
subscribe('newTurn', messagesNew => {
window.setTimeout(() => {
elements.getControl('archive-log')
.find('.value').text(archiveGroups.length);
}, 10);
Expand Down
4 changes: 2 additions & 2 deletions source/js/draw/archive/initArchiveGroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ export function initArchiveGroups() {
const $archiveTab = elements.getTab('archive').toggle(showArchive);

$('<span class="link-ajax archive-renew">обновить</span>').appendTo($archiveTabContent)
.on('click', function() {
.on('click', () => {
drawArchiveGroups(archiveGroups);
});

$archiveContent.on('click', '.group-toggle', function() {
$(this).closest('.group').toggleClass('open');
});

subscribe('settingsChange', function(key, value) {
subscribe('settingsChange', (key, value) => {
if (key === 'showArchive') {
showArchive = value;
$archiveTab.toggle(showArchive);
Expand Down
4 changes: 1 addition & 3 deletions source/js/draw/archive/loadArchiveGroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import log from '../../utils/log';

export function loadArchiveGroups() {
const _archiveGroups = log.get('archiveGroups') || [];
_archiveGroups.sort(function(a, b) {
return a.ts[0] - b.ts[0];
});
_archiveGroups.sort((a, b) => a.ts[0] - b.ts[0]);
for (let i = 0; i < _archiveGroups.length - 1; i++) { /* remove doubles */
if (_archiveGroups[i].ts[0] === _archiveGroups[i + 1].ts[0]) {
_archiveGroups.splice(i, 1);
Expand Down
6 changes: 3 additions & 3 deletions source/js/draw/archive/upgradeArchiveGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function upgradeArchiveGroup(archiveGroup, index) {
sum = 0;
} else {
count = vals.length;
sum = vals.reduce(function(pv, cv) { return pv + cv; }, 0) || 0;
sum = vals.reduce((pv, cv) => pv + cv, 0) || 0;
}

let av;
Expand All @@ -45,12 +45,12 @@ export function upgradeArchiveGroup(archiveGroup, index) {
if (type === 'hit' && sum) {
av = sum / count;
critMin = av * 1.35;
critVals = vals.filter(function(item) { return item > critMin; });
critVals = vals.filter(item => item > critMin);
critCount = critVals.length;
}
if (critCount) {
addTo.crit = addTo.crit || {sum: 0, count: 0};
const critSum = critVals.reduce(function(pv, cv) { return pv + cv; }, 0) || 0;
const critSum = critVals.reduce((pv, cv) => pv + cv, 0) || 0;
addTo.crit.count += critCount;
addTo.crit.sum += critSum;
}
Expand Down
6 changes: 3 additions & 3 deletions source/js/draw/group/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ import {subscribe} from '../../utils/pubsub';
import {settingsValues} from '../../settings/settings';
import {messagesLog} from '../../trace/messagesLog';

subscribe('init', function() {
subscribe('init', () => {
addMessages(messagesLog);
drawMessages(messagesGrouped);
// subscribe('groupFinished', function(group, index) {
// redrawGroup(index);
// });
subscribe('groupStarted', function(group, index) {
subscribe('groupStarted', (group, index) => {
redrawGroup(index - 1);
});
subscribe('newTurn', function(messagesNew) {
subscribe('newTurn', messagesNew => {
addMessages(messagesNew);
redrawGroup(messagesGrouped.length - 1);
});
Expand Down
6 changes: 3 additions & 3 deletions source/js/draw/stats/drawStatsSide.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export function drawStatsSide(archiveGroups) {
const type = types[0];
htmlTime +=
'<span class="action-icon ' + (act.countType || type) + '" ' +
'title="' + types.map(function(item) { return CONST.ACTION_TYPE_TEXTS[item]; }).join(', ') + '">' +
'title="' + types.map(item => CONST.ACTION_TYPE_TEXTS[item]).join(', ') + '">' +
(act.icon || CONST.ACTION_TYPE_ICONS[type]) +
'</span>';
if (!act.countAverage) {
Expand Down Expand Up @@ -244,8 +244,8 @@ function groupsByLevel(archiveGroups, level) {
let lv1;
let lv2;
if (level) {
lv1 = levelsLog.filter(function(item) { return item[1] === level; })[0] || [];
lv2 = levelsLog.filter(function(item) { return item[1] === level + 1; })[0] || [];
lv1 = levelsLog.filter(item => item[1] === level)[0] || [];
lv2 = levelsLog.filter(item => item[1] === level + 1)[0] || [];
} else {
lv1 = levelsLog[levelsLog.length - 1];
lv2 = [];
Expand Down
6 changes: 3 additions & 3 deletions source/js/draw/stats/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ import {drawStatsSide} from './drawStatsSide';
* статистика собирается из архива
* */

subscribe('settingsChange', function(key, value) {
subscribe('settingsChange', (key, value) => {
if (['statsByMob', 'statsByMobId', 'myStatsByMob', 'statsActionsCount', 'statsByLevel', 'statsByLevelValue'].indexOf(key) > 0) {
drawStatsSide();
}
});

subscribe('preload', function() {
subscribe('preload', () => {
drawStatsSide();

subscribe('newMessages', function() {
subscribe('newMessages', () => {
drawStatsSide();
});
});
Expand Down
10 changes: 5 additions & 5 deletions source/js/draw/towns/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ $('body')
const id = $(this).data('place-id');
showMapDialogById(id);
})
.on('click.town', '.reload', function() {
.on('click.town', '.reload', () => {
const map_version = utils.map_version;
if (map_version) {
mapDataUpdate(map_version)
.done(function(mapData) {
.done(mapData => {
townParams(mapData);
});
}
Expand All @@ -33,16 +33,16 @@ $('body')
$townsContent.html('<span class="link-ajax pull-right reload glyphicon glyphicon-repeat"></span>');


subscribe('preload', function() {
subscribe('preload', () => {
const map_version = utils.map_version;
if (!map_version) return;
mapDataUpdate(map_version)
.done(function() {
.done(() => {
init();
});
});


subscribe('questUpdate', function(quest) {
subscribe('questUpdate', quest => {
townQuestUpdate(quest);
});
2 changes: 1 addition & 1 deletion source/js/draw/towns/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {mapData} from './mapData';
const $townsContent = elements.getTabInner('towns');


export const init = function() {
export const init = () => {
const places = mapData.places;
let html = '';
for (const i in places) {
Expand Down
2 changes: 1 addition & 1 deletion source/js/draw/towns/mapDataUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function mapDataUpdate(map_version) {
dataType: 'json',
type: 'get',
})
.done(function(map_data) {
.done(map_data => {
for (const key in mapData) {
if (mapData.hasOwnProperty(key)) {
delete mapData[key];
Expand Down
8 changes: 4 additions & 4 deletions source/js/draw/towns/townParams.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ export function townParams(mapData) {
const places = mapData.places;
for (const i in places) {
if (places.hasOwnProperty(i)) {
(function(placeIndex) {
((placeIndex => {
const place = places[placeIndex];
requestPlace(place.pos.x, place.pos.y)
.done(function(html) {
.done(html => {
const parsed = parsePlaceHtml(html);
const $placeRow = $('.place-row[data-place-id="' + placeIndex + '"]');
parsed.cityParams.forEach(function(item) {
parsed.cityParams.forEach(item => {
let val = item.value;
if (val < 100) val = '&nbsp;' + val;
$placeRow.children('[data-city-param="' + item.name + '"]').html(val);
});
});
})(i);
}))(i);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/js/ext.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import '../css/main.css';
/* todo разнести эту логику */
publish('init');
elements.getTabInner('sets')
.on('click', '#reset-stats', function() {
.on('click', '#reset-stats', () => {
if (confirm('Будет сброшена вся история\nПродолжить?')) {
log.set('messagesLog', '');
messagesLog.splice(0, messagesLog.length);
Expand Down
2 changes: 1 addition & 1 deletion source/js/notifications/hero.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {subscribe} from '../utils/pubsub';
import {sendNotify} from './sendNotify';

let lastNotifyMessagesText = '';
subscribe('newMessages', function(messagesNew, gameData) {
subscribe('newMessages', (messagesNew, gameData) => {
const hero = gameData.account.hero;
if (!settingsValues.notify) return;
const notifyMessages = [];
Expand Down
4 changes: 2 additions & 2 deletions source/js/notifications/quests.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import {subscribe} from '../utils/pubsub';
import {checkQuests} from './checkQuests';


subscribe('preload', function() {
subscribe('newMessages', function(messagesNew, game_data) {
subscribe('preload', () => {
subscribe('newMessages', (messagesNew, game_data) => {
const hero = game_data.account.hero;
const quests = hero.quests.quests;
checkQuests(quests);
Expand Down
2 changes: 1 addition & 1 deletion source/js/notifications/sendNotify.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function sendNotify(name, options) {
body: options.body + (options.addTime ? '\n' + time : ''),
icon: options.icon || (window.extPath + 'img/128.png'),
});
nt.onclick = nt.onclose = function() {
nt.onclick = nt.onclose = () => {
rndStr = generateRandomString();
};
}
12 changes: 6 additions & 6 deletions source/js/settings/initSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function initSettings() {
});
}

subscribe('preload', function(gameData) {
subscribe('preload', gameData => {
if (gameData) {
const hero = gameData.account.hero;
const energyBonus = hero.energy.bonus;
Expand All @@ -62,15 +62,15 @@ subscribe('preload', function(gameData) {
}
});

subscribe('init', function() {
subscribe('init', () => {
initSettings();
});


addSets(setsGame);


subscribe('init', function() {
subscribe('init', () => {
init();
});

Expand All @@ -83,14 +83,14 @@ subscribe('preload', function() {
}
});

subscribe('settingsChange', function(key/*, value*/) {
subscribe('settingsChange', key/*, value*/ => {
if (key === 'heroNameStart') {
drawMessages(messagesGrouped);
}
});

subscribe('newTurn', function(messagesNew) {
window.setTimeout(function() {
subscribe('newTurn', messagesNew => {
window.setTimeout(() => {
$('#storage-size')
.text('(занято ' + Math.round(log.size() / 1024 / 1024 * 100) / 100 + 'Мб)');
}, 10);
Expand Down
2 changes: 1 addition & 1 deletion source/js/settings/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function getSettingInput(key) {
const deps = {};
function checkDependences(key, value, isDisabled) {
if (deps[key]) {
deps[key].forEach(function(keyName) {
deps[key].forEach(keyName => {
if (keyName) {
getSettingInput(keyName).closest('.input-wrap').toggleClass('disabled', isDisabled || !value);//.prop('disabled', !value);
}
Expand Down
8 changes: 4 additions & 4 deletions source/js/tables.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import $ from 'jquery';

//console.log('tables.js')
window.tables = (function(_tables) {
window.tables = ((_tables => {
'use strict';

function makeSortable($table) {
Expand All @@ -28,15 +28,15 @@ window.tables = (function(_tables) {
value: value,
});
});
arr.sort(function(a, b) {
arr.sort((a, b) => {
if (a.value === b.value) {
return 0;
}
return a.value > b.value
? inverse ? 1 : -1
: inverse ? -1 : 1;
});
arr.forEach(function(item) {
arr.forEach(item => {
$table.append(item.$item);
});
});
Expand All @@ -61,4 +61,4 @@ window.tables = (function(_tables) {
}

return _tables;
})({});
}))({});
Loading

0 comments on commit 8c8b4b5

Please sign in to comment.