Skip to content

TCA-480 - replace learn.freecodecamp.org links with the platformui links #84

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

Merged
merged 2 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 0 additions & 59 deletions client/src/components/layouts/tc-integration.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ class TcIntegrationLayout extends Component<TcIntegrationLayoutProps> {

window.addEventListener('online', this.updateOnlineStatus);
window.addEventListener('offline', this.updateOnlineStatus);
window.addEventListener('click', this.externalLinkHandler);
}

componentDidUpdate(prevProps: TcIntegrationLayoutProps) {
Expand All @@ -113,64 +112,6 @@ class TcIntegrationLayout extends Component<TcIntegrationLayoutProps> {
window.removeEventListener('offline', this.updateOnlineStatus);
}

externalLinkHandler = (event: MouseEvent) => {
// prettier is the worst

// if we're not clicking an anchor tag, there's nothing to do
const eventTarget = event.target as HTMLElement;
const anchorTag = eventTarget.closest('a');
if (!anchorTag) {
return;
}

// if the target of the click isn't external, there's nothing to do
const target = anchorTag;
const url = new URL(target.href);
if (url.host === window.location.host) {
return;
}

// stop the click so we can alter it
event.stopPropagation();
event.preventDefault();

// if this is a freecodecamp lesson, change its domain and path
const fccHost = 'freecodecamp.org';
if (url.host.endsWith(fccHost)) {
// TODO: it would be nice to not require that the FCC
// app knows about the paths in the platform UI, but
// creating a way to share this info would be complex and
// time consuming, so we can handle it when we get another
// provider.

// set the pathname for the 2 flavors of lesson URL
const platformPathPrefix = 'learn/freeCodeCamp';
const learnPrefix = '/learn/';
let updateHost = false;
if (url.host === `learn.${fccHost}`) {
url.pathname = `${platformPathPrefix}${url.pathname}`;
updateHost = true;
} else if (
url.host === `www.${fccHost}` &&
url.pathname.startsWith(learnPrefix)
) {
url.pathname = url.pathname.replace(
learnPrefix,
`/${platformPathPrefix}/`
);
updateHost = true;
}

// set the host to the iframe's parent domain
if (updateHost) {
url.host = new URL(document.referrer).host;
}
}

// now open the url in a new tab
window.open(url, '_blank');
};

updateOnlineStatus = () => {
const { onlineStatusChange } = this.props;
const isOnline =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dashedName: assignment-with-a-returned-value

# --description--

如果你還記得我們在這一節<a href="/learn/javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator" target="_blank" rel="noopener noreferrer nofollow">使用賦值運算符存儲值</a>中的討論,賦值之前,先完成等號右邊的操作。 這意味着我們可以獲取函數的返回值,並將其賦值給一個變量。
如果你還記得我們在這一節<a href="https://platform-ui.topcoder.com/learn/freeCodeCamp/javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator" target="_blank" rel="noopener noreferrer nofollow">使用賦值運算符存儲值</a>中的討論,賦值之前,先完成等號右邊的操作。 這意味着我們可以獲取函數的返回值,並將其賦值給一個變量。

假設我們有一個預先定義的函數 `sum` ,它將兩個數相加,然後:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dashedName: generate-random-fractions-with-javascript

在 JavaScript 中,可以用 `Math.random()` 生成一個在`0`(包括 0)到 `1`(不包括 1)之間的隨機小數。 因此 `Math.random()` 可能返回 `0`,但絕不會返回 `1`。

**提示:**<a href="/learn/javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator" target="_blank" rel="noopener noreferrer nofollow">使用賦值運算符存儲值</a>這一節講過,所有函數調用將在 `return` 執行之前結束,因此我們可以 `return`(返回)`Math.random()` 函數的值。
**提示:**<a href="https://platform-ui.topcoder.com/learn/freeCodeCamp/javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator" target="_blank" rel="noopener noreferrer nofollow">使用賦值運算符存儲值</a>這一節講過,所有函數調用將在 `return` 執行之前結束,因此我們可以 `return`(返回)`Math.random()` 函數的值。

# --instructions--

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ myFun();
修改函數 `abTest` 當 `a` 或 `b` 小於 `0` 時,函數立即返回一個 `undefined` 並退出。

**提示**
記住 <a href="https://platform-ui.topcoder.com/learn/javascript-algorithms-and-data-structures/basic-javascript/understanding-uninitialized-variables" target="_blank" rel="noopener noreferrer nofollow"><code>undefined</code> 是關鍵字 </a>,不是字符串.
記住 <a href="https://platform-ui.topcoder.com/learn/freeCodeCamp/javascript-algorithms-and-data-structures/basic-javascript/understanding-uninitialized-variables" target="_blank" rel="noopener noreferrer nofollow"><code>undefined</code> 是關鍵字 </a>,不是字符串.

# --hints--

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dashedName: use-recursion-to-create-a-countdown

# --description--

在上一個<a href="/learn/javascript-algorithms-and-data-structures/basic-javascript/replace-loops-using-recursion" target="_blank" rel="noopener noreferrer nofollow">挑戰</a>中,你學習了怎樣用遞歸來代替 `for` 循環。 現在來學習一個更復雜的函數,函數返回一個從 `1` 到傳遞給函數的指定數字的連續數字數組。
在上一個<a href="https://platform-ui.topcoder.com/learn/freeCodeCamp/javascript-algorithms-and-data-structures/basic-javascript/replace-loops-using-recursion" target="_blank" rel="noopener noreferrer nofollow">挑戰</a>中,你學習了怎樣用遞歸來代替 `for` 循環。 現在來學習一個更復雜的函數,函數返回一個從 `1` 到傳遞給函數的指定數字的連續數字數組。

正如上一個挑戰提到的,會有一個 <dfn>base case</dfn>。 base case 告訴遞歸函數什麼時候不再需要調用其自身。 這是簡單 情況,返回得到的值。 還有 <dfn>recursive call</dfn>,繼續用不同的參數調用自身。 如果函數無誤,一直執行直到 base case 爲止。

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dashedName: compare-scopes-of-the-var-and-let-keywords

# --description--

如果你不熟悉 `let`的話, 請查看 <a href="/learn/javascript-algorithms-and-data-structures/basic-javascript/explore-differences-between-the-var-and-let-keywords" target="_blank" rel="noopener noreferrer nofollow">這個介紹 <code>let</code>和 <code>var</code> 關鍵字之間的差異的挑戰</a>
如果你不熟悉 `let`的話, 請查看 <a href="https://platform-ui.topcoder.com/learn/freeCodeCamp/javascript-algorithms-and-data-structures/basic-javascript/explore-differences-between-the-var-and-let-keywords" target="_blank" rel="noopener noreferrer nofollow">這個介紹 <code>let</code>和 <code>var</code> 關鍵字之間的差異的挑戰</a>

使用 `var` 關鍵字聲明變量時,它是全局聲明的,如果在函數內部聲明則是局部聲明的。

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dashedName: mutate-an-array-declared-with-const

# --description--

如果你不熟悉 `const`,請查看[這個挑戰](/learn/javascript-algorithms-and-data-structures/basic-javascript/declare-a-read-only-variable-with-the-const-keyword)。
如果你不熟悉 `const`,請查看[這個挑戰](https://platform-ui.topcoder.com/learn/freeCodeCamp/javascript-algorithms-and-data-structures/basic-javascript/declare-a-read-only-variable-with-the-const-keyword)。

`const` 聲明在現代 JavaScript 中有很多用例。

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dashedName: introducing-inline-styles

# --description--

還有其他複雜的概念可以爲 React 代碼增加強大的功能。 但是,你可能會想知道更簡單的問題,比如:如何對在 React 中創建的 JSX 元素添加樣式。 你可能知道,由於[將 class 應用於 JSX 元素的方式](/learn/front-end-development-libraries/react/define-an-html-class-in-jsx)與 HTML 中的使用並不完全相同。
還有其他複雜的概念可以爲 React 代碼增加強大的功能。 但是,你可能會想知道更簡單的問題,比如:如何對在 React 中創建的 JSX 元素添加樣式。 你可能知道,由於[將 class 應用於 JSX 元素的方式](https://platform-ui.topcoder.com/learn/freeCodeCamp/front-end-development-libraries/react/define-an-html-class-in-jsx)與 HTML 中的使用並不完全相同。

如果從樣式表導入樣式,它就沒有太大的不同。 使用 `className` 屬性將 class 應用於 JSX 元素,並將樣式應用於樣式表中的 class。 另一種選擇是使用內聯樣式,這在 ReactJS 開發中非常常見。

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Redux `store` 是一個保存和管理應用程序狀態的`state`, 可以使

聲明一個 `store` 變量並把它分配給 `createStore()` 方法,然後把 `reducer` 作爲一個參數傳入即可。

**注意**: 編輯器中的代碼使用 ES6 默認參數語法將 state 的值初始化爲 `5`, 如果你不熟悉默認參數,你可以參考[ES6 全部課程](https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/set-default-parameters-for-your-functions),它裏面涵蓋了這個內容。
**注意**: 編輯器中的代碼使用 ES6 默認參數語法將 state 的值初始化爲 `5`, 如果你不熟悉默認參數,你可以參考[ES6 全部課程](https://platform-ui.topcoder.com/learn/freeCodeCamp/javascript-algorithms-and-data-structures/es6/set-default-parameters-for-your-functions),它裏面涵蓋了這個內容。

# --hints--

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dashedName: use-assert-isok-and-assert-isnotok

`isOk()` 用來測試值是否爲真值,`isNotOk()` 用來測試值是否爲假值。

可以在[過濾數組中的假值](https://platform-ui.topcoder.com/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/falsy-bouncer)這個挑戰中瞭解更多關於真值和假值的信息。
可以在[過濾數組中的假值](https://platform-ui.topcoder.com/learn/freeCodeCamp/javascript-algorithms-and-data-structures/basic-algorithm-scripting/falsy-bouncer)這個挑戰中瞭解更多關於真值和假值的信息。

# --instructions--

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Let's write a `removeAt` method that removes the `element` at a given `index`. T

A common technique used to iterate through the elements of a linked list involves a <dfn>'runner'</dfn>, or sentinel, that 'points' at the nodes that your code is comparing. In our case, starting at the `head` of our list, we start with a `currentIndex` variable that starts at `0`. The `currentIndex` should increment by one for each node we pass.

Just like our `remove(element)` method, which [we covered in a previous lesson](/learn/coding-interview-prep/data-structures/remove-elements-from-a-linked-list), we need to be careful not to orphan the rest of our list when we remove the node in our `removeAt(index)` method. We keep our nodes contiguous by making sure that the node that has reference to the removed node has a reference to the next node.
Just like our `remove(element)` method, which [we covered in a previous lesson](https://platform-ui.topcoder.com/learn/freeCodeCamp/coding-interview-prep/data-structures/remove-elements-from-a-linked-list), we need to be careful not to orphan the rest of our list when we remove the node in our `removeAt(index)` method. We keep our nodes contiguous by making sure that the node that has reference to the removed node has a reference to the next node.

# --instructions--

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dashedName: assignment-with-a-returned-value

# --description--

如果你还记得我们在这一节<a href="/learn/javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator" target="_blank" rel="noopener noreferrer nofollow">使用赋值运算符存储值</a>中的讨论,赋值之前,先完成等号右边的操作。 这意味着我们可以获取函数的返回值,并将其赋值给一个变量。
如果你还记得我们在这一节<a href="https://platform-ui.topcoder.com/learn/freeCodeCamp/javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator" target="_blank" rel="noopener noreferrer nofollow">使用赋值运算符存储值</a>中的讨论,赋值之前,先完成等号右边的操作。 这意味着我们可以获取函数的返回值,并将其赋值给一个变量。

假设我们有一个预先定义的函数 `sum` ,它将两个数相加,然后:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dashedName: generate-random-fractions-with-javascript

在 JavaScript 中,可以用 `Math.random()` 生成一个在`0`(包括 0)到 `1`(不包括 1)之间的随机小数。 因此 `Math.random()` 可能返回 `0`,但绝不会返回 `1`。

**提示:**<a href="/learn/javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator" target="_blank" rel="noopener noreferrer nofollow">使用赋值运算符存储值</a>这一节讲过,所有函数调用将在 `return` 执行之前结束,因此我们可以 `return`(返回)`Math.random()` 函数的值。
**提示:**<a href="https://platform-ui.topcoder.com/learn/freeCodeCamp/javascript-algorithms-and-data-structures/basic-javascript/storing-values-with-the-assignment-operator" target="_blank" rel="noopener noreferrer nofollow">使用赋值运算符存储值</a>这一节讲过,所有函数调用将在 `return` 执行之前结束,因此我们可以 `return`(返回)`Math.random()` 函数的值。

# --instructions--

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ myFun();
修改函数 `abTest` 当 `a` 或 `b` 小于 `0` 时,函数立即返回一个 `undefined` 并退出。

**提示**
记住 <a href="https://platform-ui.topcoder.com/learn/javascript-algorithms-and-data-structures/basic-javascript/understanding-uninitialized-variables" target="_blank" rel="noopener noreferrer nofollow"><code>undefined</code> 是关键字 </a>,不是字符串.
记住 <a href="https://platform-ui.topcoder.com/learn/freeCodeCamp/javascript-algorithms-and-data-structures/basic-javascript/understanding-uninitialized-variables" target="_blank" rel="noopener noreferrer nofollow"><code>undefined</code> 是关键字 </a>,不是字符串.

# --hints--

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dashedName: use-recursion-to-create-a-countdown

# --description--

在上一个<a href="/learn/javascript-algorithms-and-data-structures/basic-javascript/replace-loops-using-recursion" target="_blank" rel="noopener noreferrer nofollow">挑战</a>中,你学习了怎样用递归来代替 `for` 循环。 现在来学习一个更复杂的函数,函数返回一个从 `1` 到传递给函数的指定数字的连续数字数组。
在上一个<a href="https://platform-ui.topcoder.com/learn/freeCodeCamp/javascript-algorithms-and-data-structures/basic-javascript/replace-loops-using-recursion" target="_blank" rel="noopener noreferrer nofollow">挑战</a>中,你学习了怎样用递归来代替 `for` 循环。 现在来学习一个更复杂的函数,函数返回一个从 `1` 到传递给函数的指定数字的连续数字数组。

正如上一个挑战提到的,会有一个 <dfn>base case</dfn>。 base case 告诉递归函数什么时候不再需要调用其自身。 这是简单 情况,返回得到的值。 还有 <dfn>recursive call</dfn>,继续用不同的参数调用自身。 如果函数无误,一直执行直到 base case 为止。

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dashedName: compare-scopes-of-the-var-and-let-keywords

# --description--

如果你不熟悉 `let`的话, 请查看 <a href="/learn/javascript-algorithms-and-data-structures/basic-javascript/explore-differences-between-the-var-and-let-keywords" target="_blank" rel="noopener noreferrer nofollow">这个介绍 <code>let</code>和 <code>var</code> 关键字之间的差异的挑战</a>
如果你不熟悉 `let`的话, 请查看 <a href="https://platform-ui.topcoder.com/learn/freeCodeCamp/javascript-algorithms-and-data-structures/basic-javascript/explore-differences-between-the-var-and-let-keywords" target="_blank" rel="noopener noreferrer nofollow">这个介绍 <code>let</code>和 <code>var</code> 关键字之间的差异的挑战</a>

使用 `var` 关键字声明变量时,它是全局声明的,如果在函数内部声明则是局部声明的。

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dashedName: mutate-an-array-declared-with-const

# --description--

如果你不熟悉 `const`,请查看[这个挑战](/learn/javascript-algorithms-and-data-structures/basic-javascript/declare-a-read-only-variable-with-the-const-keyword)。
如果你不熟悉 `const`,请查看[这个挑战](https://platform-ui.topcoder.com/learn/freeCodeCamp/javascript-algorithms-and-data-structures/basic-javascript/declare-a-read-only-variable-with-the-const-keyword)。

`const` 声明在现代 JavaScript 中有很多用例。

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dashedName: introducing-inline-styles

# --description--

还有其他复杂的概念可以为 React 代码增加强大的功能。 但是,你可能会想知道更简单的问题,比如:如何对在 React 中创建的 JSX 元素添加样式。 你可能知道,由于[将 class 应用于 JSX 元素的方式](/learn/front-end-development-libraries/react/define-an-html-class-in-jsx)与 HTML 中的使用并不完全相同。
还有其他复杂的概念可以为 React 代码增加强大的功能。 但是,你可能会想知道更简单的问题,比如:如何对在 React 中创建的 JSX 元素添加样式。 你可能知道,由于[将 class 应用于 JSX 元素的方式](https://platform-ui.topcoder.com/learn/freeCodeCamp/front-end-development-libraries/react/define-an-html-class-in-jsx)与 HTML 中的使用并不完全相同。

如果从样式表导入样式,它就没有太大的不同。 使用 `className` 属性将 class 应用于 JSX 元素,并将样式应用于样式表中的 class。 另一种选择是使用内联样式,这在 ReactJS 开发中非常常见。

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Redux `store` 是一个保存和管理应用程序状态的`state`, 可以使

声明一个 `store` 变量并把它分配给 `createStore()` 方法,然后把 `reducer` 作为一个参数传入即可。

**注意**: 编辑器中的代码使用 ES6 默认参数语法将 state 的值初始化为 `5`, 如果你不熟悉默认参数,你可以参考[ES6 全部课程](https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/set-default-parameters-for-your-functions),它里面涵盖了这个内容。
**注意**: 编辑器中的代码使用 ES6 默认参数语法将 state 的值初始化为 `5`, 如果你不熟悉默认参数,你可以参考[ES6 全部课程](https://platform-ui.topcoder.com/learn/freeCodeCamp/javascript-algorithms-and-data-structures/es6/set-default-parameters-for-your-functions),它里面涵盖了这个内容。

# --hints--

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dashedName: use-assert-isok-and-assert-isnotok

`isOk()` 用来测试值是否为真值,`isNotOk()` 用来测试值是否为假值。

可以在[过滤数组中的假值](https://platform-ui.topcoder.com/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/falsy-bouncer)这个挑战中了解更多关于真值和假值的信息。
可以在[过滤数组中的假值](https://platform-ui.topcoder.com/learn/freeCodeCamp/javascript-algorithms-and-data-structures/basic-algorithm-scripting/falsy-bouncer)这个挑战中了解更多关于真值和假值的信息。

# --instructions--

Expand Down
Loading