-
Notifications
You must be signed in to change notification settings - Fork 16
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
init #3
base: master
Are you sure you want to change the base?
init #3
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"><head> | ||
<meta charset="UTF-8"> | ||
<title>1-introduction</title> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
<body> | ||
|
||
<h1>Preface</h1> | ||
|
||
<p>Before you begin, it is important to understand various styles employed in this book. Please do not skip this section, because it contains important information that will aid you as you read the book.</p> | ||
|
||
<h2>More code, less words</h2> | ||
|
||
<p>Please examine the code examples in detail. The text should be viewed as secondary to the code itself. It is my opinion that a code example is worth a thousand words. Do not worry if youʼre initially confused by explanations. Examine the code. Tinker with it. Reread the code comments. Repeat this process until the concept being explained becomes clear. I hope you achieve a level of expertise such that well-documented code is all you need to grok a programming concept.</p> | ||
|
||
<h2>Exhaustive code and repetition</h2> | ||
|
||
<p>You will probably curse me for repeating myself and for being so comprehensive with my code examples. And while I might deserve it, I prefer to err on the side of being exact, verbose, and repetitive, rather than make false assumptions authors often make about their reader. Yes, both can be annoying, depending upon what knowledge you bring to the subject, but they can also serve a useful purpose for those who want to learn a subject in detail.</p> | ||
|
||
<h2>Color-coding Conventions</h2> | ||
|
||
<p>In the JavaScript code examples (example shown below), orange is used to highlight code directly relevant to the concept being discussed. Any additional code used to support the orange colored code will be green. The color gray in the code examples is reserved for JavaScript comments (example shown below).</p> | ||
|
||
<pre><code><!DOCTYPE html><html lang="en"><body><script> | ||
|
||
<span class="comment">// this is a comment about a specific part of the code</span> | ||
var foo = <span class="string">'calling out this part of the code'</span>; | ||
|
||
</script></body></html></code></pre> | ||
|
||
<p>In addition to code examples being color-coded, the text in this book is colored so as to denote JavaScript words/keywords v.s. JavaScript code v.s. regular text. Below, I take an excerpt from the book to demonstrate this coloring semantic.</p> | ||
|
||
<p>"Consider that the <em>cody</em> object created from the <code>Object()</code> constructor function (i.e <code>var cody = new Object()</code>) is not really different from a string object created via the <code>String()</code>constructor function. To drive this fact home, examine the code below:"</p> | ||
|
||
<p>Notice the use of gray italic text for code references, orange text for JavaScript words/keywords, and regular black text for everything in-between.</p> | ||
|
||
<h2>jsFiddle, JS Bin, and Firebug lite-dev</h2> | ||
|
||
<p>The majority of code examples in this book are linked to a corresponding <a href="http://jsfiddle.net/">jsFiddle</a> page, where the code can be tweaked and executed online. The jsFiddle examples have been configured to use the <a href="http://fbug.googlecode.com/svn/lite/branches/firebug1.3/content/firebug-lite-dev.js">Firebug lite-dev</a> plugin so that the log function (i.e. <code>console.log</code>) will work in most any modern browser regardless of if the browser has its own console. Before reading this book make sure you are comfortable with the <a href="http://stackoverflow.com/questions/4743730/what-is-console-log-and-how-do-i-use-it">usage and purpose</a> of <code>console.log</code>.</p> | ||
|
||
<p>In situations where jsFiddle & Firebug lite-dev caused complications with the JavaScript code <a href="http://jsbin.tumblr.com/about">JS Bin</a> & Firebug Lite-dev will be used. I've tried to avoid a dependency on a browser console by using Firebug lite-dev but with certain code examples the solution itself gets in the way of code execution. In these situations the console built into your web browser will have to be leveraged to output logs. If you are not using a browser with a built in JavaScript console I would suggest <a href="http://browsehappy.com/">upgrading or switching browsers</a>.</p> | ||
|
||
<p>When JS Bin is used, keep in mind that the code has to be executed manually (clicking 'Render') which differs from the page load execution done by jsFiddle.</p> | ||
|
||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
body { | ||
margin: 0 auto; | ||
max-width: 670px; | ||
} | ||
|
||
h1, h2 { | ||
border-bottom: 3px solid #eaeaea; | ||
color: #444; | ||
} | ||
|
||
h1 { | ||
margin: 46px 0 104px; | ||
padding-bottom: 7px; | ||
text-align: right; | ||
font: normal 39px "Arial Narrow", sans-serif; | ||
} | ||
|
||
h2 { | ||
margin: 56px 0 18px; | ||
padding-bottom: 9px; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Аналогично комментарию выше |
||
border-width: 2px; | ||
font: bold 17px "Tahoma", sans-serif; | ||
} | ||
|
||
p { | ||
margin-bottom: 22px; | ||
font: 14px/25px "Helvetica", sans-serif; | ||
} | ||
|
||
pre { | ||
margin: 28px 0 25px; | ||
padding-bottom: 11px; | ||
border-bottom: 2px solid #ffd966; | ||
font-size: 12px; | ||
|
||
} | ||
|
||
pre:before { | ||
display: block; | ||
margin-bottom: 16px; | ||
height: 20px; | ||
background: #ffd966; | ||
background: linear-gradient(to bottom, #fff2c5 0%, #ffdd66 100%); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. в каких браузерах это отработает? :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. На удивление, последние фаерфокс, хром и опера, опера 12, интернет эксплорер 10. Остальные увидят симпатичный оранжевый бордер, что, я считаю, тоже неплохо. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Почему на удивление? Как расширить поддержку? и да, ie8 никогда не умел работать со стандартными градиентами :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Потому что у спецификации статус draft (http://dev.w3.org/csswg/css-images-3/), а все свежие браузеры уже понимают свойство без префиксов.
Для кого, ие 8-9? Наверное, использовать фильтры. Как last resort мера — отдельный div с фоном-картинкой. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ок 👍 |
||
content: ""; | ||
} | ||
|
||
pre code { | ||
color: #34581e; | ||
} | ||
|
||
pre .comment { | ||
color: #7a7a7a; | ||
} | ||
|
||
pre .string { | ||
color: #b45f06; | ||
} | ||
|
||
code { | ||
color: #b45f06; | ||
font: bold 1em "Courier New", monospace; | ||
} | ||
|
||
em { | ||
color: #5f5f5f; | ||
} | ||
|
||
@media print { | ||
body { | ||
max-width: none; | ||
} | ||
|
||
a, code, em, h1, h2, pre code, pre .comment, pre .string { | ||
color: #000; | ||
} | ||
|
||
pre { | ||
border: none | ||
} | ||
|
||
a { | ||
text-decoration: none; | ||
} | ||
|
||
a:after { | ||
content: ' (' attr(href) ')'; | ||
} | ||
} |
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.
padding: 0 0 7px 0;
чуток короче, есть нет необходимости сохранить определённые заранее.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.
Я правильно понимаю, мы пару байт экономим?
Читаемость, на мой взгляд, резко падает.
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.
да, экономим, и читаемость тут не падает, ты же свойство выше нормально читаешь?
margin: 46px 0 104px
-- понятно что оно разложится в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.
Строку выше я читаю как «Я хочу выставить отступ снизу и обнулить остальные отступы».
Как поддерживающему код разработчику понять, что я обнуляю отступы только для экономии места?
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.
Даже так, правильнее экономнее будет
padding: 0 0 7px;
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.
тут не только экономия, я как раз в своей записи по коду вижу что у этого элемента есть отступ только с низу, в твоём случае я полез смотреть снова код, так как попытался понять не определён ли у тебя где выше паддинг более глобально, а в этом месте ты его точечно уменьшаешь