-
Notifications
You must be signed in to change notification settings - Fork 56
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
Options update #29
Options update #29
Conversation
Thanks for your contribution! I am more inclined to accept this PR rather than #30. In summary, if I already have the extension installed and I update to the new version, everything should continue working without my intervention. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Sorry for taking so long to review it.
It looks good but there are several issues of varying severity, as you can see in the comments. Last moment I decided it would be easier to change them myself, so I'm approving the PR.
useOldStyleLinks: false | ||
}, function(items) { | ||
var uri = ''; | ||
if (selection != '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use consistent equality operator (see above)
|
||
if (selection != "") { uri += '/' + esc(selection); }; | ||
function createCaptureURL(template, title, url, selection, oldStyle) { | ||
if (oldStyle == true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if oldStyle is a boolean, there is no need for == true
if (selection != "") { uri += '/' + esc(selection); }; | ||
function createCaptureURL(template, title, url, selection, oldStyle) { | ||
if (oldStyle == true) | ||
return "org-protocol://capture:/"+template+'/'+url+'/'+title + ((selection === '') ? '' : ('/' + selection)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use consistent equality operator (see below)
chrome.storage.sync.get({ | ||
selectedTemplate: 'p', | ||
unselectedTemplate: 'L', | ||
useOldStyleLinks: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make the default to old style links, for the benefit of those who already have the extension installed.
|
||
console.log("Capturing the following URI with org-protocol:", uri); | ||
function captureIt() { | ||
var selection = window.getSelection().toString(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please escape the selection as well, not just the title.
</tr> | ||
<tr> | ||
<td> | ||
Use Old-Style Links? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add write that new-style is the recommended option for supported org-mode versions above 9.0
if (oldStyle == true) | ||
return "org-protocol://capture:/"+template+'/'+url+'/'+title + ((selection === '') ? '' : ('/' + selection)); | ||
else | ||
return "org-protocol://capture?template="+template+'&url='+url+'&title='+title+((selection === '') ? '' : ('&body=' + selection)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are using a regular URL syntax here, the selection should be escaped using encodeURIComponent as well.
Create User-settable options and enable both new and old-style capture Links