|
|
|
|
|
|
|
|
|
|
|
|
|
function togglePlatform(platformId) {
|
|
this.platformStates[platformId] = !this.platformStates[platformId];
|
|
|
|
|
|
const stateKey = `platformStates_${this.currentView}`;
|
|
localStorage.setItem(stateKey, JSON.stringify(this.platformStates));
|
|
}
|
|
|
|
|
|
function getPlatformKeyCount(platformId, filtered = false) {
|
|
return this.apiKeys.filter(key => {
|
|
|
|
if (key.platform !== platformId) return false;
|
|
|
|
|
|
if (this.currentView === 'valid' && key.success !== true) return false;
|
|
if (this.currentView === 'invalid' && key.success !== false) return false;
|
|
|
|
|
|
if (filtered && this.searchTerm !== '' && !this.matchesSearch(key.name, key.key)) return false;
|
|
|
|
return true;
|
|
}).length;
|
|
}
|
|
|
|
|
|
function getPlatformValidKeyCount(platformId) {
|
|
return this.apiKeys.filter(key =>
|
|
key.platform === platformId && key.success === true
|
|
).length;
|
|
}
|
|
|
|
|
|
function getPlatformInvalidKeyCount(platformId) {
|
|
return this.apiKeys.filter(key =>
|
|
key.platform === platformId && key.success === false
|
|
).length;
|
|
}
|
|
|
|
|
|
function hasPlatformKeys(platformId) {
|
|
return this.getPlatformKeyCount(platformId) > 0;
|
|
}
|
|
|
|
|
|
function isPlatformVisible(platformId) {
|
|
|
|
if (this.platformFilters[platformId] !== true) {
|
|
return false;
|
|
}
|
|
|
|
|
|
const hasKeysInCurrentView = this.apiKeys.some(key => {
|
|
if (key.platform !== platformId) return false;
|
|
if (this.currentView === 'valid' && key.success !== true) return false;
|
|
if (this.currentView === 'invalid' && key.success !== false) return false;
|
|
return true;
|
|
});
|
|
|
|
return hasKeysInCurrentView;
|
|
}
|
|
|
|
|
|
function getPlatforms() {
|
|
return JSON.parse(platformsData);
|
|
}
|
|
|
|
|
|
function getPlatformStyles() {
|
|
return JSON.parse(platformStylesData);
|
|
}
|
|
|
|
|
|
function getPlatformIds() {
|
|
return this.getPlatforms().map(platform => platform.id);
|
|
}
|
|
|
|
|
|
function getPlatformStyle(platformId) {
|
|
const styles = getPlatformStyles();
|
|
return styles[platformId] || {};
|
|
}
|
|
|
|
|
|
function togglePlatformFilter(platformId) {
|
|
this.platformFilters[platformId] = !this.platformFilters[platformId];
|
|
|
|
|
|
if (this.platformFilters[platformId] === false) {
|
|
|
|
const platformIndex = this.selectedPlatforms.indexOf(platformId);
|
|
if (platformIndex !== -1) {
|
|
this.selectedPlatforms.splice(platformIndex, 1);
|
|
}
|
|
|
|
|
|
this.selectedKeys = this.selectedKeys.filter(keyId => {
|
|
const key = this.apiKeys.find(k => k.id === keyId);
|
|
return key && key.platform !== platformId;
|
|
});
|
|
}
|
|
|
|
|
|
const platforms = this.getPlatforms();
|
|
this.allPlatformsSelected = platforms.every(platform =>
|
|
this.platformFilters[platform.id] === true
|
|
);
|
|
|
|
|
|
localStorage.setItem('platformFilters', JSON.stringify(this.platformFilters));
|
|
}
|
|
|
|
|
|
function toggleAllPlatformFilters() {
|
|
const newState = !this.allPlatformsSelected;
|
|
this.allPlatformsSelected = newState;
|
|
|
|
|
|
const platforms = this.getPlatforms();
|
|
platforms.forEach(platform => {
|
|
this.platformFilters[platform.id] = newState;
|
|
});
|
|
|
|
|
|
if (newState === false) {
|
|
|
|
this.selectedPlatforms = [];
|
|
|
|
|
|
this.selectedKeys = [];
|
|
}
|
|
|
|
|
|
localStorage.setItem('platformFilters', JSON.stringify(this.platformFilters));
|
|
}
|
|
|