Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Rewrite “Aircraft: Flights” code #72

Open
wants to merge 41 commits into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
08c838a
add flight-data class
ZoeBijl Jun 13, 2024
f20bf5f
add ExtractionButton class
ZoeBijl Jun 13, 2024
b92f34d
add AircraftStatisticsPanel and AircraftStatisticsRow classes
ZoeBijl Jun 13, 2024
c51d503
add Aircraft class
ZoeBijl Jun 13, 2024
cdd84a3
move getData()
ZoeBijl Jun 13, 2024
60ad846
replace flight with new class
ZoeBijl Jun 13, 2024
abc2d13
include flightNumber in saved data
ZoeBijl Jun 13, 2024
38f768e
only change currency colour when positive
ZoeBijl Jun 13, 2024
e14ef6f
add jsdoc
ZoeBijl Jun 13, 2024
62352f3
remove unused variables
ZoeBijl Jun 13, 2024
70e90ef
add jsdoc
ZoeBijl Jun 13, 2024
32a1e0d
add formatDaysAgo() function to helpers.js
ZoeBijl Jun 13, 2024
71f6501
make getDateDiff accept more values
ZoeBijl Jun 13, 2024
2fa8d56
make StatisticsPanel add itself to the page
ZoeBijl Jun 13, 2024
af8da1a
add InfoPanel class
ZoeBijl Jun 13, 2024
8da7cbd
remove formatMoeny
ZoeBijl Jun 13, 2024
5375eea
remove buildTable()
ZoeBijl Jun 13, 2024
03bd4eb
rewrites
ZoeBijl Jun 13, 2024
82a13d4
wip
ZoeBijl Jun 14, 2024
c472708
chore: update .editorconfig
ZoeBijl Jun 14, 2024
81520aa
chore: move flight-data.js to data-models folder
ZoeBijl Jun 14, 2024
908b1d1
expand FlightData jsdoc
ZoeBijl Jun 14, 2024
5a46710
reorder variables
ZoeBijl Jun 14, 2024
0afd9c7
make sure the id is an integer
ZoeBijl Jun 14, 2024
aa1cad4
get aircraft data asynchronously
ZoeBijl Jun 14, 2024
adf51b6
fix(#69): filter airline.name when used as a key
RobertFridolin Jun 14, 2024
08663dc
port to vanilla
ZoeBijl Jun 15, 2024
b6a0c79
fix(#79): add check for AESMenu target
ZoeBijl Jun 16, 2024
2c336f5
style: format to .editorconfig spec
ZoeBijl Jun 16, 2024
4c3c4da
remove comment
ZoeBijl Jun 17, 2024
8596381
chore: write flightDataExample
ZoeBijl Jun 17, 2024
da9d4eb
only set statisticsPanel.allExtracted when there are profitFlights
ZoeBijl Jun 17, 2024
bece074
move button creation into a function
ZoeBijl Jun 17, 2024
f9ceeaa
feat(#81): add `version_name` support
ZoeBijl Jun 17, 2024
29fa397
refactor: displayFlightProfit
ZoeBijl Jun 18, 2024
730d0c7
set default for callback
ZoeBijl Jun 18, 2024
f8b635d
refactor: port createButtonOld to vanilla
ZoeBijl Jun 18, 2024
f0f3d02
style(#86): format all historic .js files with .editorconfig
ZoeBijl Jun 19, 2024
a4d8ae3
feat(#62): add Notifications API
ZoeBijl Jun 19, 2024
250cb4f
feat: use Notifications API for aircraftFlights and flightInfo
ZoeBijl Jun 20, 2024
4f6f7f5
chore: update jQuery to 3.7.1 (#84)
RobertFridolin Jun 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_style = space
indent_size = 4
indent_size = 4

[*.js]
trim_trailing_whitespace = true
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,45 @@ The community has published some updates in the meantime but no continued develo

Sources: the [original forum thread](https://forums.airlinesim.aero/t/introducing-airlinesim-enhancement-suite-beta/21684).

## Developer Features

These features make developing for AES easier.

### Notifications

AES comes with its own notification API. This uses AS’ notification style and location. The AES notification API consists of two components: `Notifications` and `Notification`.

#### Usage

Notifications should only be used as a response to an action by the user; don’t add notifications on page load.

#### Initiate the `Notifications`:

To start using the notification API create a new `Notifications`:

```
const notifications = new Notifications()
```

#### Add a new notification

To add a notification:

```
notifications.add("The settings have been updated")
```

By default a new notification comes with the success styling (a checkmark icon and a green background). The style can be changed by passing an options object:

```
notifications.new("Failed to save data", {type: "warning"})
```

The possible values for `type` are:
- `"success"`
- `"warning"`
- `"error"`

## Credits

- Marcipanas for the original development
Expand Down
200 changes: 100 additions & 100 deletions extension/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,122 +4,122 @@

'use strict';
//Functions
function setDefaultSettings(){
//Add default settings
function setDefaultSettings() {
//Add default settings

let aesSettings = {
invPricing:setDefaultInvPricingSettings(),
general:setDefaultGeneralSettings(),
schedule:setDefaultScheduleSettings()
};
chrome.storage.local.get(['settings'], function(result) {
let settings = result.settings;
if(!settings){
settings = aesSettings;
chrome.storage.local.set({settings: aesSettings}, function() {
});
}
});
//
let aesSettings = {
invPricing: setDefaultInvPricingSettings(),
general: setDefaultGeneralSettings(),
schedule: setDefaultScheduleSettings()
};
chrome.storage.local.get(['settings'], function(result) {
let settings = result.settings;
if (!settings) {
settings = aesSettings;
chrome.storage.local.set({ settings: aesSettings }, function() {

});
}
});
//
}

function setDefaultScheduleSettings(){
//auto settings
let schedule = {
autoExtract:0
};
//Cmp setttings
return schedule;
function setDefaultScheduleSettings() {
//auto settings
let schedule = {
autoExtract: 0
};
//Cmp setttings
return schedule;
}
function setDefaultGeneralSettings(){
//auto settings
let general = {
defaultDashboard:'general'
};
//Cmp setttings
return general;

function setDefaultGeneralSettings() {
//auto settings
let general = {
defaultDashboard: 'general'
};
//Cmp setttings
return general;
}
function setDefaultInvPricingSettings(){
//auto settings
let invPricing = {
autoAnalysisSave:1,
autoPriceUpdate:0,
autoClose:0,
recommendation:{},
historyTable:{
showNow:1,
showOnlyPricing:0,
numberOfDates:"5"
}
};
//Cmp setttings
let steps = [
{
min:0,
max:40,
name:'Drop High',
step:-8

function setDefaultInvPricingSettings() {
//auto settings
let invPricing = {
autoAnalysisSave: 1,
autoPriceUpdate: 0,
autoClose: 0,
recommendation: {},
historyTable: {
showNow: 1,
showOnlyPricing: 0,
numberOfDates: "5"
}
};
//Cmp setttings
let steps = [
{
min: 0,
max: 40,
name: 'Drop High',
step: -8
},
{
min:40,
max:60,
name:'Drop Medium',
step: -4
{
min: 40,
max: 60,
name: 'Drop Medium',
step: -4
},
{
min:60,
max:70,
name:'Drop Low',
step: -2
{
min: 60,
max: 70,
name: 'Drop Low',
step: -2
},
{
min:70,
max:80,
name:'Keep',
step: 0
{
min: 70,
max: 80,
name: 'Keep',
step: 0
},
{
min:80,
max:90,
name:'Raise Low',
step: 1
{
min: 80,
max: 90,
name: 'Raise Low',
step: 1
},
{
min:90,
max:99,
name:'Raise Medium',
step: 2
{
min: 90,
max: 99,
name: 'Raise Medium',
step: 2
},
{
min:99,
max:100,
name:'Raise High',
step: 5
{
min: 99,
max: 100,
name: 'Raise High',
step: 5
}
];
let cmps = ['Y','C','F','Cargo'];
cmps.forEach(function(cmp){
invPricing.recommendation[cmp] = {
maxPrice:200,
minPrice:60,
steps:steps
};
});
return invPricing;
let cmps = ['Y', 'C', 'F', 'Cargo'];
cmps.forEach(function(cmp) {
invPricing.recommendation[cmp] = {
maxPrice: 200,
minPrice: 60,
steps: steps
};
});
return invPricing;
}


//MAIN

chrome.runtime.onInstalled.addListener(function() {
setDefaultSettings();
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
chrome.declarativeContent.onPageChanged.addRules([{
conditions: [new chrome.declarativeContent.PageStateMatcher({
pageUrl: {hostContains: '.airlinesim.aero'},
})],
actions: [new chrome.declarativeContent.ShowPageAction()]
setDefaultSettings();
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
chrome.declarativeContent.onPageChanged.addRules([{
conditions: [new chrome.declarativeContent.PageStateMatcher({
pageUrl: { hostContains: '.airlinesim.aero' },
})],
actions: [new chrome.declarativeContent.ShowPageAction()]
}]);
});
});
});
Loading