beautify_js
This commit is contained in:
parent
0febe4f5fd
commit
5c2f32e184
208 changed files with 3891 additions and 1474 deletions
|
@ -1,12 +1,24 @@
|
|||
describe("Тест", function() {
|
||||
|
||||
before(function() { alert("Начало всех тестов"); });
|
||||
after(function() { alert("Окончание всех тестов"); });
|
||||
before(function() {
|
||||
alert("Начало всех тестов");
|
||||
});
|
||||
after(function() {
|
||||
alert("Окончание всех тестов");
|
||||
});
|
||||
|
||||
beforeEach(function() { alert("Вход в тест"); });
|
||||
afterEach(function() { alert("Выход из теста"); });
|
||||
beforeEach(function() {
|
||||
alert("Вход в тест");
|
||||
});
|
||||
afterEach(function() {
|
||||
alert("Выход из теста");
|
||||
});
|
||||
|
||||
it('тест 1', function() { alert('1'); });
|
||||
it('тест 2', function() { alert('2'); });
|
||||
it('тест 1', function() {
|
||||
alert('1');
|
||||
});
|
||||
it('тест 2', function() {
|
||||
alert('2');
|
||||
});
|
||||
|
||||
});
|
|
@ -4,6 +4,8 @@ describe("isEmpty", function() {
|
|||
});
|
||||
|
||||
it("если у объекта есть любое свойство, не важно какое - возвращает false", function() {
|
||||
assert.isFalse( isEmpty({ anything: false }) );
|
||||
assert.isFalse(isEmpty({
|
||||
anything: false
|
||||
}));
|
||||
});
|
||||
});
|
|
@ -1,5 +1,6 @@
|
|||
function getMaxSubSum(arr) {
|
||||
var maxSum = 0, partialSum = 0;
|
||||
var maxSum = 0,
|
||||
partialSum = 0;
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
partialSum += arr[i];
|
||||
maxSum = Math.max(maxSum, partialSum);
|
||||
|
@ -7,4 +8,3 @@ function getMaxSubSum(arr) {
|
|||
}
|
||||
return maxSum;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
describe("addClass", function() {
|
||||
|
||||
it("добавляет класс, которого нет", function() {
|
||||
var obj = { className: 'open menu' };
|
||||
var obj = {
|
||||
className: 'open menu'
|
||||
};
|
||||
addClass(obj, 'new');
|
||||
assert.deepEqual(obj, {
|
||||
className: 'open menu new'
|
||||
|
@ -9,7 +11,9 @@ describe("addClass", function() {
|
|||
});
|
||||
|
||||
it("не добавляет класс, который уже есть", function() {
|
||||
var obj = { className: 'open menu' };
|
||||
var obj = {
|
||||
className: 'open menu'
|
||||
};
|
||||
addClass(obj, 'open');
|
||||
assert.deepEqual(obj, {
|
||||
className: 'open menu'
|
||||
|
@ -17,7 +21,9 @@ describe("addClass", function() {
|
|||
});
|
||||
|
||||
it("не добавляет лишних пробелов, который уже есть", function() {
|
||||
var obj = { className: '' };
|
||||
var obj = {
|
||||
className: ''
|
||||
};
|
||||
addClass(obj, 'open');
|
||||
assert.deepEqual(obj, {
|
||||
className: 'open'
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
describe("unique", function() {
|
||||
it("убирает неуникальные элементы из массива", function() {
|
||||
var strings = ["кришна", "кришна", "харе", "харе",
|
||||
"харе", "харе", "кришна", "кришна", "8-()"];
|
||||
"харе", "харе", "кришна", "кришна", "8-()"
|
||||
];
|
||||
|
||||
assert.deepEqual(unique(strings), ["кришна", "харе", "8-()"]);
|
||||
});
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
describe("removeClass", function() {
|
||||
|
||||
it("ничего не делает, если класса нет", function() {
|
||||
var obj = { className: 'open menu' };
|
||||
var obj = {
|
||||
className: 'open menu'
|
||||
};
|
||||
removeClass(obj, 'new');
|
||||
assert.deepEqual(obj, {
|
||||
className: 'open menu'
|
||||
|
@ -9,7 +11,9 @@ describe("removeClass", function() {
|
|||
});
|
||||
|
||||
it("не меняет пустое свойство", function() {
|
||||
var obj = { className: '' };
|
||||
var obj = {
|
||||
className: ''
|
||||
};
|
||||
removeClass(obj, 'new');
|
||||
assert.deepEqual(obj, {
|
||||
className: ""
|
||||
|
@ -17,7 +21,9 @@ describe("removeClass", function() {
|
|||
});
|
||||
|
||||
it("удаляет класс, не оставляя лишних пробелов", function() {
|
||||
var obj = { className: 'open menu' };
|
||||
var obj = {
|
||||
className: 'open menu'
|
||||
};
|
||||
removeClass(obj, 'open');
|
||||
assert.deepEqual(obj, {
|
||||
className: "menu"
|
||||
|
@ -25,7 +31,9 @@ describe("removeClass", function() {
|
|||
});
|
||||
|
||||
it("если класс один и он удалён, то результат - пустая строка", function() {
|
||||
var obj = { className: "menu" };
|
||||
var obj = {
|
||||
className: "menu"
|
||||
};
|
||||
removeClass(obj, 'menu');
|
||||
assert.deepEqual(obj, {
|
||||
className: ""
|
||||
|
|
|
@ -19,4 +19,3 @@ it("приводит всё к строке", function() {
|
|||
buffer(false);
|
||||
assert.equal(buffer(), "nullfalse");
|
||||
});
|
||||
|
||||
|
|
|
@ -9,4 +9,3 @@ function inBetween(a, b) {
|
|||
function inArray(arr) {
|
||||
// ...ваш код...
|
||||
}
|
||||
|
||||
|
|
|
@ -35,11 +35,15 @@ describe("inBetween", function() {
|
|||
describe("filter", function() {
|
||||
|
||||
it("фильтрует через func", function() {
|
||||
assert.deepEqual( filter(arr, function(a) { return a % 2 == 0; }), [2,4,6] );
|
||||
assert.deepEqual(filter(arr, function(a) {
|
||||
return a % 2 == 0;
|
||||
}), [2, 4, 6]);
|
||||
});
|
||||
|
||||
it("не модифицирует исходный массив", function() {
|
||||
filter(arr, function(a) { return a % 2 == 0; });
|
||||
filter(arr, function(a) {
|
||||
return a % 2 == 0;
|
||||
});
|
||||
assert.deepEqual(arr, [1, 2, 3, 4, 5, 6, 7]);
|
||||
});
|
||||
|
||||
|
|
|
@ -12,4 +12,3 @@ var calculator = {
|
|||
this.b = +prompt('b?', 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,9 @@ describe("makeLogging", function() {
|
|||
var log = [];
|
||||
|
||||
var calculator = {
|
||||
double: function(x) { return x*2; }
|
||||
double: function(x) {
|
||||
return x * 2;
|
||||
}
|
||||
}
|
||||
|
||||
calculator.double = sinon.spy(calculator.double);
|
||||
|
|
|
@ -7,9 +7,3 @@ function makeLogging(f, log) {
|
|||
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
describe("makeLogging", function() {
|
||||
it("записывает вызовы в массив log", function() {
|
||||
var work = sinon.spy();
|
||||
|
@ -8,10 +7,15 @@ describe("makeLogging", function() {
|
|||
assert.deepEqual(log, []);
|
||||
|
||||
work(1, 2);
|
||||
assert.deepEqual( log, [[1, 2]]);
|
||||
assert.deepEqual(log, [
|
||||
[1, 2]
|
||||
]);
|
||||
|
||||
work(3, 4);
|
||||
assert.deepEqual( log, [[1, 2], [3,4]]);
|
||||
assert.deepEqual(log, [
|
||||
[1, 2],
|
||||
[3, 4]
|
||||
]);
|
||||
});
|
||||
|
||||
it("передаёт вызов функции, возвращает её результат", function() {
|
||||
|
@ -34,7 +38,9 @@ describe("makeLogging", function() {
|
|||
var log = [];
|
||||
|
||||
var calculator = {
|
||||
sum: function(a, b) { return a + b; }
|
||||
sum: function(a, b) {
|
||||
return a + b;
|
||||
}
|
||||
}
|
||||
|
||||
calculator.sum = sinon.spy(calculator.sum);
|
||||
|
|
|
@ -9,6 +9,7 @@ describe("delay", function() {
|
|||
|
||||
it("вызывает функцию через указанный таймаут", function() {
|
||||
var start = Date.now();
|
||||
|
||||
function f(x) {
|
||||
assert.equal(Date.now() - start, 1000);
|
||||
}
|
||||
|
|
|
@ -11,7 +11,9 @@ function debounce(f, ms) {
|
|||
|
||||
state = COOLDOWN;
|
||||
|
||||
setTimeout(function() { state = null }, ms);
|
||||
setTimeout(function() {
|
||||
state = null
|
||||
}, ms);
|
||||
}
|
||||
|
||||
}
|
|
@ -9,16 +9,25 @@ describe("debounce", function() {
|
|||
|
||||
it("вызывает функцию не чаще чем раз в ms миллисекунд", function() {
|
||||
var log = '';
|
||||
function f(a) { log += a; }
|
||||
|
||||
function f(a) {
|
||||
log += a;
|
||||
}
|
||||
|
||||
f = debounce(f, 1000);
|
||||
|
||||
f(1); // выполнится сразу же
|
||||
f(2); // игнор
|
||||
|
||||
setTimeout(function() { f(3) }, 100); // игнор (рановато)
|
||||
setTimeout(function() { f(4) }, 1100); // выполнится (таймаут прошёл)
|
||||
setTimeout(function() { f(5) }, 1500); // игнор
|
||||
setTimeout(function() {
|
||||
f(3)
|
||||
}, 100); // игнор (рановато)
|
||||
setTimeout(function() {
|
||||
f(4)
|
||||
}, 1100); // выполнится (таймаут прошёл)
|
||||
setTimeout(function() {
|
||||
f(5)
|
||||
}, 1500); // игнор
|
||||
|
||||
this.clock.tick(5000);
|
||||
assert.equal(log, "14");
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
describe("throttle(f, 1000)", function() {
|
||||
var f1000;
|
||||
var log = "";
|
||||
function f(a) { log += a; }
|
||||
|
||||
function f(a) {
|
||||
log += a;
|
||||
}
|
||||
|
||||
before(function() {
|
||||
f1000 = throttle(f, 1000);
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
function Clock(options) {
|
||||
this._template = options.template;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
function Clock(options) {
|
||||
this._template = options.template;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
function ExtendedClock(options) {
|
||||
Clock.apply(this, arguments);
|
||||
this._precision = +options.precision || 1000;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
function Clock(options) {
|
||||
this._template = options.template;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
function ExtendedClock(options) {
|
||||
Clock.apply(this, arguments);
|
||||
this._precision = +options.precision || 1000;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
function Clock(options) {
|
||||
this._template = options.template;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ function extend(Child, Parent) {
|
|||
Child.prototype.constructor = Child;
|
||||
Child.parent = Parent.prototype;
|
||||
}
|
||||
|
||||
function inherit(proto) {
|
||||
function F() {}
|
||||
F.prototype = proto;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
if (!window.setImmediate) window.setImmediate = (function() {
|
||||
var head = { }, tail = head; // очередь вызовов, 1-связный список
|
||||
var head = {},
|
||||
tail = head; // очередь вызовов, 1-связный список
|
||||
|
||||
var ID = Math.random(); // уникальный идентификатор
|
||||
|
||||
|
@ -18,7 +19,9 @@ if (!window.setImmediate) window.setImmediate = (function() {
|
|||
}
|
||||
|
||||
return window.postMessage ? function(func) {
|
||||
tail = tail.next = { func: func };
|
||||
tail = tail.next = {
|
||||
func: func
|
||||
};
|
||||
window.postMessage(ID, "*");
|
||||
} :
|
||||
function(func) { // IE7-
|
||||
|
|
|
@ -17,7 +17,8 @@ function fixIERangeObject(range, win) { //Only for IE8 and below.
|
|||
var _findTextNode = function(parentElement, text) {
|
||||
//Iterate through all the child text nodes and check for matches
|
||||
//As we go through each text node keep removing the text value (substring) from the beginning of the text variable.
|
||||
var container=null,offset=-1;
|
||||
var container = null,
|
||||
offset = -1;
|
||||
for (var node = parentElement.firstChild; node; node = node.nextSibling) {
|
||||
if (node.nodeType == 3) { //Text node
|
||||
var find = node.nodeValue;
|
||||
|
@ -33,11 +34,16 @@ function fixIERangeObject(range, win) { //Only for IE8 and below.
|
|||
}
|
||||
//Debug Message
|
||||
//alert(container.nodeValue);
|
||||
return {node: container,offset: offset}; //nodeInfo
|
||||
return {
|
||||
node: container,
|
||||
offset: offset
|
||||
}; //nodeInfo
|
||||
}
|
||||
|
||||
var rangeCopy1=range.duplicate(), rangeCopy2=range.duplicate(); //Create a copy
|
||||
var rangeObj1=range.duplicate(), rangeObj2=range.duplicate(); //More copies :P
|
||||
var rangeCopy1 = range.duplicate(),
|
||||
rangeCopy2 = range.duplicate(); //Create a copy
|
||||
var rangeObj1 = range.duplicate(),
|
||||
rangeObj2 = range.duplicate(); //More copies :P
|
||||
|
||||
rangeCopy1.collapse(true); //Go to beginning of the selection
|
||||
rangeCopy1.moveEnd('character', 1); //Select only the first character
|
||||
|
@ -46,7 +52,8 @@ function fixIERangeObject(range, win) { //Only for IE8 and below.
|
|||
|
||||
//Debug Message
|
||||
// alert(rangeCopy1.text); //Should be the first character of the selection
|
||||
var parentElement1=rangeCopy1.parentElement(), parentElement2=rangeCopy2.parentElement();
|
||||
var parentElement1 = rangeCopy1.parentElement(),
|
||||
parentElement2 = rangeCopy2.parentElement();
|
||||
|
||||
//If user clicks the input button without selecting text, then moveToElementText throws an error.
|
||||
if (parentElement1 instanceof HTMLInputElement || parentElement2 instanceof HTMLInputElement) {
|
||||
|
@ -78,8 +85,7 @@ function getRangeObject(win) { //Gets the first range object
|
|||
try {
|
||||
return win.getSelection().getRangeAt(0); //W3C DOM Range Object
|
||||
} catch (e) { /*If no text is selected an exception might be thrown*/ }
|
||||
}
|
||||
else if(win.document.selection) { // IE8
|
||||
} else if (win.document.selection) { // IE8
|
||||
var range = win.document.selection.createRange(); //Microsoft TextRange Object
|
||||
return fixIERangeObject(range, win);
|
||||
}
|
||||
|
|
|
@ -37,5 +37,3 @@ DragZone.prototype.onDragStart = function(downX, downY, event) {
|
|||
|
||||
return avatar;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -74,8 +74,7 @@ DropTarget.prototype.onDragEnd = function(avatar, event) {
|
|||
/**
|
||||
* Вход аватара в DropTarget
|
||||
*/
|
||||
DropTarget.prototype.onDragEnter = function(fromDropTarget, avatar, event) {
|
||||
};
|
||||
DropTarget.prototype.onDragEnter = function(fromDropTarget, avatar, event) {};
|
||||
|
||||
/**
|
||||
* Выход аватара из DropTarget
|
||||
|
@ -84,5 +83,3 @@ DropTarget.prototype.onDragLeave = function(toDropTarget, avatar, event) {
|
|||
this._hideHoverIndication();
|
||||
this._targetElem = null;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
function TreeDragAvatar(dragZone, dragElem) {
|
||||
DragAvatar.apply(this, arguments);
|
||||
}
|
||||
|
@ -42,4 +41,3 @@ TreeDragAvatar.prototype.onDragCancel = function() {
|
|||
TreeDragAvatar.prototype.onDragEnd = function() {
|
||||
this._destroy();
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
function TreeDragZone(elem) {
|
||||
DragZone.apply(this, arguments);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
function TreeDropTarget(elem) {
|
||||
TreeDropTarget.parent.constructor.apply(this, arguments);
|
||||
}
|
||||
|
|
|
@ -37,5 +37,3 @@ DragZone.prototype.onDragStart = function(downX, downY, event) {
|
|||
|
||||
return avatar;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -74,8 +74,7 @@ DropTarget.prototype.onDragEnd = function(avatar, event) {
|
|||
/**
|
||||
* Вход аватара в DropTarget
|
||||
*/
|
||||
DropTarget.prototype.onDragEnter = function(fromDropTarget, avatar, event) {
|
||||
};
|
||||
DropTarget.prototype.onDragEnter = function(fromDropTarget, avatar, event) {};
|
||||
|
||||
/**
|
||||
* Выход аватара из DropTarget
|
||||
|
@ -84,5 +83,3 @@ DropTarget.prototype.onDragLeave = function(toDropTarget, avatar, event) {
|
|||
this._hideHoverIndication();
|
||||
this._targetElem = null;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
function TreeDragAvatar(dragZone, dragElem) {
|
||||
DragAvatar.apply(this, arguments);
|
||||
}
|
||||
|
@ -42,4 +41,3 @@ TreeDragAvatar.prototype.onDragCancel = function() {
|
|||
TreeDragAvatar.prototype.onDragEnd = function() {
|
||||
this._destroy();
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
function TreeDragZone(elem) {
|
||||
DragZone.apply(this, arguments);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
function TreeDropTarget(elem) {
|
||||
TreeDropTarget.parent.constructor.apply(this, arguments);
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
function getCoords(elem) {
|
||||
var box = elem.getBoundingClientRect();
|
||||
|
||||
|
@ -14,7 +13,10 @@ function getCoords(elem) {
|
|||
var top = box.top + scrollTop - clientTop;
|
||||
var left = box.left + scrollLeft - clientLeft;
|
||||
|
||||
return { top: Math.round(top), left: Math.round(left) };
|
||||
return {
|
||||
top: Math.round(top),
|
||||
left: Math.round(left)
|
||||
};
|
||||
}
|
||||
|
||||
function getElementUnderClientXY(elem, clientX, clientY) {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
function bench(test, times) {
|
||||
var sum = 0;
|
||||
for (var i = 0; i < times; i++) {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/* 1. Вставляет TBODY в документ сразу. а затем элементы */
|
||||
var appendFirst = new function() {
|
||||
var benchTable;
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
var elems = document.querySelectorAll('form,div,p');
|
||||
|
||||
for (var i = 0; i < elems.length; i++) {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
var form = document.querySelector('form');
|
||||
|
||||
form.onclick = function(event) {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
var elems = document.querySelectorAll('form,div,p');
|
||||
|
||||
for (var i = 0; i < elems.length; i++) {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
function HoverIntent(options) {
|
||||
|
||||
options = Object.create(options); // not to modify the object
|
||||
|
@ -74,4 +73,3 @@ function HoverIntent(options) {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
function HoverIntent(options) {
|
||||
/* ваш код */
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
// элемент TD, внутри которого сейчас курсор
|
||||
var currentElem = null;
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
table.onmouseover = function(event) {
|
||||
var target = event.target;
|
||||
target.style.background = 'pink';
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
table.onmouseenter = table.onmouseleave = log;
|
||||
|
||||
function log(event) {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
function log(event) {
|
||||
text.value += event.type + ' [target: ' + event.target.className + ']\n';
|
||||
text.scrollTop = text.scrollHeight;
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
function mouselog(event) {
|
||||
text.value += event.type + ' [target: ' + event.target.className + ']\n'
|
||||
text.scrollTop = text.scrollHeight
|
||||
|
|
|
@ -17,6 +17,7 @@ function clearText() {
|
|||
var lastMessageTime = 0;
|
||||
var lastMessage = "";
|
||||
var repeatCounter = 1;
|
||||
|
||||
function log(message) {
|
||||
if (lastMessageTime == 0) lastMessageTime = new Date();
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
document.onmousedown = function(e) {
|
||||
|
||||
var dragElement = e.target;
|
||||
|
|
|
@ -155,4 +155,3 @@ function getCoords(elem) { // кроме IE8-
|
|||
};
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
kinput.onkeydown = kinput.onkeyup = kinput.onkeypress = handle;
|
||||
|
||||
var lastTime = Date.now();
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
var table = document.getElementById('bagua-table');
|
||||
|
||||
var editingTd;
|
||||
|
@ -61,4 +60,3 @@ function finishTdEdit(td, isOk) {
|
|||
td.classList.remove('edit-td'); // remove edit class
|
||||
editingTd = null;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
var table = document.getElementById('bagua-table');
|
||||
|
||||
/* ваш код */
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
function ListSelect(options) {
|
||||
var elem = options.elem;
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
function Voter(options) {
|
||||
var elem = this._elem = options.elem;
|
||||
this._voteElem = elem.querySelector('.vote');
|
||||
|
@ -30,4 +29,3 @@ Voter.prototype._voteDecrease = function() {
|
|||
Voter.prototype.setVote = function(vote) {
|
||||
this._voteElem.innerHTML = +vote;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
function Voter(options) {
|
||||
var elem = this._elem = options.elem;
|
||||
this._voteElem = elem.querySelector('.vote');
|
||||
|
@ -30,4 +29,3 @@ Voter.prototype._voteDecrease = function() {
|
|||
Voter.prototype.setVote = function(vote) {
|
||||
this._voteElem.innerHTML = +vote;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
function Menu(options) {
|
||||
var elem = options.elem;
|
||||
|
||||
elem.onmousedown = function() { return false; }
|
||||
elem.onmousedown = function() {
|
||||
return false;
|
||||
}
|
||||
|
||||
elem.onclick = function(event) {
|
||||
if (event.target.closest('.title')) {
|
||||
|
|
|
@ -7,7 +7,9 @@ function Menu(options) {
|
|||
}
|
||||
|
||||
function render() {
|
||||
var html = options.template({title: options.title});
|
||||
var html = options.template({
|
||||
title: options.title
|
||||
});
|
||||
|
||||
elem = document.createElement('div');
|
||||
elem.innerHTML = html;
|
||||
|
@ -33,7 +35,9 @@ function Menu(options) {
|
|||
function renderItems() {
|
||||
if (elem.querySelector('ul')) return;
|
||||
|
||||
var listHtml = options.listTemplate({items: options.items});
|
||||
var listHtml = options.listTemplate({
|
||||
items: options.items
|
||||
});
|
||||
elem.insertAdjacentHTML("beforeEnd", listHtml);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,9 @@ function Menu(options) {
|
|||
}
|
||||
|
||||
function render() {
|
||||
var html = options.template({title: options.title});
|
||||
var html = options.template({
|
||||
title: options.title
|
||||
});
|
||||
|
||||
elem = document.createElement('div');
|
||||
elem.innerHTML = html;
|
||||
|
@ -27,7 +29,9 @@ function Menu(options) {
|
|||
function renderItems() {
|
||||
if (elem.querySelector('ul')) return;
|
||||
|
||||
var listHtml = options.listTemplate({items: options.items});
|
||||
var listHtml = options.listTemplate({
|
||||
items: options.items
|
||||
});
|
||||
elem.insertAdjacentHTML("beforeEnd", listHtml);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,9 @@ function Menu(options) {
|
|||
}
|
||||
|
||||
function render() {
|
||||
var html = options.template({title: options.title});
|
||||
var html = options.template({
|
||||
title: options.title
|
||||
});
|
||||
|
||||
elem = document.createElement('div');
|
||||
elem.innerHTML = html;
|
||||
|
@ -27,7 +29,9 @@ function Menu(options) {
|
|||
function renderItems() {
|
||||
if (elem.querySelector('ul')) return;
|
||||
|
||||
var listHtml = options.listTemplate({items: options.items});
|
||||
var listHtml = options.listTemplate({
|
||||
items: options.items
|
||||
});
|
||||
elem.insertAdjacentHTML("beforeEnd", listHtml);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,10 @@ function Voter(options) {
|
|||
|
||||
function setVote(vote) {
|
||||
voteElem.innerHTML = +vote;
|
||||
var widgetEvent = new CustomEvent("change", { bubbles: true, detail: +vote });
|
||||
var widgetEvent = new CustomEvent("change", {
|
||||
bubbles: true,
|
||||
detail: +vote
|
||||
});
|
||||
elem.dispatchEvent(widgetEvent);
|
||||
};
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
function ListSelect(options) {
|
||||
var elem = options.elem;
|
||||
|
||||
|
|
|
@ -7,7 +7,9 @@ function Menu(options) {
|
|||
}
|
||||
|
||||
function render() {
|
||||
var html = options.template({title: options.title});
|
||||
var html = options.template({
|
||||
title: options.title
|
||||
});
|
||||
|
||||
elem = document.createElement('div');
|
||||
elem.innerHTML = html;
|
||||
|
@ -33,7 +35,9 @@ function Menu(options) {
|
|||
function renderItems() {
|
||||
if (elem.querySelector('ul')) return;
|
||||
|
||||
var listHtml = options.listTemplate({items: options.items});
|
||||
var listHtml = options.listTemplate({
|
||||
items: options.items
|
||||
});
|
||||
elem.insertAdjacentHTML("beforeEnd", listHtml);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,9 @@ function Menu(options) {
|
|||
}
|
||||
|
||||
function render() {
|
||||
var html = options.template({title: options.title});
|
||||
var html = options.template({
|
||||
title: options.title
|
||||
});
|
||||
|
||||
elem = document.createElement('div');
|
||||
elem.innerHTML = html;
|
||||
|
@ -33,7 +35,9 @@ function Menu(options) {
|
|||
function renderItems() {
|
||||
if (elem.querySelector('ul')) return;
|
||||
|
||||
var listHtml = options.listTemplate({items: options.items});
|
||||
var listHtml = options.listTemplate({
|
||||
items: options.items
|
||||
});
|
||||
elem.insertAdjacentHTML("beforeEnd", listHtml);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,4 +46,3 @@ function scriptRequest(url, onSuccess, onError) {
|
|||
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
var http = require('http');
|
||||
var url = require('url');
|
||||
var static = require('node-static');
|
||||
var file = new static.Server('.', { cache: 0 });
|
||||
var file = new static.Server('.', {
|
||||
cache: 0
|
||||
});
|
||||
|
||||
|
||||
function accept(req, res) {
|
||||
|
@ -35,4 +37,3 @@ if (!module.parent) {
|
|||
} else {
|
||||
exports.accept = accept;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
var http = require('http');
|
||||
var url = require('url');
|
||||
var static = require('node-static');
|
||||
var file = new static.Server('.', { cache: 0 });
|
||||
var file = new static.Server('.', {
|
||||
cache: 0
|
||||
});
|
||||
var multiparty = require('multiparty');
|
||||
|
||||
function accept(req, res) {
|
||||
|
@ -38,5 +40,3 @@ if (!module.parent) {
|
|||
} else {
|
||||
exports.accept = accept;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
var IframeComet = new function() {
|
||||
var self = this;
|
||||
|
||||
var connectTries = 0, reconnectTimer;
|
||||
var connectTries = 0,
|
||||
reconnectTimer;
|
||||
var htmlfile; // for ie only
|
||||
var iframe;
|
||||
|
||||
|
|
|
@ -1,14 +1,17 @@
|
|||
|
||||
var http = require('http');
|
||||
var url = require('url');
|
||||
var static = require('node-static');
|
||||
var file = new static.Server('.', { cache: 0 });
|
||||
var file = new static.Server('.', {
|
||||
cache: 0
|
||||
});
|
||||
|
||||
|
||||
function accept(req, res) {
|
||||
|
||||
if (req.url == '/comet') {
|
||||
res.writeHead(200, {'Content-Type': 'text/html; charset=utf-8'});
|
||||
res.writeHead(200, {
|
||||
'Content-Type': 'text/html; charset=utf-8'
|
||||
});
|
||||
|
||||
res.write('<!DOCTYPE HTML><html> \
|
||||
<head><meta junk="' + new Array(2000).join('*') + '"/> \
|
||||
|
@ -38,5 +41,3 @@ if (!module.parent) {
|
|||
} else {
|
||||
exports.accept = accept;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
|
||||
|
||||
function createIframe(name, src, debug) {
|
||||
src = src || 'javascript:false'; // пустой src
|
||||
|
||||
|
@ -92,5 +90,3 @@ function iframePost(url, data, onSuccess, onError) {
|
|||
|
||||
postToIframe(url, data, iframeName);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
var http = require('http');
|
||||
var url = require('url');
|
||||
var static = require('node-static');
|
||||
var file = new static.Server('.', { cache: 0 });
|
||||
var file = new static.Server('.', {
|
||||
cache: 0
|
||||
});
|
||||
var multiparty = require('multiparty');
|
||||
|
||||
function accept(req, res) {
|
||||
|
@ -38,5 +40,3 @@ if (!module.parent) {
|
|||
} else {
|
||||
exports.accept = accept;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -28,4 +28,3 @@ if (!module.parent) {
|
|||
} else {
|
||||
exports.accept = accept;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@ var http = require('http');
|
|||
var url = require('url');
|
||||
var querystring = require('querystring');
|
||||
var static = require('node-static');
|
||||
var file = new static.Server('.', { cache: 0 });
|
||||
var file = new static.Server('.', {
|
||||
cache: 0
|
||||
});
|
||||
|
||||
|
||||
function accept(req, res) {
|
||||
|
@ -26,4 +28,3 @@ if (!module.parent) {
|
|||
} else {
|
||||
exports.accept = accept;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@ var http = require('http');
|
|||
var url = require('url');
|
||||
var querystring = require('querystring');
|
||||
var static = require('node-static');
|
||||
var file = new static.Server('.', { cache: 0 });
|
||||
var file = new static.Server('.', {
|
||||
cache: 0
|
||||
});
|
||||
|
||||
|
||||
function accept(req, res) {
|
||||
|
@ -26,4 +28,3 @@ if (!module.parent) {
|
|||
} else {
|
||||
exports.accept = accept;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@ var http = require('http');
|
|||
var url = require('url');
|
||||
var querystring = require('querystring');
|
||||
var static = require('node-static');
|
||||
var file = new static.Server('.', { cache: 0 });
|
||||
var file = new static.Server('.', {
|
||||
cache: 0
|
||||
});
|
||||
|
||||
|
||||
function accept(req, res) {
|
||||
|
@ -26,4 +28,3 @@ if (!module.parent) {
|
|||
} else {
|
||||
exports.accept = accept;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@ var http = require('http');
|
|||
var url = require('url');
|
||||
var querystring = require('querystring');
|
||||
var static = require('node-static');
|
||||
var file = new static.Server('.', { cache: 0 });
|
||||
var file = new static.Server('.', {
|
||||
cache: 0
|
||||
});
|
||||
|
||||
|
||||
function accept(req, res) {
|
||||
|
@ -26,4 +28,3 @@ if (!module.parent) {
|
|||
} else {
|
||||
exports.accept = accept;
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@ var http = require('http');
|
|||
var url = require('url');
|
||||
var querystring = require('querystring');
|
||||
var static = require('node-static');
|
||||
var file = new static.Server('.', { cache: 0 });
|
||||
var file = new static.Server('.', {
|
||||
cache: 0
|
||||
});
|
||||
|
||||
|
||||
function accept(req, res) {
|
||||
|
@ -34,4 +36,3 @@ if (!module.parent) {
|
|||
} else {
|
||||
exports.accept = accept;
|
||||
}
|
||||
|
||||
|
|
|
@ -32,7 +32,9 @@ function onUpload(req, res) {
|
|||
// если байт 0, то создать новый файл, иначе проверить размер и дописать
|
||||
if (startByte == 0) {
|
||||
upload.bytesReceived = 0;
|
||||
var fileStream = fs.createWriteStream(filePath, {flags: 'w'});
|
||||
var fileStream = fs.createWriteStream(filePath, {
|
||||
flags: 'w'
|
||||
});
|
||||
console.log("New file created: " + filePath);
|
||||
} else {
|
||||
if (upload.bytesReceived != startByte) {
|
||||
|
@ -41,7 +43,9 @@ function onUpload(req, res) {
|
|||
return;
|
||||
}
|
||||
// добавляем в существующий файл
|
||||
fileStream = fs.createWriteStream(filePath, {flags: 'a'});
|
||||
fileStream = fs.createWriteStream(filePath, {
|
||||
flags: 'a'
|
||||
});
|
||||
console.log("File reopened: " + filePath);
|
||||
}
|
||||
|
||||
|
@ -113,4 +117,3 @@ if (!module.parent) {
|
|||
} else {
|
||||
exports.accept = accept;
|
||||
}
|
||||
|
||||
|
|
|
@ -94,7 +94,8 @@ function Uploader(file, onSuccess, onFail, onProgress) {
|
|||
function hashCode(str) {
|
||||
if (str.length == 0) return 0;
|
||||
|
||||
var hash = 0, i, chr, len;
|
||||
var hash = 0,
|
||||
i, chr, len;
|
||||
for (i = 0; i < str.length; i++) {
|
||||
chr = str.charCodeAt(i);
|
||||
hash = ((hash << 5) - hash) + chr;
|
||||
|
|
|
@ -74,4 +74,3 @@ if (!module.parent) {
|
|||
} else {
|
||||
exports.accept = accept;
|
||||
}
|
||||
|
||||
|
|
|
@ -108,4 +108,3 @@ if (!module.parent) {
|
|||
} else {
|
||||
exports.accept = accept;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,8 @@ function Uploader(file, onSuccess, onError, onProgress) {
|
|||
function hashCode(str) {
|
||||
if (str.length == 0) return 0;
|
||||
|
||||
var hash = 0, i, chr, len;
|
||||
var hash = 0,
|
||||
i, chr, len;
|
||||
for (i = 0; i < str.length; i++) {
|
||||
chr = str.charCodeAt(i);
|
||||
hash = ((hash << 5) - hash) + chr;
|
||||
|
|
|
@ -115,7 +115,9 @@ function DraggableWindow(options) {
|
|||
|
||||
function submit(message) {
|
||||
// добавить
|
||||
var newMessageElem = $('<div>', {text: message }).appendTo(contentElem);
|
||||
var newMessageElem = $('<div>', {
|
||||
text: message
|
||||
}).appendTo(contentElem);
|
||||
|
||||
// прокрутить к новому сообщению
|
||||
contentElem.prop('scrollTop', 999999999);
|
||||
|
@ -123,4 +125,3 @@ function DraggableWindow(options) {
|
|||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,9 @@ function DraggableWindow(options) {
|
|||
}
|
||||
|
||||
function onFocus() {
|
||||
$(self).triggerHandler({ type: 'focus' });
|
||||
$(self).triggerHandler({
|
||||
type: 'focus'
|
||||
});
|
||||
}
|
||||
|
||||
function onTitleMouseDown(e) {
|
||||
|
@ -119,7 +121,9 @@ function DraggableWindow(options) {
|
|||
|
||||
function submit(message) {
|
||||
// добавить
|
||||
var newMessageElem = $('<div>', {text: message }).appendTo(contentElem);
|
||||
var newMessageElem = $('<div>', {
|
||||
text: message
|
||||
}).appendTo(contentElem);
|
||||
|
||||
// прокрутить к новому сообщению
|
||||
contentElem.prop('scrollTop', 999999999);
|
||||
|
@ -139,4 +143,3 @@ function DraggableWindow(options) {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,11 @@ function Calendar(options) {
|
|||
|
||||
function onDateCellClick(e) {
|
||||
day = $(e.target).html();
|
||||
self.setValue({year: year, month: month, day: day});
|
||||
self.setValue({
|
||||
year: year,
|
||||
month: month,
|
||||
day: day
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -155,4 +159,3 @@ function Calendar(options) {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,10 @@ function DatePicker(options) {
|
|||
|
||||
if (!calendarCache[key]) {
|
||||
calendar = calendarCache[key] = new Calendar({
|
||||
value: {year: year, month: month}
|
||||
value: {
|
||||
year: year,
|
||||
month: month
|
||||
}
|
||||
});
|
||||
$(calendar).on("select", onCalendarSelect);
|
||||
} else {
|
||||
|
|
|
@ -93,7 +93,11 @@ function Calendar(options) {
|
|||
|
||||
function onDateCellClick(e) {
|
||||
day = $(e.target).html();
|
||||
self.setValue({year: year, month: month, day: day});
|
||||
self.setValue({
|
||||
year: year,
|
||||
month: month,
|
||||
day: day
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -155,4 +159,3 @@ function Calendar(options) {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
var result = {
|
||||
0: { children: [] }
|
||||
0: {
|
||||
children: []
|
||||
}
|
||||
};
|
||||
|
||||
$('div[id^="region"]').each(function() {
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,4 +1,3 @@
|
|||
|
||||
function Tree(options) {
|
||||
var self = this;
|
||||
|
||||
|
|
|
@ -88,7 +88,11 @@ function Calendar(options) {
|
|||
|
||||
function onDateCellClick(e) {
|
||||
day = $(e.target).html();
|
||||
self.setValue({year: year, month: month, day: day});
|
||||
self.setValue({
|
||||
year: year,
|
||||
month: month,
|
||||
day: day
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -150,4 +154,3 @@ function Calendar(options) {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ function Autocomplete(options) {
|
|||
|
||||
function onInputFocus() {
|
||||
var inputValue = input.val();
|
||||
|
||||
function checkInput() {
|
||||
if (inputValue != input.val()) {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue