Skip to content

Instantly share code, notes, and snippets.

@fiatjaf fiatjaf/recover.js
Last active Aug 29, 2015

Embed
What would you like to do?
bookmarklet bhiss salvar-recuperar
(function () {
var fields = {
'form:numDocumento': 'value',
'form:dnomeRazaoSocial': 'value',
'form:cep': 'value',
'form:logradouro': 'value',
'form:numero': 'value',
'form:complemento': 'value',
'form:bairro': 'value',
'form:municipioTomadorServico': 'value',
'form:ufTomadorServico': 'value',
'form:descriminacaoServico': 'value',
'form:regimeEspecialTributacao': 'value',
'form:valorServicos': 'value'
};
var values = JSON.parse(localStorage.getItem(document.querySelector('[name="form:numDocumento"]').value));
for (var k in fields) {
var type = fields[k];
document.querySelector('[name="' + k + '"]')[type] = values[k];
}
})()
(function () {
var fields = {
'form:numDocumento': 'value',
'form:dnomeRazaoSocial': 'value',
'form:cep': 'value',
'form:logradouro': 'value',
'form:numero': 'value',
'form:complemento': 'value',
'form:bairro': 'value',
'form:municipioTomadorServico': 'value',
'form:ufTomadorServico': 'value',
'form:descriminacaoServico': 'value',
'form:regimeEspecialTributacao': 'value',
'form:valorServicos': 'value'
};
var values = {};
for (var k in fields) {
var type = fields[k];
var val = document.querySelector('[name="' + k + '"]')[type];
values[k] = val;
}
if (values['form:numDocumento']) {
localStorage.setItem(values['form:numDocumento'], JSON.stringify(values));
localStorage.setItem(values['form:numDocumento'] + '-' + (new Date()).toISOString(), JSON.stringify(values));
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.