Sfoglia il codice sorgente

TipueSearch loads page list from sitemap

Talha Mansoor 12 anni fa
parent
commit
e2320c4566
1 ha cambiato i file con 25 aggiunte e 1 eliminazioni
  1. 25 1
      static/tipuesearch/tipuesearch_set.js

+ 25 - 1
static/tipuesearch/tipuesearch_set.js

@@ -20,5 +20,29 @@ var tipuesearch_stem = {"words": [
      {"word": "javascript", stem: "js"}
 ]};
 
-var tipuesearch_pages = ["http://foo.com/", "http://foo.com/about/", "http://foo.com/blog/", "http://foo.com/tos/"];
+var tipuesearch_pages;
 
+function showGetResult()
+{
+     var result = new Array();
+     var scriptUrl = 'sitemap.xml';
+     $.ajax({
+        url: scriptUrl,
+        type: 'GET',
+        dataType: 'xml',
+        async: false,
+        success: function(xml) {
+            $(xml).find('url').each(function(){
+                var loc = $(this).find('loc').text();
+                result.push(loc);
+            });
+        },
+        error: function() {
+            alert('An error occurred while processing XML file.'); 
+        }
+     });
+     return result;
+}
+
+var r = showGetResult();
+tipuesearch_pages = r;