Archive for the JavaScript Category

Google Custom Search – Restricted to specific directory, and filetype…

Posted in CSE, Custom Search Engine, Google, Google, Information Technology, JavaScript with tags , , , , , , , , , on 2012.26.01 by w3bguy

So I’ve been having trouble getting a new Google Custom Search to look only in a specific directory on my web server, as well as to only look at specific file types.   It seemed like this should have been SO easy…  But, it took me a bit to figure it out.  So here’s the information just in case anyone else needs it.

  1. Set up a new search engine, in Google Custom Search.
  2. Make sure that you have the root directory in the “Sites” section.  I used “www.mydomain.com”.
  3. You can enter refinements, but they only seem to work if the user clicks on them; not what I wanted.
  4. Go down to “Get Code” and grab the code block that is created for you.  For me it was this:
    • <div id="cse" style="width: 100%;">Loading</div>
        <script src="http://www.google.com/jsapi" type="text/javascript"></script>
        <script type="text/javascript">
          google.load('search', '1', {language : 'en', style : google.loader.themes.MINIMALIST});
          google.setOnLoadCallback(function() {
            var customSearchOptions = {};
            var customSearchControl = new google.search.CustomSearchControl(
              'Custom Search ID', customSearchOptions);
            customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
            customSearchControl.draw('cse');
          }, true);
      </script>
  5. This will give you the basic search.  In order to add in the site restriction and the filetype restriction I changed it to:
    • <div id="cse" style="width: 100%;">Loading</div>
        <script src="http://www.google.com/jsapi" type="text/javascript"></script>
      <script type="text/javascript">
      google.load('search', '1', {language : 'en', style : google.loader.themes.MINIMALIST});
      google.setOnLoadCallback(function(){
      var customSearchOptions ={};
      /* Add Custom Search Option to restrict directory */
      customSearchOptions [google.search.Search.RESTRICT_EXTENDED_ARGS]={"as_sitesearch": "www.myDomain.com/subDirectory1/subDirectory2/"};
      var customSearchControl = new google.search.CustomSearchControl("Custom Search ID", customSearchOptions );
      customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
      customSearchControl.draw('cse');
      /* Add query addition to restrict filetype */
      customSearchControl.setSearchStartingCallback(
      this,
      function(control, searcher, query) {
      searcher.setQueryAddition("filetype:pdf OR filetype:PDF");
      }
      );
      }, true);
        </script>

    I hope that helps out anyone else who might be looking for a similar problem…

Easy GPS Coordinates

Posted in Google, Google, Google Maps, JavaScript, Web Development with tags , , on 2010.05.11 by w3bguy

Ever need to find the GPS coordinates for a location?
Try the simple step below to get the GPS coordinates for any location, using Google Maps:

  1. Open Google Maps, and find the areayou wish GPS coordinates for
  2. Right click at the specific spot you would like GPS coordinates for
  3. Select “center map here” from the list
  4. Paste this JavaScript code into the address bar
    • javascript:void(prompt(”,gApplication.getMap().getCenter()));
  5. Press Enter on your keyboard
  6. A pop-up will appear showing the coordinates of the center of the map. It should look something like this: (43.60336, -110.7362)
  7. Right click on the coordinates to copy, and click either “OK” or “Cancel”

13 Super Useful jQuery Content Slider Scripts and Tutorials

Posted in Information Technology, JavaScript, jQuery, Programming on 2010.21.07 by w3bguy

via WDL

You’ve probably noticed that a lot of websites lately have a featured area with content that slides or changes in some way. This is a great technique to show several pieces of content in a limited amount of space and a good way to engage the user. If you’ve been wondering how this is accomplished, here are 13 very useful tutorials and scripts that will help you create these types of effects using jQuery.