1
function get_data(str, nm)
3
if(typeof(str) == 'object')
5
if( typeof(str.cb) != "undefined") cb = str.cb
9
if(typeof(cache[str]) != "undefined")
12
//$("#loading").fadeIn(500)
16
xhr = new XMLHttpRequest()
17
xhr.open("GET", url + "?" + str, false)
20
response = JSON.parse(xhr.responseText)
23
if(typeof(cb) != "undefined")
24
response = eval(cb+"(response, nm)")
33
function parse_posts_pages(obj, jso, cb, nm)
35
ret = {type: 'folder', dname: nm }
37
$.each(obj, function()
39
cat = {type: 'folder', dname: this.title }
41
if(this.post_count <= 20)
46
cat.include = 'slug,title,id,date'
52
for( var i = 0; i < Math.ceil(this.post_count / 20); i++ )
54
cat[i] = {type: 'folder', dname: 'Page '+(i+1), cb: cb, json: jso, include: 'slug,title,id,date', page: i, slug: this.slug, count: 20}
64
function parse_categories(str,nm)
66
return parse_posts_pages(str.categories, 'get_category_posts', 'parse_posts', nm)
69
function parse_tags(str,nm)
71
ret = {type: 'folder', dname: nm}
77
$.each(str.tags, function()
79
s = this.slug.substr(0,1)
80
if( typeof(ret[s]) == "undefined" )
85
ret[s] = {type:'folder', dname: s}
89
slugs[s].push(this.slug)
90
ret[s][this.slug] = {type: 'folder', dname: this.title, cb: "parse_posts", json: "get_tag_posts", include: "slug,title,id,date", slug: this.slug}
92
out = {type:'folder', dname: nm}
94
$.each(pres, function(i)
99
out[slug] = ret[s][slug]
107
function parse_authors(str,nm)
109
ret = {type: 'folder', dname: nm }
111
$.each(str.authors, function()
113
cat = {type: 'folder', dname: this.name }
115
cat.cb = "parse_posts"
116
cat.json = 'get_author_posts'
117
cat.include = 'slug,title,id,date'
128
function parse_posts(data, nm)
131
ret = {type: 'folder', dname: nm}
133
$.each(data.posts, function()
135
ret[this.date.replace(/[ :-]+/g, "")] = {type: 'file', url: this.slug, dname: this.title, cb: 'parse_post', json:'get_post', id: this.id}
137
// console.log("parse posts", ret)
141
function parse_post(data)
145
content = $("<div>"+data.content+"</div>");
146
content.find("style, img, .gallery, *:empty, a[href$=png], a[href$=jpg], a[href$=jpeg], embed, object, param").remove()
147
content.find("a").each( function()
149
$(this).attr("href", "javascript: handle_click('"+$(this).attr("href")+"')")
151
content = content.html().replace(/[\s]+/g, " ")
153
pad = title.replace(/./g, "-")+"--"
155
return {type: 'file', dname: title, content: "\n"+pad+"\n> "+title+"\n"+pad+"\n\n"+content}
158
function parse_dates(data,nm)
160
months = {"01":"January", "02":"February", "03":"March", "04":"April", "05":"May", "06":"June", "07":"July", "08":"August", "09":"September", "10":"October", "11":"November", "12":"December"}
161
ret = {type: 'folder', dname: nm}
162
$.each(data.tree, function(i,v)
164
year = {type: 'folder', dname: i}
165
$.each(data.tree[i], function(j)
167
year[j] = {type: 'folder', dname: months[j], cb:'parse_posts', json:'get_date_posts','date': i+"-"+j,'count':this.toString(), include:'slug,title,id,date'}
b'\\ No newline at end of file'