Best Python code snippet using pyatom_python
main.py
Source:main.py
...92 newyf.append(yf[i])93 return np.fft.irfft(newyf)94 def scrollleft(self):95 self.scroll_helper(-10)96 def scrollright(self):97 self.scroll_helper(10)98 def zoomin(self):99 self.zoom_helper(0)100 def zoomout(self):101 self.zoom_helper(1)102 def scroll_helper(self,number):103 #Number is the number to be added to both limits104 left, right = self.axes.set_xlim()105 if number< 0 and left+number < 0 or right+number>len(self.y) and number>0:106 return107 left+=number108 right+=number109 left, right = self.axes.set_xlim(left,right)110 self.draw()111 def zoom_helper(self,identifier):112 #Identifier 0 for zoomin, 1 for zoomout113 left, right = self.axes.set_xlim()114 average = (left+right)/2115 left_for_calculation = average if identifier == 0 else left116 right_for_calculation = average if identifier ==0 else right117 left_new = left_for_calculation-abs((average - left)/2)118 right_new = right_for_calculation+abs((average - right)/2)119 left,right = self.axes.set_xlim(left_new,right_new)120 if left_new < 0 or right_new > len(self.y):121 return122 self.draw()123 124 def update_figure(self):125 left, right = self.axes.set_xlim()126 if(right+1 > len(self.y)):127 return128 self.axes.set_xlim(left+100,right+100)129 self.draw()130 def pause(self):131 self.timer.stop()132 def play(self):133 self.timer.start(self.speed)134 def getY(self):135 return self.axes.get_lines()[0].get_ydata()136 def setSpeed(self,speed):137 self.speed = speed138 self.timer.start(self.speed)139class ApplicationWindow(QMainWindow):140 def clearLayout(self, layout):141 if layout is not None:142 while layout.count():143 item = layout.takeAt(0)144 widget = item.widget()145 if widget is not None:146 widget.deleteLater()147 else:148 self.clearLayout(item.layout())149 def __init__(self):150 QMainWindow.__init__(self)151 self.children = []152 self.setAttribute(QtCore.Qt.WA_DeleteOnClose)153 self.setWindowTitle("Signal Viewer")154 self.resize(900, 800)155 self.file_menu = QMenu('&File', self)156 self.file_menu.addAction('&Quit', self.fileQuit,157 QtCore.Qt.CTRL + QtCore.Qt.Key_Q)158 self.menuBar().addMenu(self.file_menu)159 self.actionOpen_file = QtWidgets.QAction(self)160 self.actionOpen_file.setObjectName("actionOpen_file")161 self.actionOpen_file.setText("Open file")162 self.actionOpen_file.setShortcut("Ctrl+O")163 self.actionOpen_file.triggered.connect(self.OpenFile)164 self.actionNew_file = QtWidgets.QAction(self)165 self.actionNew_file.setObjectName("actionNew_file")166 self.file_menu.addAction(self.actionOpen_file)167 self.file_menu.addAction(self.actionNew_file)168 self.actionNew_file.setText("New file")169 self.actionNew_file.setShortcut("Ctrl+N")170 self.actionNew_file.triggered.connect(self.NewFile)171 self.main_widget = QWidget(self)172 self.actionReport = QtWidgets.QAction(self)173 self.actionReport.setObjectName("actionReport")174 self.actionReport.setText("Report")175 self.actionReport.setShortcut("Ctrl+R")176 self.actionReport.triggered.connect(self.GenerateReport)177 self.file_menu.addAction(self.actionReport)178 self.main_widget.setFocus()179 self.setCentralWidget(self.main_widget)180 self.layout = QHBoxLayout(self.main_widget)181 def GenerateReport(self):182 filenames = QFileDialog().getOpenFileNames(options=QFileDialog.DontUseNativeDialog)183 i = 0184 fig, axs = plt.subplots(len(filenames[0]),2)185 for filename in filenames[0]:186 file = open(filename)187 datalines = file.readlines()188 y = [float(line.split(',')[0]) for line in datalines]189 x = np.arange(len(y))190 axs[i, 0].plot(x, y)191 dt = 0.0005192 NFFT = 1024193 Fs = int(1.0 / dt)194 Pxx, freqs, bins, im = axs[i, 1].axes.specgram(y, NFFT=NFFT, Fs=Fs, noverlap=900)195 i+=1196 plt.savefig('report.pdf') 197198199200201 def drawButtons(self):202 self.pauseButton = QPushButton(self)203 self.pauseButton.setText("Pause") #text204 self.pauseButton.setShortcut('Ctrl+D') #shortcut key205 self.pauseButton.clicked.connect(self.pause)206 self.pauseButton.setToolTip("Close the widget") #Tool tip207 self.playButton = QPushButton(self)208 self.playButton.setText("Play") #text209 self.playButton.setShortcut('Ctrl+P') #shortcut key210 self.playButton.setToolTip("Close the widget") #Tool tip211 self.playButton.clicked.connect(self.play)212 self.Zoom = QPushButton(self)213 self.Zoom.setText("Zoom In") #text214 self.Zoom.setShortcut('Ctrl+Z') #shortcut key215 self.Zoom.setToolTip("Close the widget") #Tool tip216 self.Zoom.clicked.connect(self.zoomin)217 self.ZoomOut = QPushButton(self)218 self.ZoomOut.setText("Zoom Out") #text219 self.ZoomOut.setShortcut('Ctrl+Z') #shortcut key220 self.ZoomOut.setToolTip("Close the widget") #Tool tip221 self.ZoomOut.clicked.connect(self.zoomout)222 self.scrollLeft = QPushButton(self)223 self.scrollLeft.setText("Scroll Left") #text224 self.scrollLeft.setShortcut('Ctrl+L') #shortcut key225 self.scrollLeft.setToolTip("Close the widget") #Tool tip226 self.scrollLeft.clicked.connect(self.scrollleft)227 self.scrollRight = QPushButton(self)228 self.scrollRight.setText("Scroll Right") #text229 self.scrollRight.setShortcut('Ctrl+R') #shortcut key230 self.scrollRight.setToolTip("Close the widget") #Tool tip231 self.scrollRight.clicked.connect(self.scrollright)232 def drawSliders(self):233 self.sliders = []234 for slider_number in range(0,10):235 self.sliders.append(QSlider(QtCore.Qt.Vertical))236 self.sliders[slider_number].setFocusPolicy(QtCore.Qt.NoFocus)237 self.sliders[slider_number].setRange(0,100)238 self.sliders[slider_number].setMinimum(0)239 self.sliders[slider_number].setMaximum(5)240 self.sliders[slider_number].setSingleStep(1)241 self.sliders[slider_number].setTickInterval(1)242 self.sliders[slider_number].setTickPosition(QSlider.TicksBelow)243 self.sliders[slider_number].setValue(1)244 self.sliders[slider_number].valueChanged.connect(self.Equalizer)245 def Equalizer(self):246 slider_values = [self.sliders[slider_number].value() for slider_number in range(0,10)]247 self.dc2.Equalizer(slider_values)248 self.sc.addSpectrogram(self.dc2.getY())249250 def spectrogram_Sliders(self):251 slider_maxvalue = [self.MaxSlider.value()]252 slider_minvalue = [self.MinSlider.value()]253 resultSignal = self.dc2.spectrogramRange(slider_minvalue, slider_maxvalue,self.dc2.getY())254 self.sc.addSpectrogram(resultSignal,slider_minvalue[0],slider_maxvalue[0])255 def OpenFile(self):256 try:257 self.clearLayout(self.layout)258 except:259 pass260 self.drawButtons()261 self.drawSliders()262 filename = QFileDialog().getOpenFileName(options=QFileDialog.DontUseNativeDialog)263 try:264 f1 = open(filename[0])265 except:266 return267 f2 = open(filename[0])268 self.dc,self.dc2 = MyDynamicMplCanvas(self.main_widget, width=5, height=4, dpi=100,file=f1),MyDynamicMplCanvas(self.main_widget, width=5, height=4, dpi=100,file=f2)269 self.sc = MyStaticMplCanvas(self.main_widget, width=4, height=3, dpi=100,file=f1)270 self.sc.addSpectrogram(self.dc2.getY())271 left = QVBoxLayout()272 buttons = QHBoxLayout()273 buttons.addWidget(self.pauseButton)274 buttons.addWidget(self.playButton)275 buttons.addWidget(self.Zoom)276 buttons.addWidget(self.ZoomOut)277 buttons.addWidget(self.scrollLeft)278 buttons.addWidget(self.scrollRight)279 combo = QComboBox(self)280 combo.addItem("viridis")281 combo.addItem("plasma")282 combo.addItem("inferno")283 combo.addItem("magma")284 combo.addItem("cividis")285 combo.activated[str].connect(self.onChanged)286 textbox = QLineEdit(self)287 textbox.setFixedSize(50,20)288 textbox.setText(str(1000))289 textbox.textChanged[str].connect(self.speedChanged)290 buttons.addWidget(combo)291 buttons.addWidget(textbox)292 horizontalGroupBox = QGroupBox("Controls")293 horizontalGroupBox.setLayout(buttons)294 SlidersgroupBox = QGroupBox("Equalizer")295 sliders = QHBoxLayout()296 for slider_number in range(0,10):297 sliders.addWidget(self.sliders[slider_number])298 SlidersgroupBox.setLayout(sliders)299 SpectrogramSliders = QGroupBox("Spectrogram Sliders")300 self.MaxSlider = QSlider(QtCore.Qt.Vertical)301 self.MaxSlider.setFocusPolicy(QtCore.Qt.NoFocus)302 self.MaxSlider.setRange(0,250)303 self.MaxSlider.setSingleStep(50)304 self.MaxSlider.setTickInterval(50)305 self.MaxSlider.setTickPosition(QSlider.TicksBelow)306 self.MaxSlider.setValue(250)307 self.MinSlider = QSlider(QtCore.Qt.Vertical)308 self.MinSlider.setFocusPolicy(QtCore.Qt.NoFocus)309 self.MinSlider.setRange(0,250)310 self.MinSlider.setSingleStep(50)311 self.MinSlider.setTickInterval(50)312 self.MinSlider.setTickPosition(QSlider.TicksBelow)313 self.MinSlider.setValue(0)314 MinMaxSliders= QHBoxLayout()315 MinMaxSliders.addWidget(self.MinSlider)316 MinMaxSliders.addWidget(self.MaxSlider)317 self.MinSlider.valueChanged.connect(self.spectrogram_Sliders)318 self.MaxSlider.valueChanged.connect(self.spectrogram_Sliders)319 SpectrogramSliders.setLayout(MinMaxSliders)320 left.addWidget(horizontalGroupBox)321 left.addWidget(self.dc)322 left.addWidget(self.dc2)323 left.addWidget(self.sc)324 self.layout.addLayout(left)325 self.layout.addWidget(SlidersgroupBox)326 self.layout.addWidget(SpectrogramSliders)327 def onChanged(self,text):328 self.sc.setCmap(text)329 self.sc.addSpectrogram(self.dc2.getY())330 def speedChanged(self,speed):331 self.dc.setSpeed(int(speed))332 self.dc2.setSpeed(int(speed))333 def zoomin(self):334 self.dc.zoomin(),self.dc2.zoomin()335 def zoomout(self):336 self.dc.zoomout(),self.dc2.zoomout()337 def scrollleft(self):338 self.dc.scrollleft(),self.dc2.scrollleft()339 def scrollright(self):340 self.dc.scrollright(),self.dc2.scrollright()341 def fileQuit(self):342 self.close()343 def pause(self):344 self.dc.pause(),self.dc2.pause()345 def play(self):346 self.dc.play(),self.dc2.play()347 def closeEvent(self, ce):348 self.fileQuit()349 def NewFile(self):350 self.newWindow = ApplicationWindow()351 self.children.append(self.newWindow)352 self.newWindow.setWindowTitle("Signal Viewer")353 self.newWindow.show()354if __name__ == '__main__':
...
examine2.js
Source:examine2.js
1$(".downMenuBox div").click(function(){2 $(this).toggleClass('hover').siblings().removeClass('hover');3})4//ä¸ææ¡æ»å
¥æ»åºææ5$(".downMenuBox div").click(function(){6 //æ¶å7 $(".downMenuBox div").not(this).next(".MenuCenter").slideUp(350);8 //æ¾ç¤º9 $(this).next(".MenuCenter").slideToggle(350);10});11//tapåæ¢12$(".tapUl").find("li").click(function(){13 $(this).toggleClass("tapIco").siblings().removeClass('tapIco');14})15//æ¹åå®¡æ ¸æ°é16var num = 0;17$(".address").click(function(){18 num = $(".ListIpt").val();19 num ++;20 $(".ListIpt").val(num);21})22$(".reduce").click(function(){23 num = $(".ListIpt").val();24 if(num <= 0){25 $(".ListIpt").val("0");26 }else{27 num --;28 $(".ListIpt").val(num);29 }30})31//设置弹çªå¤§å°32var popupw = $(document).width();33var popuph = $(document).height();34$(".popup1,.popup2,.popup3,.popup4,.popup5").css("width",popupw).css("height",popuph);35//ç¹å»æ¥çå¾ççæå¼¹çª36$(".previewImg").click(function(){37 $(".popup1").show();38})39//å
³éå¾çå¼¹çª40$(".colseBtn1").click(function(){41 $(".popup1").hide();42})43//å®¡æ ¸ä¸éè¿å¼¹çª44$(".newGoods").click(function(){45 $(".popup2").show();46})47//å
³éå®¡æ ¸ä¸éè¿å¼¹çª48$(".closeImg,.popup2LeftBtn,.popup2RightBtn").click(function(){49 $(".popup2").hide();50 $(".popup3").hide();51})52//å¾
客æ·åé¦å¼¹çª53$(".feedback").click(function(){54 $(".popup3").show();55})56//客æ·æ¾å¼å¼¹çª57$(".giveUp").click(function(){58 $(".popup4").show();59})60//å
³é客æ·æ¾å¼å¼¹çª61$(".closeImg,.popup4LeftBtn,.popup4RightBtn").click(function(){62 $(".popup4").hide();63})64//é¼ æ 移å¨æ»å¨æ¡äºä»¶65$(".scrollRight").mousedown(function(){66 //è·åé¼ æ å¨æ»å¨æ¡éçä½ç½®67 var y = event.clientY - $(this).position().top;68 //é¼ æ 移å¨äºä»¶69 $(document).mousemove(function(){70 //è·åæ»å¨æ¡ç移å¨ä½ç½®71 var y1 = event.clientY - y;72 //设置æ»å¨æ¡ç移å¨73 $(".scrollRight").css("top",y1);74 //è·åæ··å¨æ¡ç¶çº§çé«75 var h = $(".scrollRightBox").outerHeight();76 //å
容移å¨77 var ch = y1 * $(".scrollLeftUl").outerHeight() / $(".scrollRightBox").outerHeight() + 45;78 $(".scrollLeftUl").css("top",-ch);79 //ææ¬ãæ»å¨æ¡ç¢°å£æ£æµ80 var bh = $(".scrollRight").position().top;81 if(bh <= 0){82 $(".scrollRight").css("top","0px");83 $(".scrollLeftUl").css("top","0px");84 }else if(bh >= $(".scrollRightBox").outerHeight() - $(".scrollRight").outerHeight()){85 $(".scrollRight").css("top",$(".scrollRightBox").outerHeight() - $(".scrollRight").outerHeight());86 $(".scrollLeftUl").css("top",$(".scrollLeftBox").outerHeight() - $(".scrollLeftUl").outerHeight());87 }88 })89})90//æ¾å¼é¼ æ 移é¤ç§»å¨äºä»¶91$(document).mouseup(function(){92 $(document).unbind("mousemove");93})94//æ»å¨æ¡æ»å¨äºä»¶95var up = 0;96$(".scrollBox").on("mousewheel DOMMouseScroll", function (e) {97 var delta = (e.originalEvent.wheelDelta && (e.originalEvent.wheelDelta > 0 ? 1 : -1)) || //å
¼å®¹chrome & ie98 (e.originalEvent.detail && (e.originalEvent.detail > 0 ? -1 : 1));//å
¼å®¹firefox99 if (delta < 0) {100 //åä¸æ»101 up += 10102 $(".scrollRight").css("top",up);103 $(".scrollLeftUl").css("top",-up * ($(".scrollLeftUl").outerHeight() / ($(".scrollRight").outerHeight())));104 } else if (delta > 0) {105 //åä¸æ»106 up -= 10107 $(".scrollRight").css("top",up);108 $(".scrollLeftUl").css("top",-up * ($(".scrollLeftUl").outerHeight() / ($(".scrollRight").outerHeight())));109 }110 //碰å£æ£æµ111 //ææ¬ãæ»å¨æ¡ç¢°å£æ£æµ112 var bh = $(".scrollRight").position().top;113 if(bh <= 0){114 up = 0;115 $(".scrollRight").css("top","0px");116 $(".scrollLeftUl").css("top","0px");117 }else if(bh >= $(".scrollRightBox").outerHeight() - $(".scrollRight").outerHeight()){118 up = $(".scrollRightBox").outerHeight() - $(".scrollRight").outerHeight();119 $(".scrollRight").css("top",$(".scrollRightBox").outerHeight() - $(".scrollRight").outerHeight());120 $(".scrollLeftUl").css("top",-($(".scrollLeftUl").outerHeight() - $(".scrollLeftBox").outerHeight()));121 }122 //æ¸
é¤é»è®¤æ»è½®äºä»¶123 return false;124});125//ç¹å»åæ客æ·åè´§çæå¼¹çª126$(".agreeBtn").click(function(){127 $(".popup5").show();128})129//å
³éåæ客æ·å®¡æ ¸å¼¹çª130$(".closeImg,.saveBtn").click(function(){131 $(".popup5").hide();132})133var time = setInterval(function(){134 var secdDay = new Date(2018,5,15).getTime();135 var Now = new Date().getTime();136 var oDate = new Date();137 var date = oDate.getDate();138 var h = oDate.getHours();139 var m = oDate.getMinutes();140 var s = oDate.getSeconds();141 //æ»æ¶é´å·®142 var all = secdDay - Now;143 //ç§144 var ses = Math.floor((all/1000)%60);145 //å146 var minu = Math.floor((all/(1000*60))%60);147 //æ¶148 var hour = Math.floor((all/(1000*60*60))%24);149 //天150 var day = Math.floor((all/(1000*60*60*24)));151 $(".dayTxt").text(day);152 $(".hourtxt").text(hour);153 $(".minuTxt").text(minu);154 $(".sesTxt").text(ses);155},1000)156$(".list").show();157//tapåæ¢å
容158//è·åå
ç´ çç´¢å¼å¼159$(".tapUl").find("li").click(function(){160 var num = $(this).index();161 $(".List").hide();162 $(".List").eq(num).show();
...
editor.py
Source:editor.py
1from State.state import State2import pygame3# Nowe elementy: tlo, animacja tla, przewijanie, tick Clocka, Nowe rzeczy konstruktor4class Editor(State):5 def __init__(self,game):6 super().__init__(game)7 self.TILESIZE = 328 self.LOWERMARGIN = 1009 self.SIDEMARGIN = 20010 self.COLS = 3011 self.ROWS = (self.game.DISPLAY_WIDTH - self.SIDEMARGIN) // self.TILESIZE12 self.scrollLeft = False13 self.scrollRight = False14 self.leftShift=False15 self.scroll = 016 self.scrollSpeed = 117 self.keyBackspace = False18 self.cloudImage = pygame.image.load('./Sprites/Background/sky_cloud.png').convert_alpha()19 self.skyImage = pygame.image.load('./Sprites/Background/sky.png').convert_alpha()20 #self.skyRect = self.skyImage.get_rect()21 self.mountainImage = pygame.image.load('./Sprites/Background/mountain2.png').convert_alpha()22 #self.mountainRect = self.mountainImage.get_rect()23 self.pineForestImg1 = pygame.image.load('./Sprites/Background/pine2.png').convert_alpha()24 #self.pineRect1 = self.pineForestImg1.get_rect()25 self.pineForestImg2 = pygame.image.load('./Sprites/Background/pine1.png').convert_alpha()26 #self.pineRect2 = self.pineForestImg2.get_rect()27 self.TILE_COUNT = 1628 self.InitTiles()29 def InitTiles(self):30 self.imgList = []31 for x in range(5):32 img = pygame.image.load(f'Sprites/Tiles/grass_{x+1}.png')33 img=pygame.transform.scale(img,(self.TILESIZE,self.TILESIZE))34 self.imgList.append(img)35 for x in range(11):36 img = pygame.image.load(f'Sprites/Tiles/ground_{x+1}.png')37 img = pygame.transform.scale(img, (self.TILESIZE, self.TILESIZE))38 self.imgList.append(img)39 def ResetKeys(self):40 self.keyBackspace = False41 def CheckInput(self):42 if (self.keyBackspace):43 print("Backspace")44 if (self.scrollLeft and self.scroll > 15):45 self.scroll -= 5 * self.scrollSpeed46 if (self.scrollRight):47 self.scroll += 5 * self.scrollSpeed48 if (self.leftShift):49 self.scrollSpeed=550 if (self.leftShift==False):51 self.scrollSpeed=152 def UpdateEvents(self):53 for event in pygame.event.get():54 if event.type == pygame.QUIT:55 self.runDisplay = False56 self.game.start = False57 if event.type == pygame.KEYDOWN:58 if event.key == pygame.K_BACKSPACE:59 self.keyBackspace = True60 print(self.keyBackspace)61 if event.key == pygame.K_LEFT:62 self.scrollLeft = True63 if event.key==pygame.K_LSHIFT:64 self.leftShift=True65 if event.key == pygame.K_RIGHT:66 self.scrollRight = True67 if event.type == pygame.KEYUP:68 if event.key == pygame.K_LEFT:69 self.scrollLeft = False70 if event.key == pygame.K_RIGHT:71 self.scrollRight = False72 if event.key==pygame.K_LSHIFT:73 self.leftShift=False74 def Update(self):75 self.UpdateEvents()76 self.CheckInput()77 self.ResetKeys()78 pygame.display.update()79 def DrawBg(self):80 # ZMIANY81 self.game.display.fill(self.game.COLORS["gray"])82 width = self.skyImage.get_width()83 for x in range(4):84 self.game.display.blit(self.cloudImage, ((x * width)-self.scroll * 0.5,0))85 self.game.display.blit(self.skyImage, ((x * width)-self.scroll * 0.6, self.game.DISPLAY_HEIGHT - self.skyImage.get_height() - 250))86 self.game.display.blit(self.mountainImage,((x * width)-self.scroll * 0.7, self.game.DISPLAY_HEIGHT - self.mountainImage.get_height() - 250))87 self.game.display.blit(self.pineForestImg2, ((x * width)-self.scroll * 0.8,self.game.DISPLAY_HEIGHT - self.pineForestImg2.get_height() - 180))88 self.game.display.blit(self.pineForestImg1, ((x * width)-self.scroll * 0.9,self.game.DISPLAY_HEIGHT - self.pineForestImg2.get_height() - 150))89 def DrawGrid(self):90 for i in range(self.COLS):91 pygame.draw.line(self.game.display,self.game.COLORS["white"],(i * self.TILESIZE - self.scroll,0),(i*self.TILESIZE - self.scroll,self.game.DISPLAY_HEIGHT- self.LOWERMARGIN))92 for i in range(self.ROWS):93 pygame.draw.line(self.game.display,self.game.COLORS["white"],(0,i * self.TILESIZE),(self.game.DISPLAY_WIDTH - self.SIDEMARGIN,i * self.TILESIZE))94 def InitBattons(self):95 pass96 def DrawEditorPanel(self):97 pygame.draw.rect(self.game.display,self.game.COLORS['black'],(self.game.DISPLAY_WIDTH - self.SIDEMARGIN,0,self.SIDEMARGIN,self.game.DISPLAY_HEIGHT + self.LOWERMARGIN))98 pygame.draw.rect(self.game.display,self.game.COLORS["black"],(0,self.game.DISPLAY_HEIGHT - self.LOWERMARGIN,self.game.DISPLAY_WIDTH,self.game.DISPLAY_HEIGHT - self.LOWERMARGIN))99 def Render(self):100 self.DrawBg()101 self.DrawGrid()102 self.DrawEditorPanel()103 self.BlitScreen()104 def DisplayState(self):105 print("Jestem w edytorze.")106 while self.runDisplay:107 self.Update()108 self.Render()109 # ZEGAR...
index.js
Source:index.js
1const {http} = require('../../request/http');2Component({3 properties: {4 show: {5 type: Boolean,6 value: false7 },8 province:{9 type: String,10 value: ''11 },12 city:{13 type: String,14 value: ''15 }16 },17 data: {18 list:[],19 scrollLeft:[],20 scrollRight:[],21 _index: 022 },23 methods: {24 handleLeft(e){25 console.log(e)26 let {index} = e.currentTarget.dataset;27 let {list,scrollLeft} = this.data;28 scrollLeft.forEach((item,index1)=>{29 if(index1 === index){30 item.active = true31 }else{32 item.active = false33 }34 });35 let scrollRight = (list[index].routeStop).map(item=>{36 return{37 name: item,38 active:false39 }40 });41 this.setData({42 _index:index,43 scrollRight:scrollRight,44 scrollLeft:scrollLeft45 })46 },47 handleRight(e){48 let {index} = e.currentTarget.dataset;49 console.log(index);50 let {scrollRight} = this.data;51 scrollRight[index]['active'] = !scrollRight[index]['active']52 this.setData({53 scrollRight54 });55 },56 getList(){57 let that = this;58 let {province,city} = this.properties;59 http({60 url: '/api/access/v1/house/metro/line/list',61 method: 'GET',62 params:{63 city: city,64 proviince: province65 }66 }).then(res=>{67 console.log(res)68 let scrollLeft = res.map((item,index)=>{69 return {70 lineName: item.lineName,71 active: index===0? true:false72 }73 });74 let scrollRight = (res[0].routeStop).map(item=>{75 return{76 name: item,77 active:false78 }79 });80 that.setData({81 scrollLeft,82 scrollRight,83 list: res84 });85 }).catch(err=>{86 console.log(err)87 });88 },89 onClose(){90 this.triggerEvent('close',{detail:''})91 },92 clear(){93 let {scrollRight} = this.data;94 scrollRight.forEach(item=>{95 item.active=false;96 });97 this.setData({98 _index: -1,99 scrollRight:scrollRight100 });101 },102 sure(){103 if(this.data['list'].length===0){104 this.triggerEvent('close',{detail:[]});105 return;106 }107 let {_index,scrollLeft,scrollRight}=this.data;108 let lineName = scrollLeft[_index]['lineName'];109 console.log(lineName);110 let routeStop = scrollRight.filter(item=>item.active===true);111 if(routeStop.length === 0){112 this.triggerEvent('close',{detail:[]});113 return;114 }115 console.log(routeStop);116 // let chooseSubWay = routeStop.map(item=> lineName+'/'+item.name);117 let chooseSubWay = routeStop.map(item=> {118 return{119 lineName: lineName,120 routeStop: item.name121 }122 });123 this.triggerEvent('close',{detail:chooseSubWay});124 }125 },126 lifetimes:{127 ready() {128 // wx.nextTick(()=>{129 // this.getList();130 // });131 this.getList();132 }133 }...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!