Last active
August 29, 2015 14:03
-
-
Save fiatjaf/ea221c482726744c4eea to your computer and use it in GitHub Desktop.
bookmarklet bhiss salvar-recuperar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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]; | |
} | |
})() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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