aboutsummaryrefslogtreecommitdiffstats
path: root/old-ui/lib/persistent-form.js
diff options
context:
space:
mode:
authorWhymarrh Whitby <whymarrh.whitby@gmail.com>2019-02-21 20:24:32 +0800
committerGitHub <noreply@github.com>2019-02-21 20:24:32 +0800
commit65bfdeedc77e51dea28ef643b5ea9d50a8569c81 (patch)
tree91859eabd9280c19131a403e35a9bc5262a6e402 /old-ui/lib/persistent-form.js
parentc6e84ccf458061a6b64e6a15512b008e8d0166ea (diff)
parent38bb1d39792d8e4c238f7528990d725527379550 (diff)
downloadtangerine-wallet-browser-65bfdeedc77e51dea28ef643b5ea9d50a8569c81.tar.gz
tangerine-wallet-browser-65bfdeedc77e51dea28ef643b5ea9d50a8569c81.tar.zst
tangerine-wallet-browser-65bfdeedc77e51dea28ef643b5ea9d50a8569c81.zip
Merge pull request #6166 from whymarrh/bye-bye-old-ui
Delete the old UI
Diffstat (limited to 'old-ui/lib/persistent-form.js')
-rw-r--r--old-ui/lib/persistent-form.js61
1 files changed, 0 insertions, 61 deletions
diff --git a/old-ui/lib/persistent-form.js b/old-ui/lib/persistent-form.js
deleted file mode 100644
index d4dc20b03..000000000
--- a/old-ui/lib/persistent-form.js
+++ /dev/null
@@ -1,61 +0,0 @@
-const inherits = require('util').inherits
-const Component = require('react').Component
-const defaultKey = 'persistent-form-default'
-const eventName = 'keyup'
-
-module.exports = PersistentForm
-
-function PersistentForm () {
- Component.call(this)
-}
-
-inherits(PersistentForm, Component)
-
-PersistentForm.prototype.componentDidMount = function () {
- const fields = document.querySelectorAll('[data-persistent-formid]')
- const store = this.getPersistentStore()
-
- for (var i = 0; i < fields.length; i++) {
- const field = fields[i]
- const key = field.getAttribute('data-persistent-formid')
- const cached = store[key]
- if (cached !== undefined) {
- field.value = cached
- }
-
- field.addEventListener(eventName, this.persistentFieldDidUpdate.bind(this))
- }
-}
-
-PersistentForm.prototype.getPersistentStore = function () {
- let store = window.localStorage[this.persistentFormParentId || defaultKey]
- if (store && store !== 'null') {
- store = JSON.parse(store)
- } else {
- store = {}
- }
- return store
-}
-
-PersistentForm.prototype.setPersistentStore = function (newStore) {
- window.localStorage[this.persistentFormParentId || defaultKey] = JSON.stringify(newStore)
-}
-
-PersistentForm.prototype.persistentFieldDidUpdate = function (event) {
- const field = event.target
- const store = this.getPersistentStore()
- const key = field.getAttribute('data-persistent-formid')
- const val = field.value
- store[key] = val
- this.setPersistentStore(store)
-}
-
-PersistentForm.prototype.componentWillUnmount = function () {
- const fields = document.querySelectorAll('[data-persistent-formid]')
- for (var i = 0; i < fields.length; i++) {
- const field = fields[i]
- field.removeEventListener(eventName, this.persistentFieldDidUpdate.bind(this))
- }
- this.setPersistentStore({})
-}
-