Merge pull request #5038 from bugron/fix/common-improvements

Some common code improvements
This commit is contained in:
Logan Tegman
2015-12-07 06:48:47 -08:00
3 changed files with 12 additions and 15 deletions

View File

@@ -175,7 +175,10 @@ window.common = (function(global) {
});
$('#search-issue').on('click', function() {
var queryIssue = window.location.href.toString().split('?')[0];
var queryIssue = window.location.href
.toString()
.split('?')[0]
.replace(/(#*)$/, '');
window.open(
'https://github.com/FreeCodeCamp/FreeCodeCamp/issues?q=' +
'is:issue is:all ' +
@@ -233,9 +236,12 @@ window.common = (function(global) {
public: true,
files: {}
};
var queryIssue = window.location.href.toString().split('?')[0];
var filename = queryIssue
.substr(queryIssue.lastIndexOf('challenges/') + 11)
var challengeLink = window.location.href
.toString()
.split('?')[0]
.replace(/(#*)$/, '');
var filename = challengeLink
.substr(challengeLink.lastIndexOf('challenges/') + 11)
.replace('/', '') + '.js';
data.files[filename] = {
@@ -244,7 +250,7 @@ window.common = (function(global) {
'\n' +
(common.username ? '// Author: @' + common.username + '\n' : '') +
'// Challenge: ' +
queryIssue +
challengeLink +
'\n' +
'// Learn to Code at Free Code Camp (www.freecodecamp.com)' +
'\n\n' +

View File

@@ -13,7 +13,7 @@ window.common = (function(global) {
!key ||
typeof key !== 'string'
) {
console.log('unable to save to storage');
console.log('unable to read from storage');
return '';
}
return '' + localStorage.getItem(key + 'Val');