From 074785cea106179cb3305637055ab0a009ca74f2 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:42:52 -0500 Subject: initial commit --- .../ru/web/api/storagemanager/estimate/index.html | 78 ++++++++++++++++++++++ files/ru/web/api/storagemanager/index.html | 53 +++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 files/ru/web/api/storagemanager/estimate/index.html create mode 100644 files/ru/web/api/storagemanager/index.html (limited to 'files/ru/web/api/storagemanager') diff --git a/files/ru/web/api/storagemanager/estimate/index.html b/files/ru/web/api/storagemanager/estimate/index.html new file mode 100644 index 0000000000..ff509f32fd --- /dev/null +++ b/files/ru/web/api/storagemanager/estimate/index.html @@ -0,0 +1,78 @@ +--- +title: StorageManager.estimate() +slug: Web/API/StorageManager/estimate +tags: + - метод +translation_of: Web/API/StorageManager/estimate +--- +

{{securecontext_header}}{{APIRef("Storage")}}

+ +

The estimate() method of the {{domxref("StorageManager")}} interface asks the Storage Manager to obtain quota and usage information for the current origin. This method operates asynchronously, so it returns a {{jsxref("Promise")}} which resolves once the information is available. The promise's fulfillment handler receives as an input a {{domxref("StorageEstimate")}} with the usage and quota data.

+ +

Синтаксис

+ +
var estimatePromise = StorageManager.estimate();
+ +

Параметры

+ +

None.

+ +

Возвращаемый результат

+ +

A {{jsxref('Promise')}} that resolves to an object which conforms to the {{domxref('StorageEstimate')}} dictionary. This dictionary contains estimates of how much space is available to the origin or app (in {{domxref("StorageEstimate.quota")}}, as well as how much is currently used (in {{domxref("StorageEstimate.usage")}}). These are not exact numbers; between compression, deduplication, and obfuscation for security reasons, they will not be precise.

+ +

You may find that the quota varies from app to app based on factors such as the frequency with which the user visits it, commonly-known site popularity data, and so forth.

+ +

Примеры

+ +

In this example, we obtain the usage estimates and present the percentage of storage capacity currently used to the user.

+ +

HTML content

+ +
<p>
+  You're currently using about <span id="percent">
+  </span>% of your available storage.
+</p>
+
+ +

JavaScript content

+ +
navigator.storage.estimate().then(function(estimate) {
+  document.getElementById("percent").innerHTML =
+      (estimate.usage / estimate.quota).toFixed(2);
+});
+
+ +

Результат

+ +

{{ EmbedLiveSample('Example', 600, 40) }}

+ +

Спецификация

+ + + + + + + + + + + + + + +
СпецификацияСтатусКомментарий
{{SpecName('Storage','#dom-storagemanager-estimate','estimate()')}}{{Spec2('Storage')}}Initial definition.
+ +

Совместимость с браузерами

+ +
{{Compat("api.StorageManager.estimate")}}
+ +

Смотрите также

+ + diff --git a/files/ru/web/api/storagemanager/index.html b/files/ru/web/api/storagemanager/index.html new file mode 100644 index 0000000000..c28ba798a3 --- /dev/null +++ b/files/ru/web/api/storagemanager/index.html @@ -0,0 +1,53 @@ +--- +title: StorageManager +slug: Web/API/StorageManager +tags: + - API + - Interface + - Persistence + - Quotas + - Reference + - Secure context + - Storage + - Storage API + - StorageManager + - Usage +translation_of: Web/API/StorageManager +--- +

{{securecontext_header}}{{SeeCompatTable}}{{APIRef("Storage")}}

+ +

StorageManager является частью Storage API и предоставляет интерфейс для управления правами на хранение данных и для получения объема данных, доступного для хранения. Доступ к интерфейсу можно получить через {{domxref("navigator.storage")}} или через {{domxref("WorkerNavigator.storage")}}.

+ +

Методы

+ +
+
{{domxref("StorageManager.estimate()")}} {{securecontext_inline}}
+
Возвращает объект {{domxref("StorageEstimate")}}, который содержит используемый и максимальный объем данных (квоту) для вашего сайта.
+
{{domxref("StorageManager.persist()")}} {{securecontext_inline}}
+
Возвращает {{jsxref('Promise')}}, который принимает значение true в случае, когда браузер имеет возможность хранить данные вашего сайта.
+
{{domxref("StorageManager.persisted()")}} {{securecontext_inline}}
+
Возвращает {{jsxref('Promise')}}, который принимает значение true в случае, когда сайт получил возможность хранить данные в браузере.
+
+ +

Спецификация

+ + + + + + + + + + + + + + +
СпецификацияСтатусКомментарий
{{SpecName('Storage','#storagemanager','StorageManager')}}{{Spec2('Storage')}}Initial definition.
+ +

Совместимость с браузерами

+ + + +

{{Compat("api.StorageManager")}}

-- cgit v1.2.3-54-g00ecf