Этот коммит содержится в:
2017-01-23 02:47:24 +03:00
родитель 9744d67202
Коммит 6644a5a52d
21 изменённых файлов: 649 добавлений и 9 удалений

55
grunt/js/bindReady.js Обычный файл
Просмотреть файл

@@ -0,0 +1,55 @@
/*
* http://javascript.ru/tutorial/events/ondomcontentloaded
* bindReady(function(){alert('dom load')})
*/
function bindReady(handler){
var called = false
function ready() { // (1)
if (called) return
called = true
handler()
}
if ( document.addEventListener ) { // (2)
document.addEventListener( "DOMContentLoaded", function(){
ready()
}, false )
} else if ( document.attachEvent ) { // (3)
// (3.1)
if ( document.documentElement.doScroll && window == window.top ) {
function tryScroll(){
if (called) return
if (!document.body) return
try {
document.documentElement.doScroll("left")
ready()
} catch(e) {
setTimeout(tryScroll, 0)
}
}
tryScroll()
}
// (3.2)
document.attachEvent("onreadystatechange", function(){
if ( document.readyState === "complete" ) {
ready()
}
})
}
// (4)
if (window.addEventListener)
window.addEventListener('load', ready, false)
else if (window.attachEvent)
window.attachEvent('onload', ready)
/* else // (4.1)
window.onload=ready
*/
}

58
grunt/js/foreach.js Обычный файл
Просмотреть файл

@@ -0,0 +1,58 @@
// Production steps of ECMA-262, Edition 5, 15.4.4.18
// Reference: http://es5.github.io/#x15.4.4.18
if (!Array.prototype.forEach) {
Array.prototype.forEach = function(callback, thisArg) {
var T, k;
if (this == null) {
throw new TypeError(' this is null or not defined');
}
// 1. Let O be the result of calling ToObject passing the |this| value as the argument.
var O = Object(this);
// 2. Let lenValue be the result of calling the Get internal method of O with the argument "length".
// 3. Let len be ToUint32(lenValue).
var len = O.length >>> 0;
// 4. If IsCallable(callback) is false, throw a TypeError exception.
// See: http://es5.github.com/#x9.11
if (typeof callback !== "function") {
throw new TypeError(callback + ' is not a function');
}
// 5. If thisArg was supplied, let T be thisArg; else let T be undefined.
if (arguments.length > 1) {
T = thisArg;
}
// 6. Let k be 0
k = 0;
// 7. Repeat, while k < len
while (k < len) {
var kValue;
// a. Let Pk be ToString(k).
// This is implicit for LHS operands of the in operator
// b. Let kPresent be the result of calling the HasProperty internal method of O with argument Pk.
// This step can be combined with c
// c. If kPresent is true, then
if (k in O) {
// i. Let kValue be the result of calling the Get internal method of O with argument Pk.
kValue = O[k];
// ii. Call the Call internal method of callback with T as the this value and
// argument list containing kValue, k, and O.
callback.call(T, kValue, k, O);
}
// d. Increase k by 1.
k++;
}
// 8. return undefined
};
}

1
grunt/js/index.js Обычный файл
Просмотреть файл

@@ -0,0 +1 @@

91
grunt/js/xmlhttp.js Обычный файл
Просмотреть файл

@@ -0,0 +1,91 @@
//xmlHttpConnect
//xH.conn(URL,Method,Vars,Function done) - assync
//xH.syn(URL,Method,Vars) - sync, return result query
function xH()
{
var xmlhttp, bComplete = false;
try
{
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
}catch (e)
{
try
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}catch (e)
{
try
{
xmlhttp = new XMLHttpRequest();
}catch (e)
{
xmlhttp = false;
}
}
}
if (!xmlhttp) return null;
this.syn = function(sURL, sMethod, sVars)
{
if (!xmlhttp) return false;
sMethod = sMethod.toUpperCase();
if (sMethod == "GET")
{
xmlhttp.open(sMethod,sURL+"?"+sVars,false);
xmlhttp.send(null);
if (xmlhttp.status == 200)
{
return xmlhttp.responseText;
}
return false;
}
else
{
xmlhttp.open(sMethod, sURL, false);
xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.send(sVars);
if (xmlhttp.status == 200)
{
return xmlhttp.responseText;
}
return false;
}
}
this.conn = function(sURL, sMethod, sVars, fnDone)
{
if (!xmlhttp) return false;
bComplete = false;
sMethod = sMethod.toUpperCase();
try
{
if (sMethod == "GET")
{
xmlhttp.open(sMethod, sURL+"?"+sVars, true);
sVars = "";
}
else
{
xmlhttp.open(sMethod, sURL, true);
xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlhttp.send(sVars);
}
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4 && !bComplete)
{
bComplete = true;
fnDone(xmlhttp);
}
};
xmlhttp.send(sVars);
}
catch(z)
{
return false;
}
return true;
};
return this;
}