mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-19 00:23:25 +02:00
Adding vs-repeat performance test sample.
This commit is contained in:
53
res/test/samples/vs-repeat/app-controller.js
Normal file
53
res/test/samples/vs-repeat/app-controller.js
Normal file
@@ -0,0 +1,53 @@
|
||||
module.exports = function ($scope, $location) {
|
||||
|
||||
function getRegularArray(size) {
|
||||
var res = [];
|
||||
for (var i = 0; i < size; i++) {
|
||||
res.push({text: i});
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
$scope.items = {
|
||||
collection: getRegularArray(1000)
|
||||
};
|
||||
$scope.$root.arraySize = 1000;
|
||||
$scope.switchCollection = function () {
|
||||
var parsed = parseInt($scope.newArray.size, 10);
|
||||
if (!isNaN(parsed)) {
|
||||
$scope.$root.arraySize = parsed;
|
||||
$scope.items = {
|
||||
collection: getRegularArray(parsed)
|
||||
};
|
||||
}
|
||||
};
|
||||
$scope.getDomElementsDesc = function () {
|
||||
var arr = [];
|
||||
var elems = document.querySelectorAll('.item-element.well');
|
||||
elems = Array.prototype.slice.call(elems);
|
||||
elems.forEach(function (item) {
|
||||
arr.push(item.innerHTML.trim());
|
||||
});
|
||||
return arr;
|
||||
}
|
||||
$scope.newArray = {};
|
||||
$scope.inputKeyDown = function (e) {
|
||||
if (e.keyCode == 13) {
|
||||
$scope.switchCollection();
|
||||
}
|
||||
};
|
||||
|
||||
$scope.outerArray = getRegularArray(2);
|
||||
$scope.thirdArray = getRegularArray(30);
|
||||
|
||||
$scope.$watch(function () {
|
||||
return $location.search();
|
||||
}, function (obj) {
|
||||
if (obj.tab)
|
||||
$scope.tab = obj.tab + '';
|
||||
}, true);
|
||||
|
||||
$scope.$watch('tab', function (tab) {
|
||||
$location.search({tab: tab});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user