浏览代码

TipueSearch loads page list from sitemap

Talha Mansoor 12 年之前
父节点
当前提交
e2320c4566
共有 1 个文件被更改,包括 25 次插入1 次删除
  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;