mirror of
				https://github.com/TeamPiped/Piped.git
				synced 2024-08-14 23:57:27 +00:00 
			
		
		
		
	Search suggestions and box.
This commit is contained in:
		
							parent
							
								
									c5801c437e
								
							
						
					
					
						commit
						dfa94f6d7f
					
				
					 1 changed files with 27 additions and 1 deletions
				
			
		
							
								
								
									
										28
									
								
								src/App.vue
									
										
									
									
									
								
							
							
						
						
									
										28
									
								
								src/App.vue
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -13,6 +13,15 @@
 | 
			
		|||
                    >Piped</router-link
 | 
			
		||||
                >
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="uk-navbar-center">
 | 
			
		||||
                <input
 | 
			
		||||
                    class="uk-input uk-form-width-large"
 | 
			
		||||
                    type="text"
 | 
			
		||||
                    placeholder="Search"
 | 
			
		||||
                    v-model="searchText"
 | 
			
		||||
                    @keypress="onChange($event)"
 | 
			
		||||
                />
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="uk-navbar-right">
 | 
			
		||||
                <ul class="uk-navbar-nav">
 | 
			
		||||
                    <li>
 | 
			
		||||
| 
						 | 
				
			
			@ -33,9 +42,26 @@
 | 
			
		|||
</template>
 | 
			
		||||
 | 
			
		||||
<script>
 | 
			
		||||
import Constants from "@/Constants.js";
 | 
			
		||||
export default {
 | 
			
		||||
    data() {
 | 
			
		||||
        return {};
 | 
			
		||||
        return {
 | 
			
		||||
            searchText: "",
 | 
			
		||||
            searchSuggestions: []
 | 
			
		||||
        };
 | 
			
		||||
    },
 | 
			
		||||
    methods: {
 | 
			
		||||
        onChange(e) {
 | 
			
		||||
            fetch(
 | 
			
		||||
                Constants.BASE_URL +
 | 
			
		||||
                    "/suggestions?query=" +
 | 
			
		||||
                    encodeURI(this.searchText + e.key)
 | 
			
		||||
            )
 | 
			
		||||
                .then(resp => resp.json())
 | 
			
		||||
                .then(json => {
 | 
			
		||||
                    this.searchSuggestions = json;
 | 
			
		||||
                });
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
};
 | 
			
		||||
</script>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue