chore(unused): Remove unused files
This commit is contained in:
committed by
mrugesh mohapatra
parent
10bee0f025
commit
6d6f8af647
@ -1,16 +0,0 @@
|
||||
import store from '@freecodecamp/store';
|
||||
|
||||
const key = '__cold-storage__';
|
||||
export function isColdStored() {
|
||||
return store.has(key);
|
||||
}
|
||||
|
||||
export function getColdStorage() {
|
||||
const coldReloadData = store.get(key);
|
||||
store.remove(key);
|
||||
return coldReloadData;
|
||||
}
|
||||
|
||||
export function saveToColdStorage(data) {
|
||||
store.set(key, data);
|
||||
}
|
@ -1,150 +0,0 @@
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
var testTimeout = 5000;
|
||||
var Rx = document.Rx;
|
||||
var frameReady = document.__frameReady;
|
||||
var helpers = Rx.helpers;
|
||||
var chai = parent.chai;
|
||||
var source = document.__source;
|
||||
var __getUserInput = document.__getUserInput || (x => x);
|
||||
var checkChallengePayload = document.__checkChallengePayload;
|
||||
|
||||
// Fake Deep Equal dependency
|
||||
/* eslint-disable no-unused-vars */
|
||||
const DeepEqual = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
||||
|
||||
// Hardcode Deep Freeze dependency
|
||||
var DeepFreeze = (o) => {
|
||||
Object.freeze(o);
|
||||
Object.getOwnPropertyNames(o).forEach(function(prop) {
|
||||
if (o.hasOwnProperty(prop)
|
||||
&& o[prop] !== null
|
||||
&& (
|
||||
typeof o[prop] === 'object' ||
|
||||
typeof o[prop] === 'function'
|
||||
)
|
||||
&& !Object.isFrozen(o[prop])) {
|
||||
DeepFreeze(o[prop]);
|
||||
}
|
||||
});
|
||||
return o;
|
||||
};
|
||||
|
||||
if (document.Enzyme) {
|
||||
window.Enzyme = document.Enzyme;
|
||||
}
|
||||
|
||||
document.__getJsOutput = function getJsOutput() {
|
||||
if (window.__err) {
|
||||
return window.__err;
|
||||
}
|
||||
let output;
|
||||
try {
|
||||
/* eslint-disable no-eval */
|
||||
output = eval(source);
|
||||
/* eslint-enable no-eval */
|
||||
} catch (e) {
|
||||
output = e.message + '\n' + e.stack;
|
||||
window.__err = e;
|
||||
}
|
||||
return output;
|
||||
};
|
||||
|
||||
document.__runTests = function runTests(tests = []) {
|
||||
/* eslint-disable no-unused-vars */
|
||||
const code = source;
|
||||
const editor = {
|
||||
getValue() { return source; }
|
||||
};
|
||||
/* eslint-enable no-unused-vars */
|
||||
if (window.__err) {
|
||||
return Rx.Observable.from(tests)
|
||||
.map(test => {
|
||||
return {
|
||||
...test,
|
||||
err: window.__err.message + '\n' + window.__err.stack,
|
||||
message: window.__err.message,
|
||||
stack: window.__err.stack
|
||||
};
|
||||
})
|
||||
.toArray()
|
||||
.do(() => { window.__err = null; });
|
||||
}
|
||||
|
||||
// Iterate through the test one at a time
|
||||
// on new stacks
|
||||
return Rx.Observable.from(tests, null, null, Rx.Scheduler.default)
|
||||
// add delay here for firefox to catch up
|
||||
.delay(200)
|
||||
/* eslint-disable no-unused-vars */
|
||||
.flatMap(({ text, testString }) => {
|
||||
const assert = chai.assert;
|
||||
const getUserInput = __getUserInput;
|
||||
/* eslint-enable no-unused-vars */
|
||||
const newTest = { text, testString };
|
||||
let test;
|
||||
let __result;
|
||||
|
||||
// uncomment the following line to inspect
|
||||
// the framerunner as it runs tests
|
||||
// make sure the dev tools console is open
|
||||
// debugger;
|
||||
try {
|
||||
/* eslint-disable no-eval */
|
||||
// eval test string to actual JavaScript
|
||||
// This return can be a function
|
||||
// i.e. function() { assert(true, 'happy coding'); }
|
||||
test = eval(testString);
|
||||
/* eslint-enable no-eval */
|
||||
if (typeof test === 'function') {
|
||||
|
||||
// all async tests must return a promise or observable
|
||||
// sync tests can return Any type
|
||||
__result = test(getUserInput);
|
||||
|
||||
if (helpers.isPromise(__result)) {
|
||||
// turn promise into an observable
|
||||
__result = Rx.Observable.fromPromise(__result);
|
||||
}
|
||||
}
|
||||
|
||||
if (!__result || typeof __result.subscribe !== 'function') {
|
||||
// make sure result is an observable
|
||||
__result = Rx.Observable.of(null);
|
||||
}
|
||||
} catch (e) {
|
||||
// something threw an uncaught error
|
||||
// we catch here and wrap it in an observable
|
||||
__result = Rx.Observable.throw(e);
|
||||
}
|
||||
return __result
|
||||
.timeout(testTimeout)
|
||||
.map(() => {
|
||||
// we don't need the result of a promise/observable/cb here
|
||||
// all data asserts should happen further up the chain
|
||||
// mark test as passing
|
||||
newTest.pass = true;
|
||||
return newTest;
|
||||
})
|
||||
.catch(err => {
|
||||
// we catch the error here to prevent the error from bubbling up
|
||||
// and collapsing the pipe
|
||||
let message = (err.message || '');
|
||||
const assertIndex = message.indexOf(': expected');
|
||||
if (assertIndex !== -1) {
|
||||
message = message.slice(0, assertIndex);
|
||||
}
|
||||
message = message.replace(/<code>(.*?)<\/code>/g, '$1');
|
||||
newTest.err = err.message + '\n' + err.stack;
|
||||
newTest.stack = err.stack;
|
||||
newTest.message = message;
|
||||
// RxJS catch expects an observable as a return
|
||||
return Rx.Observable.of(newTest);
|
||||
});
|
||||
})
|
||||
// gather tests back into an array
|
||||
.toArray();
|
||||
};
|
||||
|
||||
// notify that the window methods are ready to run
|
||||
frameReady.onNext({ checkChallengePayload });
|
||||
});
|
150
client/main.js
150
client/main.js
@ -1,150 +0,0 @@
|
||||
import { aboutUrl, donateUrl } from '../common/utils/constantStrings.json';
|
||||
|
||||
var main = window.main || {};
|
||||
|
||||
main.ga = window.ga || function() {};
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
const { Observable } = window.Rx;
|
||||
var CSRF_HEADER = 'X-CSRF-Token';
|
||||
|
||||
var setCSRFToken = function(securityToken) {
|
||||
jQuery.ajaxPrefilter(function(options, _, xhr) {
|
||||
if (!xhr.crossDomain) {
|
||||
xhr.setRequestHeader(CSRF_HEADER, securityToken);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
setCSRFToken($('meta[name="csrf-token"]').attr('content'));
|
||||
|
||||
$('img').on('error', function() {
|
||||
$(this)
|
||||
.unbind('error')
|
||||
.attr(
|
||||
'src',
|
||||
'https://s3.amazonaws.com/freecodecamp/camper-image-placeholder.png'
|
||||
);
|
||||
});
|
||||
|
||||
$.each($('.sr-only'), function(i, span) {
|
||||
if ($(span).text() === ' Complete') {
|
||||
$(span).parents('p').addClass('manip-hidden');
|
||||
}
|
||||
});
|
||||
|
||||
function addAlert(message = '', type = 'alert-info') {
|
||||
return $('.flashMessage').append($(`
|
||||
<div class='alert ${type}'>
|
||||
<button class='close' type='button', data-dismiss='alert'>
|
||||
<i class="fas fa-times-circle" />
|
||||
</Button>
|
||||
<div>${message}</div>
|
||||
</div>
|
||||
`));
|
||||
}
|
||||
|
||||
function toggleNightMode() {
|
||||
if (!main.userId) {
|
||||
return addAlert('You must be logged in to use our themes.');
|
||||
}
|
||||
const iframe$ = document.getElementById('map-aside-frame');
|
||||
const body$ = $('body');
|
||||
if (iframe$) {
|
||||
iframe$.src = iframe$.src;
|
||||
}
|
||||
body$.hide();
|
||||
let updateThemeTo;
|
||||
if (body$.hasClass('night')) {
|
||||
body$.removeClass('night');
|
||||
updateThemeTo = 'default';
|
||||
} else {
|
||||
body$.addClass('night');
|
||||
updateThemeTo = 'night';
|
||||
}
|
||||
body$.fadeIn('100');
|
||||
const options = {
|
||||
url: `/api/users/${main.userId}/update-theme`,
|
||||
type: 'POST',
|
||||
data: { theme: updateThemeTo },
|
||||
dataType: 'json'
|
||||
};
|
||||
return $.ajax(options)
|
||||
.done(() => console.log('theme updated successfully'))
|
||||
.fail(err => {
|
||||
let message;
|
||||
try {
|
||||
message = JSON.parse(err.responseText).error.message;
|
||||
} catch (error) {
|
||||
return null;
|
||||
}
|
||||
if (!message) {
|
||||
return null;
|
||||
}
|
||||
return addAlert(message);
|
||||
});
|
||||
}
|
||||
|
||||
Observable.merge(
|
||||
Observable.fromEvent($('#night-mode'), 'click'),
|
||||
Observable.create(observer => {
|
||||
window.Mousetrap.bind('g t n', () => observer.onNext());
|
||||
})
|
||||
)
|
||||
.debounce(500)
|
||||
.subscribe(toggleNightMode, err => console.error(err));
|
||||
|
||||
// Hot Keys
|
||||
window.Mousetrap.bind('g n n', () => {
|
||||
// Next Challenge
|
||||
window.location = '/challenges/next-challenge';
|
||||
});
|
||||
window.Mousetrap.bind('g n m', () => {
|
||||
// Map
|
||||
window.location = '/map';
|
||||
});
|
||||
window.Mousetrap.bind('g n a', () => {
|
||||
// About
|
||||
window.location = aboutUrl;
|
||||
});
|
||||
window.Mousetrap.bind('g n d', () => {
|
||||
// Donate
|
||||
window.location = donateUrl;
|
||||
});
|
||||
window.Mousetrap.bind('g n o', () => {
|
||||
// Settings
|
||||
window.location = '/settings';
|
||||
});
|
||||
window.Mousetrap.bind('g n r', () => {
|
||||
// Repo
|
||||
window.location = 'https://github.com/freecodecamp/freecodecamp/';
|
||||
});
|
||||
|
||||
(function getFlyer() {
|
||||
const flyerKey = '__flyerId__';
|
||||
$.ajax({
|
||||
url: '/api/flyers/findOne',
|
||||
method: 'GET',
|
||||
dataType: 'JSON',
|
||||
data: { filter: { order: 'id DESC' } }
|
||||
})
|
||||
// log error
|
||||
.fail(err => console.error(err))
|
||||
.done(flyer => {
|
||||
const lastFlyerId = localStorage.getItem(flyerKey);
|
||||
if (
|
||||
!flyer ||
|
||||
!flyer.isActive ||
|
||||
lastFlyerId === flyer.id
|
||||
) {
|
||||
return;
|
||||
}
|
||||
$('#dismiss-bill').on('click', () => {
|
||||
localStorage.setItem(flyerKey, flyer.id);
|
||||
});
|
||||
$('#bill-content').html(flyer.message);
|
||||
$('#bill-board').fadeIn();
|
||||
});
|
||||
}());
|
||||
});
|
@ -23,5 +23,4 @@ html(lang='en').full-size
|
||||
fccTheme = null;
|
||||
}
|
||||
})();
|
||||
script(src=rev('/js', 'vendor-challenges.js'))
|
||||
script(src=cacheBreaker(rev('/js', 'bundle.js')))
|
||||
|
@ -13,8 +13,6 @@ script.
|
||||
global.main.isLoggedIn = !{JSON.stringify(!!user)};
|
||||
global.main.userId = !{JSON.stringify(user && user.id || false)};
|
||||
}(window))
|
||||
script(src=rev('/js', 'vendor-main.js'))
|
||||
script(src=rev('/js', 'main.js'))
|
||||
script(defer, src=rev('/js/lib/fontawesome', 'fa-brands.min.js'))
|
||||
script(defer, src=rev('/js/lib/fontawesome', 'fa-solid.min.js'))
|
||||
script(src=rev('/js/lib/fontawesome', 'fontawesome.min.js'))
|
||||
|
Reference in New Issue
Block a user