Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linked-Based Settings Export/Import and QR Code Musings #114

Open
fny opened this issue Jun 11, 2014 · 0 comments
Open

Linked-Based Settings Export/Import and QR Code Musings #114

fny opened this issue Jun 11, 2014 · 0 comments

Comments

@fny
Copy link

fny commented Jun 11, 2014

Given the settings array is a simple list of key value pairs, its easy to construct a corresponding URL:

var settings = [{"name":"appVersion","value":"0.5.0"},{"name":"appLang","value":"en-US"},{"name":"cloudStorage","value":"dropbox"},{"name":"pagination","value":"10"},{"name":"editMode","value":"preview"},{"name":"encrypt","value":1},{"name":"encryptPass","value":[-123,-123,123,123,123,123,123,123]},{"name":"encryptSalt","value":"-123,123"},{"name":"encryptIter","value":"1000"},{"name":"encryptTag","value":"64"},{"name":"encryptKeySize","value":"128"},{"name":"navigateTop","value":"k"},{"name":"navigateBottom","value":"j"},{"name":"jumpInbox","value":"g i"},{"name":"jumpNotebook","value":"g n"},{"name":"jumpFavorite","value":"g f"},{"name":"jumpRemoved","value":"g t"},{"name":"actionsEdit","value":"e"},{"name":"actionsOpen","value":"o"},{"name":"actionsRemove","value":"shift+3"},{"name":"actionsRotateStar","value":"s"},{"name":"appCreateNote","value":"c"},{"name":"appSearch","value":"/"},{"name":"appKeyboardHelp","value":"?"}]

function buildParam(setting) {
  return encodeURIComponent(setting.name) + '=' + encodeURIComponent(setting.value);
}

function buildParams(settings) {
  return settings.reduce(function(prev, curr){
    if (typeof prev != 'string') {
      prev = buildParam(prev);
    }
    return prev += '&' + buildParam(curr);
  });
}

buildParams(settings);

Perhaps QR codes would be a near addition to follow.

@wwebfor wwebfor added this to the 2. New features milestone Dec 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants