Show More
@@ -1,111 +1,104 b'' | |||||
1 | function $X(path, root) { |
|
1 | function $X(path, root) { | |
2 | return document.evaluate(path, root || document, null, 6, null); |
|
2 | return document.evaluate(path, root || document, null, 6, null); | |
3 | } |
|
3 | } | |
4 | function $x(path, root) { |
|
4 | function $x(path, root) { | |
5 | return document.evaluate(path, root || document, null, 8, null).singleNodeValue; |
|
5 | return document.evaluate(path, root || document, null, 8, null).singleNodeValue; | |
6 | } |
|
6 | } | |
7 |
|
7 | |||
8 | function $del(el) { |
|
8 | function $del(el) { | |
9 | if(el) el.parentNode.removeChild(el); |
|
9 | if(el) el.parentNode.removeChild(el); | |
10 | } |
|
10 | } | |
11 |
|
11 | |||
12 | function $each(list, fn) { |
|
12 | function $each(list, fn) { | |
13 | if(!list) return; |
|
13 | if(!list) return; | |
14 | var i = list.snapshotLength; |
|
14 | var i = list.snapshotLength; | |
15 | if(i > 0) while(i--) fn(list.snapshotItem(i), i); |
|
15 | if(i > 0) while(i--) fn(list.snapshotItem(i), i); | |
16 | } |
|
16 | } | |
17 |
|
17 | |||
18 | function addRefLinkPreview(node) { |
|
18 | function addRefLinkPreview(node) { | |
19 | $each($X('.//a[starts-with(text(),">>")]', node || document), function(link) { |
|
19 | $each($X('.//a[starts-with(text(),">>")]', node || document), function(link) { | |
20 | link.addEventListener('mouseover', showPostPreview, false); |
|
20 | link.addEventListener('mouseover', showPostPreview, false); | |
21 | link.addEventListener('mouseout', delPostPreview, false); |
|
21 | link.addEventListener('mouseout', delPostPreview, false); | |
22 | }); |
|
22 | }); | |
23 | } |
|
23 | } | |
24 |
|
24 | |||
25 | function showPostPreview(e) { |
|
25 | function showPostPreview(e) { | |
26 | var doc = document; |
|
26 | var doc = document; | |
27 | //ref id |
|
27 | //ref id | |
28 | var pNum = $(this).text().match(/\d+/); |
|
28 | var pNum = $(this).text().match(/\d+/); | |
29 |
|
29 | |||
30 | //position |
|
30 | //position | |
31 | //var x = e.clientX + (doc.documentElement.scrollLeft || doc.body.scrollLeft) - doc.documentElement.clientLeft + 1; |
|
31 | //var x = e.clientX + (doc.documentElement.scrollLeft || doc.body.scrollLeft) - doc.documentElement.clientLeft + 1; | |
32 | //var y = e.clientY + (doc.documentElement.scrollTop || doc.body.scrollTop) - doc.documentElement.clientTop; |
|
32 | //var y = e.clientY + (doc.documentElement.scrollTop || doc.body.scrollTop) - doc.documentElement.clientTop; | |
33 |
|
33 | |||
34 | var x = e.clientX + (doc.documentElement.scrollLeft || doc.body.scrollLeft) + 2; |
|
34 | var x = e.clientX + (doc.documentElement.scrollLeft || doc.body.scrollLeft) + 2; | |
35 | var y = e.clientY + (doc.documentElement.scrollTop || doc.body.scrollTop); |
|
35 | var y = e.clientY + (doc.documentElement.scrollTop || doc.body.scrollTop); | |
36 |
|
36 | |||
37 | var cln = doc.createElement('div'); |
|
37 | var cln = doc.createElement('div'); | |
38 | cln.id = 'pstprev_' + pNum; |
|
38 | cln.id = 'pstprev_' + pNum; | |
39 | cln.className = 'post_preview post'; |
|
39 | cln.className = 'post_preview post'; | |
40 |
|
40 | |||
41 | cln.style.cssText = 'top:' + y + 'px;' + (x < doc.body.clientWidth/2 ? 'left:' + x + 'px' : 'right:' + parseInt(doc.body.clientWidth - x + 1) + 'px'); |
|
41 | cln.style.cssText = 'top:' + y + 'px;' + (x < doc.body.clientWidth/2 ? 'left:' + x + 'px' : 'right:' + parseInt(doc.body.clientWidth - x + 1) + 'px'); | |
42 |
|
42 | |||
43 | cln.addEventListener('mouseout', delPostPreview, false); |
|
43 | cln.addEventListener('mouseout', delPostPreview, false); | |
44 |
|
44 | |||
45 |
|
45 | |||
46 | var mkPreview = function(cln, html) { |
|
46 | var mkPreview = function(cln, html) { | |
47 |
|
47 | |||
48 | cln.innerHTML = html; |
|
48 | cln.innerHTML = html; | |
49 |
|
49 | |||
50 | addRefLinkPreview(cln); |
|
50 | addRefLinkPreview(cln); | |
51 |
|
51 | |||
52 | //if(!$x('.//small', cln)) showRefMap(post, p_num, refMap) |
|
52 | //if(!$x('.//small', cln)) showRefMap(post, p_num, refMap) | |
53 | }; |
|
53 | }; | |
54 |
|
54 | |||
55 |
|
55 | |||
56 | cln.innerHTML = 'ΠΠ°Π³ΡΡΠ·ΠΊΠ°...'; |
|
56 | cln.innerHTML = 'ΠΠ°Π³ΡΡΠ·ΠΊΠ°...'; | |
57 |
|
57 | |||
58 | var found = false; |
|
|||
59 |
|
||||
60 | //Π΅ΡΠ»ΠΈ ΠΏΠΎΡΡ Π½Π°ΠΉΠ΄Π΅Π½ Π² Π΄Π΅ΡΠ΅Π²Π΅. |
|
58 | //Π΅ΡΠ»ΠΈ ΠΏΠΎΡΡ Π½Π°ΠΉΠ΄Π΅Π½ Π² Π΄Π΅ΡΠ΅Π²Π΅. | |
61 | if($('div[id='+pNum+']').length > 0) { |
|
59 | if($('div[id='+pNum+']').length > 0) { | |
62 | var postdata = $('div[id='+pNum+']').html(); |
|
60 | var postdata = $('div[id='+pNum+']').html(); | |
63 |
|
61 | |||
64 | //TODO: Π²ΡΠ΅ΠΌΠ΅Π½Π½ΠΎ |
|
62 | //TODO: Π²ΡΠ΅ΠΌΠ΅Π½Π½ΠΎ | |
65 | //funcInit(postdata); |
|
63 | //funcInit(postdata); | |
66 |
|
64 | |||
67 | //make preview |
|
65 | //make preview | |
68 | mkPreview(cln, postdata); |
|
66 | mkPreview(cln, postdata); | |
69 |
|
||||
70 | found = true; |
|
|||
71 | } |
|
67 | } | |
72 | //ajax api |
|
68 | //ajax api | |
73 |
|
|
69 | else { | |
74 | // $.getJSON(mayuri_cfg['board_url']+'api/single/'+pNum) |
|
70 | $.ajax({ | |
75 | // .success(function(data) { |
|
71 | url: '/api/post/' + pNum | |
76 | // //post templates |
|
72 | }) | |
77 | // var postdata = makeAjaxPost(data).html(); |
|
73 | .success(function(data) { | |
78 | // |
|
74 | // TODO get a json, not post itself | |
79 | // //TODO: Π²ΡΠ΅ΠΌΠ΅Π½Π½ΠΎ |
|
75 | var postdata = $(data).html(); | |
80 | // //funcInit(postdata); |
|
76 | ||
81 | // |
|
77 | //make preview | |
82 | // //make preview |
|
78 | mkPreview(cln, postdata); | |
83 | // mkPreview(cln, postdata); |
|
79 | ||
84 | // |
|
80 | }) | |
85 | // })//if error |
|
81 | .error(function() { | |
86 | // .error(function() { |
|
82 | cln.innerHTML = 'ΠΠΎΡΡ Π½Π΅ Π½Π°ΠΉΠ΄Π΅Π½.'; | |
87 | // cln.innerHTML = 'ΠΠΎΡΡ Π½Π΅ Π½Π°ΠΉΠ΄Π΅Π½.'; |
|
83 | }); | |
88 | // }); |
|
84 | } | |
89 | // } |
|
|||
90 |
|
85 | |||
91 | $del(doc.getElementById(cln.id)); |
|
86 | $del(doc.getElementById(cln.id)); | |
92 |
|
87 | |||
93 | if (found) { |
|
|||
94 |
|
|
88 | //add preview | |
95 |
|
|
89 | $('body').append(cln); | |
96 | } |
|
90 | } | |
97 | } |
|
|||
98 |
|
91 | |||
99 | function delPostPreview(e) { |
|
92 | function delPostPreview(e) { | |
100 | var el = $x('ancestor-or-self::*[starts-with(@id,"pstprev")]', e.relatedTarget); |
|
93 | var el = $x('ancestor-or-self::*[starts-with(@id,"pstprev")]', e.relatedTarget); | |
101 | if(!el) $each($X('.//div[starts-with(@id,"pstprev")]'), function(clone) { |
|
94 | if(!el) $each($X('.//div[starts-with(@id,"pstprev")]'), function(clone) { | |
102 | $del(clone) |
|
95 | $del(clone) | |
103 | }); |
|
96 | }); | |
104 | else while(el.nextSibling) $del(el.nextSibling); |
|
97 | else while(el.nextSibling) $del(el.nextSibling); | |
105 | } |
|
98 | } | |
106 |
|
99 | |||
107 | function addPreview() { |
|
100 | function addPreview() { | |
108 | $('.post').find('a').each(function() { |
|
101 | $('.post').find('a').each(function() { | |
109 | showPostPreview($(this)); |
|
102 | showPostPreview($(this)); | |
110 | }); |
|
103 | }); | |
111 | } |
|
104 | } |
@@ -1,56 +1,56 b'' | |||||
1 | from django.conf.urls import patterns, url, include |
|
1 | from django.conf.urls import patterns, url, include | |
2 | from boards import views |
|
2 | from boards import views | |
3 | from boards.rss import AllThreadsFeed, TagThreadsFeed, ThreadPostsFeed |
|
3 | from boards.rss import AllThreadsFeed, TagThreadsFeed, ThreadPostsFeed | |
4 |
|
4 | |||
5 | js_info_dict = { |
|
5 | js_info_dict = { | |
6 | 'packages': ('boards',), |
|
6 | 'packages': ('boards',), | |
7 | } |
|
7 | } | |
8 |
|
8 | |||
9 | urlpatterns = patterns('', |
|
9 | urlpatterns = patterns('', | |
10 |
|
10 | |||
11 | # /boards/ |
|
11 | # /boards/ | |
12 | url(r'^$', views.index, name='index'), |
|
12 | url(r'^$', views.index, name='index'), | |
13 | # /boards/page/ |
|
13 | # /boards/page/ | |
14 | url(r'^page/(?P<page>\w+)/$', views.index, name='index'), |
|
14 | url(r'^page/(?P<page>\w+)/$', views.index, name='index'), | |
15 |
|
15 | |||
16 | # login page |
|
16 | # login page | |
17 | url(r'^login/$', views.login, name='login'), |
|
17 | url(r'^login/$', views.login, name='login'), | |
18 |
|
18 | |||
19 | # /boards/tag/tag_name/ |
|
19 | # /boards/tag/tag_name/ | |
20 | url(r'^tag/(?P<tag_name>\w+)/$', views.tag, name='tag'), |
|
20 | url(r'^tag/(?P<tag_name>\w+)/$', views.tag, name='tag'), | |
21 | # /boards/tag/tag_id/page/ |
|
21 | # /boards/tag/tag_id/page/ | |
22 | url(r'^tag/(?P<tag_name>\w+)/page/(?P<page>\w+)/$', views.tag, name='tag'), |
|
22 | url(r'^tag/(?P<tag_name>\w+)/page/(?P<page>\w+)/$', views.tag, name='tag'), | |
23 |
|
23 | |||
24 | # /boards/tag/tag_name/unsubscribe/ |
|
24 | # /boards/tag/tag_name/unsubscribe/ | |
25 | url(r'^tag/(?P<tag_name>\w+)/subscribe/$', views.tag_subscribe, |
|
25 | url(r'^tag/(?P<tag_name>\w+)/subscribe/$', views.tag_subscribe, | |
26 | name='tag_subscribe'), |
|
26 | name='tag_subscribe'), | |
27 | # /boards/tag/tag_name/unsubscribe/ |
|
27 | # /boards/tag/tag_name/unsubscribe/ | |
28 | url(r'^tag/(?P<tag_name>\w+)/unsubscribe/$', views.tag_unsubscribe, |
|
28 | url(r'^tag/(?P<tag_name>\w+)/unsubscribe/$', views.tag_unsubscribe, | |
29 | name='tag_unsubscribe'), |
|
29 | name='tag_unsubscribe'), | |
30 |
|
30 | |||
31 | # /boards/thread/ |
|
31 | # /boards/thread/ | |
32 | url(r'^thread/(?P<post_id>\w+)/$', views.thread, name='thread'), |
|
32 | url(r'^thread/(?P<post_id>\w+)/$', views.thread, name='thread'), | |
33 | url(r'^settings/$', views.settings, name='settings'), |
|
33 | url(r'^settings/$', views.settings, name='settings'), | |
34 | url(r'^tags/$', views.all_tags, name='tags'), |
|
34 | url(r'^tags/$', views.all_tags, name='tags'), | |
35 | url(r'^captcha/', include('captcha.urls')), |
|
35 | url(r'^captcha/', include('captcha.urls')), | |
36 | url(r'^jump/(?P<post_id>\w+)/$', views.jump_to_post, name='jumper'), |
|
36 | url(r'^jump/(?P<post_id>\w+)/$', views.jump_to_post, name='jumper'), | |
37 | url(r'^authors/$', views.authors, name='authors'), |
|
37 | url(r'^authors/$', views.authors, name='authors'), | |
38 | url(r'^delete/(?P<post_id>\w+)/$', views.delete, name='delete'), |
|
38 | url(r'^delete/(?P<post_id>\w+)/$', views.delete, name='delete'), | |
39 | url(r'^ban/(?P<post_id>\w+)/$', views.ban, name='ban'), |
|
39 | url(r'^ban/(?P<post_id>\w+)/$', views.ban, name='ban'), | |
40 |
|
40 | |||
41 | url(r'^banned/$', views.you_are_banned, name='banned'), |
|
41 | url(r'^banned/$', views.you_are_banned, name='banned'), | |
42 | url(r'^staticpage/(?P<name>\w+)/$', views.static_page, name='staticpage'), |
|
42 | url(r'^staticpage/(?P<name>\w+)/$', views.static_page, name='staticpage'), | |
43 |
|
43 | |||
44 | # RSS feeds |
|
44 | # RSS feeds | |
45 | url(r'^rss/$', AllThreadsFeed()), |
|
45 | url(r'^rss/$', AllThreadsFeed()), | |
46 | url(r'^page/(?P<page>\w+)/rss/$', AllThreadsFeed()), |
|
46 | url(r'^page/(?P<page>\w+)/rss/$', AllThreadsFeed()), | |
47 | url(r'^tag/(?P<tag_name>\w+)/rss/$', TagThreadsFeed()), |
|
47 | url(r'^tag/(?P<tag_name>\w+)/rss/$', TagThreadsFeed()), | |
48 | url(r'^tag/(?P<tag_name>\w+)/page/(?P<page>\w+)/rss/$', TagThreadsFeed()), |
|
48 | url(r'^tag/(?P<tag_name>\w+)/page/(?P<page>\w+)/rss/$', TagThreadsFeed()), | |
49 | url(r'^thread/(?P<post_id>\w+)/rss/$', ThreadPostsFeed()), |
|
49 | url(r'^thread/(?P<post_id>\w+)/rss/$', ThreadPostsFeed()), | |
50 |
|
50 | |||
51 | # i18n |
|
51 | # i18n | |
52 | url(r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict), |
|
52 | url(r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict), | |
53 |
|
53 | |||
54 | # API |
|
54 | # API | |
55 |
url(r'^ |
|
55 | url(r'^api/post/(?P<post_id>\w+)/$', views.get_post, name="get_post"), | |
56 | ) |
|
56 | ) |
General Comments 0
You need to be logged in to leave comments.
Login now