1angular.module("app") 2.run(function($rootScope, $http, $filter, $timeout) { 3 $rootScope.deleteField = function(object, field) { 4 delete object[field]; 5 } 6 $rootScope.classIniter = $rootScope.classIniter = function(name, classn, params){ 7 $rootScope[name] = new $rootScope[classn](params); 8 }; 9 $rootScope.lazyAction = $rootScope.lazyAction = function(params) { 10 var self = this; 11 this.timeout = 1000; 12 if(params.timeout) this.timeout = params.timeout; 13 14 this.func = params.func; 15 if(params.arg) this.arg = params.arg; 16 17 this.timer; 18 19 this.resetTimeout = function() { 20 $timeout.cancel(self.timer); 21 self.timer = $timeout(function(){self.func(self.arg);}, self.timeout); 22 } 23 }; 24 25 $rootScope.initAttrs = function(vl){ 26 if(!vl){ 27 $rootScope.attrs = {"vars":[{tsvety:[], params:[]}],"param":{}}; 28 }else{ 29 $rootScope.attrs = vl; 30 } 31 } 32 $rootScope.initVar = function(vars){ 33 if(vars){ 34 $rootScope.vars = vars; 35 }else{ 36 $rootScope.vars = { 37 next_id:1, 38 items:{} 39 }; 40 } 41 } 42 $rootScope.addVar = function(vars){ 43 $rootScope.vars.items['i'+$rootScope.vars.next_id] = {t:'text'}; 44 $rootScope.vars.next_id++; 45 } 46 $rootScope.changeVar = function(v){ 47 48 if(v.t == 'list'){ 49 v.items = []; 50 } 51 } 52 $rootScope.delVar = function(k){ 53 delete $rootScope.vars.items[k]; 54 } 55 $rootScope.send = function(data, act, cb){ 56 data.action = act; 57 $http({ 58 method : 'POST', 59 url : '/admin/custom/action', 60 data : data 61 }) 62 .success(function(r) { 63 cb(r); 64 }); 65 }; 66 $rootScope.addFile = function(ev, object){ 67 if(!ev.files) return; 68 var philds = object.split('.'); 69 var tree = $rootScope; 70 for(var i = 0; i < philds.length; ++i){ 71 var p = philds[i]; 72 if(i == philds.length-1){ 73 if(!tree[p]) tree[p] = []; 74 }else{ 75 if(!tree[p]) tree[p] = {}; 76 } 77 tree = tree[p]; 78 } 79 //if(!$rootScope[object]) $rootScope[object] = {}; 80 //if(!$rootScope[object][property]) $rootScope[object][property] = []; 81 $rootScope.filesToUpload = []; 82 $rootScope.uploadedFiles = tree ; 83 function MyFileLoader(file){ 84 var t = this; 85 this.file = file; 86 this.upload = function(){ 87 var t = this; 88 var r = new FileReader(); 89 r.onloadend = function(e){ 90 var filemeta = t; 91 var data = e.target.result; 92 $rootScope.send({ 93 lastModified: filemeta.file.lastModified, 94 name: filemeta.file.name, 95 size: filemeta.file.size, 96 type: filemeta.file.type, 97 data: data 98 }, 'fileUpload', function(rez){ 99 $rootScope.uploadedFiles.push(rez.data); 100 }); 101 } 102 r.readAsDataURL(this.file); 103 } 104 } 105 for(var i = 0; i < ev.files.length; ++i){ 106 var uploader = new MyFileLoader(ev.files[i]); 107 uploader.upload(); 108 } 109 } 110 $rootScope.slideInit = function(sl){ 111 sl.slide = []; 112 sl.indexes = []; 113 for(var i = 0; i < sl.slide_cnt; ++i){ 114 sl.slide.push({ 115 position:'absolute', 116 opacity:0, 117 'z-index':0, 118 }); 119 sl.indexes[i] = i; 120 sl.indexes[i - sl.slide_cnt] = i; 121 sl.indexes[i + sl.slide_cnt] = i; 122 } 123 $rootScope.slideNum(sl, 0); 124 $interval(function(){ 125 $rootScope.slideNum(sl, sl.slide_num+1); 126 }, 4000); 127 } 128 $rootScope.slideNum = function(sl, num){ 129 if(num<0) num = sl.slide_cnt-1; 130 if(num>= sl.slide_cnt) num = 0; 131 sl.slide_num = num; 132 var polovina = parseInt(sl.slide_cnt/2)+1; 133 for(var i = num - polovina; i < num; ++i){ 134 sl.slide[sl.indexes[i]]['z-index'] = 0; 135 sl.slide[sl.indexes[i]].opacity = 0; 136 } 137 for(var i = num+1; i < num+polovina; ++i){ 138 sl.slide[sl.indexes[i]]['z-index'] = 0; 139 sl.slide[sl.indexes[i]].opacity = 0; 140 }; 141 sl.slide[num]['z-index'] = 1; 142 sl.slide[num].opacity = 1; 143 } 144 $rootScope.addSlide = function(slider, img){ 145 slider.push(img); 146 }; 147 $rootScope.setSlider = function(slider, img){ 148 $rootScope.slider = { 149 images: slider, 150 current: img 151 }; 152 }; 153 $rootScope.changeSlider = function(add){ 154 if(add>0){ 155 $rootScope.slider.index++; 156 if($rootScope.slider.index >= $rootScope.slider.images.length) $rootScope.slider.index = $rootScope.slider.images.length -1; 157 }else{ 158 $rootScope.slider.index--; 159 if($rootScope.slider.index < 0) $rootScope.slider.index = 0; 160 } 161 } 162 $rootScope.clozeSlider = function(){ 163 delete $rootScope.slider; 164 } 165 $rootScope.getJS = function(attrs){ 166 return $filter('json')(attrs, 0); 167 } 168 169 170});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.