mirror of
https://github.com/zero-peak/ZeroOmega.git
synced 2025-02-08 13:38:14 -05:00
Use browser.downloads.download to export files if available.
This commit is contained in:
parent
8d040f9402
commit
35cdb7ed6b
@ -5,7 +5,13 @@ window.OmegaDebug =
|
|||||||
chrome.runtime.getManifest().version
|
chrome.runtime.getManifest().version
|
||||||
downloadLog: ->
|
downloadLog: ->
|
||||||
blob = new Blob [localStorage['log']], {type: "text/plain;charset=utf-8"}
|
blob = new Blob [localStorage['log']], {type: "text/plain;charset=utf-8"}
|
||||||
saveAs(blob, "OmegaLog_#{Date.now()}.txt")
|
filename = "OmegaLog_#{Date.now()}.txt"
|
||||||
|
|
||||||
|
if browser?.downloads?.download?
|
||||||
|
url = URL.createObjectURL(blob)
|
||||||
|
browser.downloads.download({url: url, filename: filename})
|
||||||
|
else
|
||||||
|
saveAs(blob, filename)
|
||||||
resetOptions: ->
|
resetOptions: ->
|
||||||
localStorage.clear()
|
localStorage.clear()
|
||||||
# Prevent options loading from sync storage after reload.
|
# Prevent options loading from sync storage after reload.
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
"alarms",
|
"alarms",
|
||||||
"storage",
|
"storage",
|
||||||
"webRequest",
|
"webRequest",
|
||||||
|
"downloads",
|
||||||
"webRequestBlocking",
|
"webRequestBlocking",
|
||||||
"contextMenus",
|
"contextMenus",
|
||||||
|
|
||||||
|
@ -66,12 +66,14 @@ angular.module('omega').config ($stateProvider, $urlRouterProvider,
|
|||||||
controller: 'AboutCtrl'
|
controller: 'AboutCtrl'
|
||||||
)
|
)
|
||||||
|
|
||||||
angular.module('omega').factory 'omegaDebug', ($window, $rootScope) ->
|
angular.module('omega').factory 'omegaDebug', ($window, $rootScope,
|
||||||
|
$injector) ->
|
||||||
omegaDebug = $window.OmegaDebug ? {}
|
omegaDebug = $window.OmegaDebug ? {}
|
||||||
|
|
||||||
omegaDebug.downloadLog ?= ->
|
omegaDebug.downloadLog ?= ->
|
||||||
|
downloadFile = $injector.get('downloadFile') ? saveAs
|
||||||
blob = new Blob [localStorage['log']], {type: "text/plain;charset=utf-8"}
|
blob = new Blob [localStorage['log']], {type: "text/plain;charset=utf-8"}
|
||||||
saveAs(blob, "OmegaLog_#{Date.now()}.txt")
|
downloadFile(blob, "OmegaLog_#{Date.now()}.txt")
|
||||||
|
|
||||||
omegaDebug.reportIssue ?= ->
|
omegaDebug.reportIssue ?= ->
|
||||||
$window.open(
|
$window.open(
|
||||||
@ -82,3 +84,14 @@ angular.module('omega').factory 'omegaDebug', ($window, $rootScope) ->
|
|||||||
$rootScope.resetOptions()
|
$rootScope.resetOptions()
|
||||||
|
|
||||||
omegaDebug
|
omegaDebug
|
||||||
|
|
||||||
|
angular.module('omega').factory 'downloadFile', ->
|
||||||
|
if browser?.downloads?.download?
|
||||||
|
return (blob, filename) ->
|
||||||
|
url = URL.createObjectURL(blob)
|
||||||
|
if filename
|
||||||
|
browser.downloads.download({url: url, filename: filename})
|
||||||
|
else
|
||||||
|
browser.downloads.download({url: url})
|
||||||
|
else
|
||||||
|
return saveAs
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
angular.module('omega').controller 'IoCtrl', ($scope, $rootScope,
|
angular.module('omega').controller 'IoCtrl', ($scope, $rootScope,
|
||||||
$window, $http, omegaTarget) ->
|
$window, $http, omegaTarget, downloadFile) ->
|
||||||
|
|
||||||
omegaTarget.state('web.restoreOnlineUrl').then (url) ->
|
omegaTarget.state('web.restoreOnlineUrl').then (url) ->
|
||||||
if url
|
if url
|
||||||
@ -10,7 +10,7 @@ angular.module('omega').controller 'IoCtrl', ($scope, $rootScope,
|
|||||||
plainOptions = angular.fromJson(angular.toJson($rootScope.options))
|
plainOptions = angular.fromJson(angular.toJson($rootScope.options))
|
||||||
content = JSON.stringify(plainOptions)
|
content = JSON.stringify(plainOptions)
|
||||||
blob = new Blob [content], {type: "text/plain;charset=utf-8"}
|
blob = new Blob [content], {type: "text/plain;charset=utf-8"}
|
||||||
saveAs(blob, "OmegaOptions.bak")
|
downloadFile(blob, "OmegaOptions.bak")
|
||||||
|
|
||||||
$scope.importSuccess = ->
|
$scope.importSuccess = ->
|
||||||
$rootScope.showAlert(
|
$rootScope.showAlert(
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
angular.module('omega').controller 'MasterCtrl', ($scope, $rootScope, $window,
|
angular.module('omega').controller 'MasterCtrl', ($scope, $rootScope, $window,
|
||||||
$q, $modal, $state, profileColors, profileIcons, omegaTarget,
|
$q, $modal, $state, profileColors, profileIcons, omegaTarget,
|
||||||
$timeout, $location, $filter, getAttachedName, isProfileNameReserved,
|
$timeout, $location, $filter, getAttachedName, isProfileNameReserved,
|
||||||
isProfileNameHidden, dispNameFilter) ->
|
isProfileNameHidden, dispNameFilter, downloadFile) ->
|
||||||
|
|
||||||
tr = $filter('tr')
|
tr = $filter('tr')
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ angular.module('omega').controller 'MasterCtrl', ($scope, $rootScope, $window,
|
|||||||
pac = OmegaPac.PacGenerator.ascii(pac)
|
pac = OmegaPac.PacGenerator.ascii(pac)
|
||||||
blob = new Blob [pac], {type: "text/plain;charset=utf-8"}
|
blob = new Blob [pac], {type: "text/plain;charset=utf-8"}
|
||||||
fileName = profileName.replace(/\W+/g, '_')
|
fileName = profileName.replace(/\W+/g, '_')
|
||||||
saveAs(blob, "OmegaProfile_#{fileName}.pac")
|
downloadFile(blob, "OmegaProfile_#{fileName}.pac")
|
||||||
if missingProfile
|
if missingProfile
|
||||||
$timeout ->
|
$timeout ->
|
||||||
$rootScope.showAlert(
|
$rootScope.showAlert(
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
angular.module('omega').controller 'SwitchProfileCtrl', ($scope, $rootScope,
|
angular.module('omega').controller 'SwitchProfileCtrl', ($scope, $rootScope,
|
||||||
$location, $timeout, $q, $modal, profileIcons, getAttachedName, omegaTarget,
|
$location, $timeout, $q, $modal, profileIcons, getAttachedName, omegaTarget,
|
||||||
trFilter) ->
|
trFilter, downloadFile) ->
|
||||||
# == Rule list ==
|
# == Rule list ==
|
||||||
$scope.ruleListFormats = OmegaPac.Profiles.ruleListFormats
|
$scope.ruleListFormats = OmegaPac.Profiles.ruleListFormats
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ angular.module('omega').controller 'SwitchProfileCtrl', ($scope, $rootScope,
|
|||||||
|
|
||||||
blob = new Blob [text], {type: "text/plain;charset=utf-8"}
|
blob = new Blob [text], {type: "text/plain;charset=utf-8"}
|
||||||
fileName = $scope.profile.name.replace(/\W+/g, '_')
|
fileName = $scope.profile.name.replace(/\W+/g, '_')
|
||||||
saveAs(blob, "OmegaRules_#{fileName}.sorl")
|
downloadFile(blob, "OmegaRules_#{fileName}.sorl")
|
||||||
|
|
||||||
exportLegacyRuleList = ->
|
exportLegacyRuleList = ->
|
||||||
wildcardRules = ''
|
wildcardRules = ''
|
||||||
@ -52,7 +52,7 @@ angular.module('omega').controller 'SwitchProfileCtrl', ($scope, $rootScope,
|
|||||||
"""
|
"""
|
||||||
blob = new Blob [text], {type: "text/plain;charset=utf-8"}
|
blob = new Blob [text], {type: "text/plain;charset=utf-8"}
|
||||||
fileName = $scope.profile.name.replace(/\W+/g, '_')
|
fileName = $scope.profile.name.replace(/\W+/g, '_')
|
||||||
saveAs(blob, "SwitchyRules_#{fileName}.ssrl")
|
downloadFile(blob, "SwitchyRules_#{fileName}.ssrl")
|
||||||
|
|
||||||
# == Condition types ==
|
# == Condition types ==
|
||||||
$scope.conditionHelp =
|
$scope.conditionHelp =
|
||||||
|
Loading…
Reference in New Issue
Block a user