Reduce state storage usage for profile.validResultProfiles.

This commit is contained in:
FelisCatus 2014-10-26 12:28:38 +08:00
parent bf82d5a55a
commit 7315d18ed9
2 changed files with 27 additions and 16 deletions

View File

@ -297,6 +297,7 @@ class Options
if allReferenceSet[key]
profiles[key].validResultProfiles =
OmegaPac.Profiles.validResultProfilesFor(p, @_options)
.map (result) -> result.name
if currentIncludable and OmegaPac.Profiles.isIncludable(p)
results?.push(p.name)
if profile and OmegaPac.Profiles.isInclusive(profile)
@ -329,7 +330,7 @@ class Options
@_state.set({
'currentProfileName': @_currentProfileName
'isSystemProfile': @_isSystem
'currentProfileCanAddRule': profile.rules?
'currentProfileCanAddRule': profile.rules? and not profile.virtualType
})
@_setAvailableProfiles()

View File

@ -75,27 +75,37 @@ module.controller 'PopupCtrl', ($scope, $window, $q, omegaTarget,
proxyNotControllable]) ->
$scope.proxyNotControllable = proxyNotControllable
return if proxyNotControllable
$scope.builtinProfiles = []
$scope.customProfiles = []
$scope.availableProfiles = availableProfiles
charCodeUnderscore = '_'.charCodeAt(0)
for own key, profile of availableProfiles
if profile.builtin
$scope.builtinProfiles.push(profile)
else if profile.name.charCodeAt(0) != charCodeUnderscore
$scope.customProfiles.push(profile)
$scope.customProfiles.sort(profileOrder)
$scope.currentProfile = availableProfiles['+' + currentProfileName]
$scope.currentProfileName = currentProfileName
$scope.isSystemProfile = isSystemProfile
$scope.externalProfile = externalProfile
refreshOnProfileChange = refreshOnProfileChange
$scope.validResultProfiles = []
for name in validResultProfiles
shown = (name.charCodeAt(0) != charCodeUnderscore or
name.charCodeAt(1) != charCodeUnderscore)
if shown
$scope.validResultProfiles.push(availableProfiles['+' + name])
charCodeUnderscore = '_'.charCodeAt(0)
profilesByNames = (names) ->
profiles = []
for name in names
shown = (name.charCodeAt(0) != charCodeUnderscore or
name.charCodeAt(1) != charCodeUnderscore)
if shown
profiles.push(availableProfiles['+' + name])
profiles
$scope.validResultProfiles = profilesByNames(validResultProfiles)
$scope.builtinProfiles = []
$scope.customProfiles = []
for own key, profile of availableProfiles
if profile.builtin
$scope.builtinProfiles.push(profile)
else if profile.name.charCodeAt(0) != charCodeUnderscore
$scope.customProfiles.push(profile)
if profile.validResultProfiles
profile.validResultProfiles =
profilesByNames(profile.validResultProfiles)
$scope.customProfiles.sort(profileOrder)
omegaTarget.getActivePageInfo().then((info) ->
if info