mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-02-08 13:38:14 -05:00
Fix condition types and add help link in popup. Fix #39.
This commit is contained in:
parent
feb2389fd8
commit
817528ef21
@ -27,11 +27,11 @@ angular.module('omegaTarget', []).factory 'omegaTarget', ($q) ->
|
|||||||
isChromeUrl = (url) -> url.substr(0, 6) == 'chrome'
|
isChromeUrl = (url) -> url.substr(0, 6) == 'chrome'
|
||||||
|
|
||||||
optionsChangeCallback = []
|
optionsChangeCallback = []
|
||||||
|
prefix = 'omega.local.'
|
||||||
urlParser = document.createElement('a')
|
urlParser = document.createElement('a')
|
||||||
omegaTarget =
|
omegaTarget =
|
||||||
options: null
|
options: null
|
||||||
state: (name, value) ->
|
state: (name, value) ->
|
||||||
prefix = 'omega.local.'
|
|
||||||
if arguments.length == 1
|
if arguments.length == 1
|
||||||
getValue = (key) -> try JSON.parse(localStorage[prefix + key])
|
getValue = (key) -> try JSON.parse(localStorage[prefix + key])
|
||||||
if Array.isArray(name)
|
if Array.isArray(name)
|
||||||
@ -41,6 +41,13 @@ angular.module('omegaTarget', []).factory 'omegaTarget', ($q) ->
|
|||||||
else
|
else
|
||||||
localStorage[prefix + name] = JSON.stringify(value)
|
localStorage[prefix + name] = JSON.stringify(value)
|
||||||
return $q.when(value)
|
return $q.when(value)
|
||||||
|
lastUrl: (url) ->
|
||||||
|
name = 'web.last_url'
|
||||||
|
if url
|
||||||
|
omegaTarget.state(name, url)
|
||||||
|
url
|
||||||
|
else
|
||||||
|
try JSON.parse(localStorage[prefix + name])
|
||||||
addOptionsChangeCallback: (callback) ->
|
addOptionsChangeCallback: (callback) ->
|
||||||
optionsChangeCallback.push(callback)
|
optionsChangeCallback.push(callback)
|
||||||
refresh: (args) ->
|
refresh: (args) ->
|
||||||
@ -62,14 +69,23 @@ angular.module('omegaTarget', []).factory 'omegaTarget', ($q) ->
|
|||||||
results
|
results
|
||||||
).then omegaTarget.refresh
|
).then omegaTarget.refresh
|
||||||
getMessage: chrome.i18n.getMessage.bind(chrome.i18n)
|
getMessage: chrome.i18n.getMessage.bind(chrome.i18n)
|
||||||
openOptions: ->
|
openOptions: (hash) ->
|
||||||
d = $q['defer']()
|
d = $q['defer']()
|
||||||
options_url = chrome.extension.getURL('options.html')
|
options_url = chrome.extension.getURL('options.html')
|
||||||
chrome.tabs.query url: options_url, (tabs) ->
|
chrome.tabs.query url: options_url, (tabs) ->
|
||||||
if tabs.length > 0
|
url = if hash
|
||||||
chrome.tabs.update(tabs[0].id, {active: true})
|
urlParser.href = tabs[0]?.url || options_url
|
||||||
|
urlParser.hash = hash
|
||||||
|
urlParser.href
|
||||||
else
|
else
|
||||||
chrome.tabs.create({url: options_url})
|
options_url
|
||||||
|
if tabs.length > 0
|
||||||
|
props = {active: true}
|
||||||
|
if hash
|
||||||
|
props.url = url
|
||||||
|
chrome.tabs.update(tabs[0].id, props)
|
||||||
|
else
|
||||||
|
chrome.tabs.create({url: url})
|
||||||
d.resolve()
|
d.resolve()
|
||||||
return d.promise
|
return d.promise
|
||||||
applyProfile: (name) ->
|
applyProfile: (name) ->
|
||||||
|
@ -29,9 +29,12 @@ module.controller 'PopupCtrl', ($scope, $window, $q, omegaTarget,
|
|||||||
'glyphicon-ok'
|
'glyphicon-ok'
|
||||||
else
|
else
|
||||||
profileIcons[profile.profileType]
|
profileIcons[profile.profileType]
|
||||||
$scope.openOptions = ->
|
$scope.openOptions = (hash) ->
|
||||||
omegaTarget.openOptions().then ->
|
omegaTarget.openOptions(hash).then ->
|
||||||
$window.close()
|
$window.close()
|
||||||
|
$scope.openConditionHelp = ->
|
||||||
|
pname = encodeURIComponent($scope.currentProfileName)
|
||||||
|
$scope.openOptions("#/profile/#{pname}?help=condition")
|
||||||
$scope.applyProfile = (profile) ->
|
$scope.applyProfile = (profile) ->
|
||||||
omegaTarget.applyProfile(profile.name).then ->
|
omegaTarget.applyProfile(profile.name).then ->
|
||||||
refresh()
|
refresh()
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
|
|
||||||
/* popup */
|
/* popup */
|
||||||
|
|
||||||
|
.clear-padding {
|
||||||
|
padding: 0 !important;
|
||||||
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
@ -24,6 +24,11 @@ angular.module('omega').config ($stateProvider, $urlRouterProvider,
|
|||||||
$animateProvider.classNameFilter(/angular-animate/)
|
$animateProvider.classNameFilter(/angular-animate/)
|
||||||
|
|
||||||
$urlRouterProvider.otherwise '/ui'
|
$urlRouterProvider.otherwise '/ui'
|
||||||
|
$urlRouterProvider.otherwise ($injector, $location) ->
|
||||||
|
if $location.path() == '' or $location.path() == '/'
|
||||||
|
$injector.get('omegaTarget').lastUrl()
|
||||||
|
else
|
||||||
|
'/ui'
|
||||||
|
|
||||||
$stateProvider
|
$stateProvider
|
||||||
.state('ui',
|
.state('ui',
|
||||||
|
@ -184,7 +184,7 @@ angular.module('omega').controller 'MasterCtrl', ($scope, $rootScope, $window,
|
|||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
||||||
$rootScope.$on '$stateChangeSuccess', ->
|
$rootScope.$on '$stateChangeSuccess', ->
|
||||||
omegaTarget.state('web.last_url', $location.url())
|
omegaTarget.lastUrl($location.url())
|
||||||
|
|
||||||
$window.onbeforeunload = ->
|
$window.onbeforeunload = ->
|
||||||
if $rootScope.optionsDirty
|
if $rootScope.optionsDirty
|
||||||
@ -218,6 +218,3 @@ angular.module('omega').controller 'MasterCtrl', ($scope, $rootScope, $window,
|
|||||||
"options_downloadInterval_" + (if interval < 0 then "never" else interval)
|
"options_downloadInterval_" + (if interval < 0 then "never" else interval)
|
||||||
|
|
||||||
omegaTarget.refresh()
|
omegaTarget.refresh()
|
||||||
|
|
||||||
omegaTarget.state('web.last_url').then (lastUrl) ->
|
|
||||||
$location.url(lastUrl) if lastUrl?
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
angular.module('omega').controller 'SwitchProfileCtrl', ($scope, $modal,
|
angular.module('omega').controller 'SwitchProfileCtrl', ($scope, $location,
|
||||||
profileIcons, getAttachedName) ->
|
$modal, profileIcons, getAttachedName) ->
|
||||||
|
|
||||||
|
$scope.showConditionHelp = ($location.search().help == 'condition')
|
||||||
|
|
||||||
$scope.basicConditionTypes = [
|
$scope.basicConditionTypes = [
|
||||||
{
|
{
|
||||||
|
@ -25,7 +25,7 @@ div(ng-controller='SwitchProfileCtrl')
|
|||||||
| {{'options_conditionType' | tr}}
|
| {{'options_conditionType' | tr}}
|
||||||
= ' '
|
= ' '
|
||||||
button.btn.btn-link.btn-sm.clear-padding(title='{{"options_showConditionTypeHelp" | tr}}'
|
button.btn.btn-link.btn-sm.clear-padding(title='{{"options_showConditionTypeHelp" | tr}}'
|
||||||
ng-click='showConditionHelp = !showConditionHelp' ng-init='showConditionHelp = false')
|
ng-click='showConditionHelp = !showConditionHelp')
|
||||||
span.glyphicon.glyphicon-question-sign
|
span.glyphicon.glyphicon-question-sign
|
||||||
th {{'options_conditionDetails' | tr}}
|
th {{'options_conditionDetails' | tr}}
|
||||||
th {{'options_resultProfile' | tr}}
|
th {{'options_resultProfile' | tr}}
|
||||||
|
@ -99,13 +99,19 @@ html(lang='en' ng-app='omegaPopup' ng-controller='PopupCtrl' ng-csp)
|
|||||||
= ' '
|
= ' '
|
||||||
| {{currentProfileName | dispName}}
|
| {{currentProfileName | dispName}}
|
||||||
div.form-group
|
div.form-group
|
||||||
label {{'options_conditionType' | tr}}
|
label
|
||||||
|
| {{'options_conditionType' | tr}}
|
||||||
|
= ' '
|
||||||
|
button.btn.btn-link.btn-sm.clear-padding(type='button' ng-click='openConditionHelp()')
|
||||||
|
| {{"options_showConditionTypeHelp" | tr}}
|
||||||
|
= ' '
|
||||||
|
span.glyphicon.glyphicon-new-window
|
||||||
select.form-control(ng-model='rule.condition.conditionType')
|
select.form-control(ng-model='rule.condition.conditionType')
|
||||||
option(value='HostWildcardCondition') {{'condition_hostWildcard' | tr}}
|
option(value='HostWildcardCondition') {{'condition_HostWildcardCondition' | tr}}
|
||||||
option(value='HostRegexCondition') {{'condition_hostRegex' | tr}}
|
option(value='HostRegexCondition') {{'condition_HostRegexCondition' | tr}}
|
||||||
option(value='UrlWildcardCondition') {{'condition_urlWildcard' | tr}}
|
option(value='UrlWildcardCondition') {{'condition_UrlWildcardCondition' | tr}}
|
||||||
option(value='UrlRegexCondition') {{'condition_urlRegex' | tr}}
|
option(value='UrlRegexCondition') {{'condition_UrlRegexCondition' | tr}}
|
||||||
option(value='KeywordCondition') {{'condition_keyword' | tr}}
|
option(value='KeywordCondition') {{'condition_KeywordCondition' | tr}}
|
||||||
div.form-group
|
div.form-group
|
||||||
label {{'options_conditionDetails' | tr}}
|
label {{'options_conditionDetails' | tr}}
|
||||||
input.form-control.condition-details(type='text' required ng-model='rule.condition.pattern')
|
input.form-control.condition-details(type='text' required ng-model='rule.condition.pattern')
|
||||||
|
Loading…
Reference in New Issue
Block a user