Git Product home page Git Product logo

learning-area's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

learning-area's Issues

refactor code

function result() {
let isCN = document.getElementById("cn").checked;
let newStory = isCN ? storyTextZh : storyText;
let insert0 = isCN ? insertA : insertX;
let insert1 = isCN ? insertB : insertY;
let insert2 = isCN ? insertC : insertZ;

let replace0 = isCN ? ':inserta:' : ':insertx:';
let replace1 = isCN ? ':insertb:' : ':inserty:';
let replace2 = isCN ? ':insertc:' : ':insertz:';
let placeName = isCN ? '李雷' : 'Bob';

newStory = newStory.replace(replace0, randomValueFromArray(insert0));
newStory = newStory.replace(replace0, randomValueFromArray(insert0));
newStory = newStory.replace(replace1, randomValueFromArray(insert1));
newStory = newStory.replace(replace2, randomValueFromArray(insert2));

if(customName.value !== '') {
    var name = customName.value;
    newStory = newStory.replace(placeName, name);
}

if(document.getElementById("uk").checked) {
    const weight = Math.round(300 * 0.0714286) + ' stone';
    const temperature = Math.round((94 - 32) * 5 / 9) + ' centigrade';
    newStory = newStory.replace('94 fahrenheit', temperature);
    newStory = newStory.replace('300 pounds', weight);
}

story.textContent = newStory;
story.style.visibility = 'visible';
}

refactor

function result() {
let isCN = document.getElementById("cn").checked;
let newStory = isCN ? storyTextZh : storyText;
let insert0 = isCN ? insertA : insertX;
let insert1 = isCN ? insertB : insertY;
let insert2 = isCN ? insertC : insertZ;

let replace0 = isCN ? ':inserta:' : ':insertx:';
let replace1 = isCN ? ':insertb:' : ':inserty:';
let replace2 = isCN ? ':insertc:' : ':insertz:';
let placeName = isCN ? '李雷' : 'Bob';

newStory = newStory.replace(replace0, randomValueFromArray(insert0));
newStory = newStory.replace(replace0, randomValueFromArray(insert0));
newStory = newStory.replace(replace1, randomValueFromArray(insert1));
newStory = newStory.replace(replace2, randomValueFromArray(insert2));

if(customName.value !== '') {
    var name = customName.value;
    newStory = newStory.replace(placeName, name);
}

if(document.getElementById("uk").checked) {
    const weight = Math.round(300 * 0.0714286) + ' stone';
    const temperature = Math.round((94 - 32) * 5 / 9) + ' centigrade';
    newStory = newStory.replace('94 fahrenheit', temperature);
    newStory = newStory.replace('300 pounds', weight);
}

story.textContent = newStory;
story.style.visibility = 'visible';

}

404 error

when I click a "raw" button, the firfox can't copy it properly. It jumps to error pages.

color picker tool 需要更新

由于MDN代码变动,原mdn.mozillademos.org域已不负责存储图片,故出现了这些404请求代码。颜色选择器例子中的图片资源需要重新引用,特此记录此issue。

image

meta-example.html has problem

I follow the steps
image
and add <script> and <style>
I can not get same result like that.

So I checked. the console gives this error
image

I found some pages that said <script> should be after the body.

I tried it works.

In the meta-example.html there has "defer". It means after HTML body loaded , load this.
<script src="script.js" defer></script>

My point is this, learn page does not include what is defer means.

could you add this defer information on MDN learn page? (https://developer.mozilla.org/zh-CN/docs/learn/HTML/Introduction_to_HTML/The_head_metadata_in_HTML)

async的用法是不是有问题?

很多章节的js文件中都是进行操作DOM,又没有DOMContentLoaded的,而在HTML中它们几乎都是用的<script async>这种形式的标签。

<head>
    <script src="script.js" async></script>
</head>

但查其他资料却都是说 async 异步加载完立刻执行,最好不要用于上面那种操作DOM的情况:Script Tag - async & defer

而 MDN 的入门文档却说这样用是对的,比如 什么是 JavaScript? 里介绍如何避免在解析HTML文档之前调用javascript的部分:
【在上文的“内部”、“外部”示例中,JavaScript 调用于文档头处,解析 HTML 文档体之前。这样做是有隐患的,需要使用一些结构来避免错误发生。】
【“内部”示例使用了以下结构:这是一个事件监听器,它监听浏览器的 "DOMContentLoaded" 事件,即 HTML 文档体加载、解释完毕事件。事件触发时将调用 " . . ." 处的代码,从而避免了错误发生(事件 的概念稍后学习)。】
【“外部”示例中使用了 JavaScript 的一项现代技术(async “异步”属性)来解决这一问题,它告知浏览器在遇到 <script> 元素时不要中断后续 HTML 内容的加载。注:“外部”示例中 async 属性可以解决调用顺序问题,因此无需使用 DOMContentLoaded 事件。而 async 只能用于外部脚本,因此不适用于“内部”示例。】

再比如笑话生成器 的示例代码。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.