Add interface for creating bookmarks.
This commit is contained in:
		
							parent
							
								
									9a156672b0
								
							
						
					
					
						commit
						1149283c7b
					
				
					 1 changed files with 28 additions and 0 deletions
				
			
		|  | @ -53,11 +53,39 @@ | ||||||
|                 <a href="{{bookmark.url}}" class="bookmark_url">{{bookmark.url}}</a> |                 <a href="{{bookmark.url}}" class="bookmark_url">{{bookmark.url}}</a> | ||||||
|             </div> |             </div> | ||||||
|             {% endfor %} |             {% endfor %} | ||||||
|  |             <div class="new_bookmark_card"> | ||||||
|  |                 <input id="new_bookmark_title" type="text" placeholder="title"> | ||||||
|  |                 <input id="new_bookmark_url" type="text" placeholder="url"> | ||||||
|  |                 <button id="new_bookmark_button" class="green_button" onclick="submit_bookmark_form()">Create</button> | ||||||
|  |             </div> | ||||||
|         </div> |         </div> | ||||||
|     </div> |     </div> | ||||||
| </body> | </body> | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| <script type="text/javascript"> | <script type="text/javascript"> | ||||||
|  | function submit_bookmark_form() | ||||||
|  | { | ||||||
|  |     var url = document.getElementById("new_bookmark_url").value.trim(); | ||||||
|  |     var title = document.getElementById("new_bookmark_title").value.trim(); | ||||||
|  |     if (!url) | ||||||
|  |     { | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  |     return create_bookmark(url, title); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | function create_bookmark(url, title) | ||||||
|  | { | ||||||
|  |     var api_url = "/bookmarks/create_bookmark"; | ||||||
|  |     var data = new FormData(); | ||||||
|  |     data.append("url", url); | ||||||
|  |     if (title) | ||||||
|  |     { | ||||||
|  |         data.append("title", title); | ||||||
|  |     } | ||||||
|  |     var callback = function(){location.reload();}; | ||||||
|  |     post(api_url, data, callback); | ||||||
|  | } | ||||||
| </script> | </script> | ||||||
| </html> | </html> | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue