Skip to content

Instantly share code, notes, and snippets.

@fiatjaf
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fiatjaf/ea221c482726744c4eea to your computer and use it in GitHub Desktop.
Save fiatjaf/ea221c482726744c4eea to your computer and use it in GitHub Desktop.
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