minor renovations, beautify round 2 (final)

This commit is contained in:
Ilya Kantor 2015-03-12 10:26:02 +03:00
parent fad6615c42
commit 8410ce6421
212 changed files with 1981 additions and 1717 deletions

View file

@ -11,7 +11,7 @@
```js
// go.js содержит функцию go()
addScript("go.js", function() {
go();
go();
});
```

View file

@ -9,6 +9,7 @@
Пример использования:
```js
//+ no-beautify
addScripts(["a.js", "b.js", "c.js"], function() { a() });
/* функция a() описана в a.js и использует b.js,c.js */
```

View file

@ -39,9 +39,9 @@ document.body.appendChild(script);
*!*
script.onload = function() {
// после выполнения скрипта становится доступна функция _
alert(_); // её код
}
// после выполнения скрипта становится доступна функция _
alert( _ ); // её код
}
*/!*
```
@ -65,7 +65,7 @@ document.body.appendChild(script);
*!*
script.onerror = function() {
alert("Ошибка: " + this.src);
alert( "Ошибка: " + this.src );
};
*/!*
```
@ -89,7 +89,7 @@ script.onerror = function() {
Например, рабочий скрипт:
```js
//+ run
//+ run no-beautify
var script = document.createElement('script');
script.src = "https://code.jquery.com/jquery.js";
document.documentElement.appendChild(script);
@ -104,7 +104,7 @@ script.onreadystatechange = function() {
Скрипт с ошибкой:
```js
//+ run
//+ run no-beautify
var script = document.createElement('script');
script.src = "http://ajax.googleapis.com/404.js";
document.documentElement.appendChild(script);
@ -132,7 +132,7 @@ script.onreadystatechange = function() {
Пример ниже вызывает `afterLoad` после загрузки скрипта и работает только в IE:
```js
//+ run
//+ run no-beautify
var script = document.createElement('script');
script.src = "https://code.jquery.com/jquery.js";
document.documentElement.appendChild(script);
@ -176,7 +176,7 @@ script.src = "https://code.jquery.com/jquery.js";
document.documentElement.appendChild(script);
function afterLoad() {
alert("Загрузка завершена: " + typeof(jQuery));
alert( "Загрузка завершена: " + typeof(jQuery) );
}
script.onload = script.onerror = function() {
@ -189,7 +189,9 @@ script.onload = script.onerror = function() {
script.onreadystatechange = function() {
var self = this;
if (this.readyState == "complete" || this.readyState == "loaded") {
setTimeout(function() { self.onload() }, 0);// сохранить "this" для onload
setTimeout(function() {
self.onload()
}, 0); // сохранить "this" для onload
}
};
```
@ -221,6 +223,7 @@ script.onreadystatechange = function() {
<dd>Ставим обработчики на `onload` + `onerror`
```js
//+ no-beautify
var img = document.createElement('img');
img.onload = function() { alert("Успех "+this.src };
img.onerror = function() { alert("Ошибка "+this.src };