forked from mrlan/EnglishPal
				
			Merge branch 'SPM-Spring2021-2597-占健豪201831990539' of https://github.com/lanlab-org/EnglishPal into BugFix254-Author-ZhanJianhao
						commit
						c581601bf3
					
				
							
								
								
									
										12
									
								
								app/main.py
								
								
								
								
							
							
						
						
									
										12
									
								
								app/main.py
								
								
								
								
							|  | @ -283,6 +283,7 @@ def unfamiliar(username,word): | |||
|     user_freq_record = path_prefix + 'static/frequency/' + 'frequency_%s.pickle' % (username) | ||||
|     pickle_idea.unfamiliar(user_freq_record,word) | ||||
|     session['thisWord'] = word  # 1. put a word into session | ||||
|     session['time'] = 1 | ||||
|     return redirect(url_for('userpage', username=username)) | ||||
| 
 | ||||
| @app.route("/<username>/<word>/familiar", methods=['GET', 'POST']) | ||||
|  | @ -290,6 +291,7 @@ def familiar(username,word): | |||
|     user_freq_record = path_prefix + 'static/frequency/' + 'frequency_%s.pickle' % (username) | ||||
|     pickle_idea.familiar(user_freq_record,word) | ||||
|     session['thisWord'] = word  # 1. put a word into session | ||||
|     session['time'] = 1 | ||||
|     return redirect(url_for('userpage', username=username)) | ||||
| 
 | ||||
| @app.route("/<username>/<word>/del", methods=['GET', 'POST']) | ||||
|  | @ -362,7 +364,12 @@ def userpage(username): | |||
|         if session.get('thisWord'): | ||||
|             page += ''' | ||||
|                    <script type="text/javascript"> | ||||
|                        location.href = "#aaa"  // 2. define a anchor URL and point to the anchor in the page whose id is aaa | ||||
|                         //point to the anchor in the page whose id is aaa if it exists | ||||
|                         window.onload = function(){ | ||||
|                             var element = document.getElementsByName("aaa"); | ||||
|                             if (element != null) | ||||
|                                 document.getElementsByName("aaa")[0].scrollIntoView(true); | ||||
|                         } | ||||
|                    </script>  | ||||
|                    ''' | ||||
| 
 | ||||
|  | @ -376,8 +383,9 @@ def userpage(username): | |||
|             for x in sort_in_descending_order(lst2): | ||||
|                 word = x[0] | ||||
|                 freq = x[1] | ||||
|                 if session.get('thisWord') == x[0]: | ||||
|                 if session.get('thisWord') == x[0] and session.get('time') == 1: | ||||
|                     page += '<a name="aaa"></a>'    # 3. anchor | ||||
|                     session['time'] = 0   # discard anchor | ||||
|                 if isinstance(d[word], list): # d[word] is a list of dates | ||||
|                     if freq > 1: | ||||
|                         page += '<p class="new-word"> <a href="%s">%s</a>(<a title="%s">%d</a>) <a href="%s/%s/familiar">熟悉</a> <a href="%s/%s/unfamiliar">不熟悉</a>  <a href="%s/%s/del">删除</a> </p>\n' % (youdao_link(word), word, '; '.join(d[word]), freq,username, word,username,word, username,word) | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue