Allow temp region selection from result view
This adds a new "temporary" config section of the results view, where a user can now change the country that their results come from without changing their default config settings. Closes #322
This commit is contained in:
		
							parent
							
								
									8e867a5ace
								
							
						
					
					
						commit
						3f363b0175
					
				| 
						 | 
				
			
			@ -406,6 +406,9 @@ def search():
 | 
			
		|||
        search_header=render_template(
 | 
			
		||||
            'header.html',
 | 
			
		||||
            config=g.user_config,
 | 
			
		||||
            translation=translation,
 | 
			
		||||
            languages=app.config['LANGUAGES'],
 | 
			
		||||
            countries=app.config['COUNTRIES'],
 | 
			
		||||
            logo=render_template('logo.html', dark=g.user_config.dark),
 | 
			
		||||
            query=urlparse.unquote(query),
 | 
			
		||||
            search_type=search_util.search_type,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -143,7 +143,7 @@ select {
 | 
			
		|||
    color: var(--whoogle-dark-contrast-text) !important;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.content {
 | 
			
		||||
.content, .result-config {
 | 
			
		||||
    background-color: var(--whoogle-dark-element-bg) !important;
 | 
			
		||||
    color: var(--whoogle-contrast-text) !important;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,6 +13,12 @@ header {
 | 
			
		|||
    border-radius: 2px 0 0 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.result-config {
 | 
			
		||||
    margin: 10px 0 10px 0;
 | 
			
		||||
    padding: 10px;
 | 
			
		||||
    border-radius: 8px;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.mobile-logo {
 | 
			
		||||
    font: 22px/36px Futura, Arial, sans-serif;
 | 
			
		||||
    padding-left: 5px;
 | 
			
		||||
| 
						 | 
				
			
			@ -121,7 +127,6 @@ a {
 | 
			
		|||
.header-tab-div {
 | 
			
		||||
    border-radius: 0 0 8px 8px;
 | 
			
		||||
    box-shadow: 0 2px 3px rgba(32, 33, 36, 0.18);
 | 
			
		||||
    margin-bottom: 20px;
 | 
			
		||||
    overflow: hidden;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -129,7 +129,7 @@ input {
 | 
			
		|||
    color: var(--whoogle-contrast-text) !important;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.content {
 | 
			
		||||
.content, .result-config {
 | 
			
		||||
    background-color: var(--whoogle-element-bg) !important;
 | 
			
		||||
    color: var(--whoogle-contrast-text) !important;
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,8 +1,19 @@
 | 
			
		|||
document.addEventListener("DOMContentLoaded", () => {
 | 
			
		||||
    const searchBar = document.getElementById("search-bar");
 | 
			
		||||
    const countrySelect = document.getElementById("result-country");
 | 
			
		||||
    const arrowKeys = [37, 38, 39, 40];
 | 
			
		||||
    let searchValue = searchBar.value;
 | 
			
		||||
 | 
			
		||||
    countrySelect.onchange = () => {
 | 
			
		||||
        let str = window.location.href;
 | 
			
		||||
        n = str.lastIndexOf("search");
 | 
			
		||||
        if (n > 0) {
 | 
			
		||||
            str = str.substring(0, n) +
 | 
			
		||||
                `search?q=${searchBar.value}&country=${countrySelect.value}`;
 | 
			
		||||
            window.location.href = str;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    searchBar.addEventListener("keyup", function(event) {
 | 
			
		||||
        if (event.keyCode === 13) {
 | 
			
		||||
            document.getElementById("search-form").submit();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2,7 +2,7 @@
 | 
			
		|||
    "lang_en": {
 | 
			
		||||
        "search": "Search",
 | 
			
		||||
        "config": "Configuration",
 | 
			
		||||
        "config-country": "Set Country",
 | 
			
		||||
        "config-country": "Country",
 | 
			
		||||
        "config-lang": "Interface Language",
 | 
			
		||||
        "config-lang-search": "Search Language",
 | 
			
		||||
        "config-near": "Near",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,6 +25,7 @@
 | 
			
		|||
                                dir="auto">
 | 
			
		||||
                        <input id="search-reset" type="reset" value="x">
 | 
			
		||||
                        <input name="tbm" value="{{ search_type }}" style="display: none">
 | 
			
		||||
                        <input name="country" value="{{ config.country }}" style="display: none;">
 | 
			
		||||
                        <input type="submit" style="display: none;">
 | 
			
		||||
                        <div class="sc"></div>
 | 
			
		||||
                    </div>
 | 
			
		||||
| 
						 | 
				
			
			@ -79,6 +80,7 @@
 | 
			
		|||
                                value="{{ clean_query(query) }}"
 | 
			
		||||
                                dir="auto">
 | 
			
		||||
                        <input name="tbm" value="{{ search_type }}" style="display: none">
 | 
			
		||||
                        <input name="country" value="{{ config.country }}" style="display: none;">
 | 
			
		||||
                        <input type="submit" style="display: none;">
 | 
			
		||||
                        <div class="sc"></div>
 | 
			
		||||
                    </div>
 | 
			
		||||
| 
						 | 
				
			
			@ -103,6 +105,24 @@
 | 
			
		|||
              </div>
 | 
			
		||||
          </div>
 | 
			
		||||
      </div>
 | 
			
		||||
 | 
			
		||||
      <div class="result-config">
 | 
			
		||||
          <label for="config-country">{{ translation['config-country'] }}: </label>
 | 
			
		||||
          <select name="country" id="result-country">
 | 
			
		||||
              {% for country in countries %}
 | 
			
		||||
                  <option value="{{ country.value }}"
 | 
			
		||||
                          {% if (
 | 
			
		||||
                              config.country != '' and config.country in country.value
 | 
			
		||||
                          ) or (
 | 
			
		||||
                              config.country == '' and country.value == '')
 | 
			
		||||
                          %}
 | 
			
		||||
                          selected
 | 
			
		||||
                          {% endif %}>
 | 
			
		||||
                      {{ country.name }}
 | 
			
		||||
                  </option>
 | 
			
		||||
              {% endfor %}
 | 
			
		||||
          </select>
 | 
			
		||||
      </div>
 | 
			
		||||
      <div class="" id="s">
 | 
			
		||||
  </div>
 | 
			
		||||
{% endif %}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user