Skip to content

Commit 2fd607e

Browse files
committed
introducing mission sort, mission list scroll
1 parent 69018cf commit 2fd607e

File tree

4 files changed

+36
-18
lines changed

4 files changed

+36
-18
lines changed

README.md

+3-4
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,9 @@ Available for Android(App) and other platforms(Web).
1212
- Navigation to mission waypoints
1313

1414
## Changelog (latest)
15-
#### V1.2.1-161012:
16-
- fixed a bug in the mission navigation bar
17-
- press back button twice to exit on Android
18-
- update checking on Android
15+
### v1.3.0-161016:
16+
- **Introducing mission sort** : AQMissionHelper can now sort missions even if their names don't match the IngressMM naming rules. (this feature is in testing currently, feedbacks are welcome)
17+
- When going back from mission detail page, the mission list will scroll to the original position.
1918

2019

2120
## Support

aqmh.js

+20-1
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,24 @@ var app = {
171171
return;
172172
}
173173
list.html('');
174-
app.result = result.mission;
174+
// Smart Sort
175+
var getNum = function(name) {
176+
var regs = [/[(\[]*(\d+)[)\]\/]/i, /(\d+)$/i];
177+
for (var key in regs) {
178+
var matches = name.match(regs[key]);
179+
if (matches && matches.length >= 2)
180+
return Number(matches[1]);
181+
}
182+
return false;
183+
};
184+
app.result = result.mission.sort(function(a, b) {
185+
var aNum = getNum(a.name);
186+
var bNum = getNum(b.name);
187+
if (aNum === false) return 1;
188+
if (bNum === false) return -1;
189+
return aNum - bNum;
190+
});
191+
175192
for (var key in app.result) {
176193
var mission = app.result[key];
177194
var type = '';
@@ -395,6 +412,7 @@ $(function() {
395412
});
396413

397414
$('#mission_list').on('click', '.mission', function() {
415+
app.lastScroll = document.body.scrollTop;
398416
$('#mission_search_box').hide();
399417
$('#mission_list').hide();
400418
$('#mission_detail').show();
@@ -421,6 +439,7 @@ $(function() {
421439
}
422440
$('#mission_switch, #mission_detail').hide();
423441
$('#mission_search_box, #mission_list').show();
442+
if (app.lastScroll) document.body.scrollTop = app.lastScroll;
424443
});
425444

426445
// init transport search

www/js/aqmh.min.js

+12-12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

www/version.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
release-1.2.1-161012
1+
release-1.3.0-161016

0 commit comments

Comments
 (0)