Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdc713e9

Browse files
committed
rsdn: lots of small improvements
1 parent127c202 commitdc713e9

File tree

3 files changed

+51
-33
lines changed

3 files changed

+51
-33
lines changed

‎NemerleWeb.RSDN/Content/site.css‎

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -315,10 +315,12 @@ a img {
315315
}
316316

317317
.comment-node, .comment-meta {
318-
margin:002px10px;
319-
padding:10px20px;
318+
margin:0-20px2px0;
319+
padding:10px10px;
320320
background-color:#efefef;
321-
border:1px solid#c0c0c0;
321+
border-left:1px solid#c0c0c0;
322+
border-top:1px solid#c0c0c0;
323+
border-bottom:1px solid#c0c0c0;
322324
}
323325

324326
.comment-node.even, .comment-meta.even {
@@ -327,7 +329,7 @@ a img {
327329

328330
.comment-meta {
329331
font-size:12px;
330-
margin:10px02px10px;
332+
margin:10px-20px2px0;
331333
}
332334

333335
.comment-author {
@@ -343,4 +345,19 @@ a img {
343345

344346
.comment-rating {
345347
padding-left:40px
348+
}
349+
350+
.loading {
351+
position: absolute;
352+
top:0;
353+
left:0;
354+
width:100%;
355+
height:100%;
356+
background-color:#aaa;
357+
text-align: center;
358+
font-size:32px;
359+
font-weight: bold;
360+
color:#333;
361+
opacity:0.5;
362+
padding-top:80px;
346363
}

‎NemerleWeb.Rsdn.Tree/MVVM/TopicList.n‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ namespace Rsdn
3535
privatemutable _url :string;
3636
privatemutable _topics : List[Topic];
3737
privatemutable _selectedTopic : CommentNode;
38+
privatemutable _maxDepth :int;
39+
privatemutable _isLoading :bool;
3840

3941
publicmutable Name :string;
4042
public Url :string
@@ -46,11 +48,13 @@ namespace Rsdn
4648
_ = server.GetTopicList(value, topics => _topics = topics.ToList());
4749
}
4850
}
49-
51+
5052
OpenTopic(topic : Topic) :void
5153
{
52-
_ = server.LoadReplies(topic.Id, node => {
54+
_isLoading = true;
55+
_ = server.LoadReplies(topic.Id, (node) => {
5356
_selectedTopic = node;
57+
_isLoading = false;
5458
});
5559
}
5660

@@ -91,6 +95,7 @@ namespace Rsdn
9195
<div $when(_selectedTopic != null)>
9296
<div template="$_selectedTopic"/>
9397
</div>
98+
<divclass="loading" visible="$_isLoading">Loading...</div>
9499
#>
95100
}
96101

‎NemerleWeb.Rsdn.Tree/Models/TopicLoader.n‎

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -63,30 +63,28 @@ namespace Rsdn.Tree.Models
6363
public LoadReplies(id :int) : CommentNode
6464
{
6565
def replies = WebClient().DownloadString($"http://www.rsdn.ru/rs/topic/$(id)/replies");
66-
def replyObjects = JsonConvert.DeserializeAnonymousType(replies,array[new (
66+
def meta = JsonConvert.DeserializeAnonymousType(replies,array[new (id =0)]);
67+
68+
def client = WebClient();
69+
client.Encoding = System.Text.Encoding.UTF8;
70+
def json = client.DownloadString($"http://www.rsdn.ru/rs/topic/$(id)/messages?formatted=true&len=$(meta.Length + 1)");
71+
def replies = JsonConvert.DeserializeAnonymousType(json,array[new (
72+
text ="",
6773
id =0,
6874
parentId =0,
75+
authorNick ="",
76+
rate =0,
77+
rateCount =0,
78+
agrees =0,
79+
disagrees =0,
80+
smiles =0,
6981
subject ="",
70-
authorNick =""
71-
)]);
72-
73-
def loadReply(replyId) {
74-
def client = WebClient();
75-
client.Encoding = System.Text.Encoding.UTF8;
76-
def json = client.DownloadString($"http://www.rsdn.ru/rs/message/$(replyId)?formatted=true");
77-
JsonConvert.DeserializeAnonymousType(json,new (
78-
text ="",
79-
id =0,
80-
authorNick ="",
81-
rate =0,
82-
rateCount =0,
83-
agrees =0,
84-
disagrees =0,
85-
smiles =0,
86-
subject ="",
87-
createdOn =""
88-
));
89-
}
82+
createdOn =""
83+
)]);
84+
85+
def mapById = replies.ToDictionary(r => r.id);
86+
def mapByParentId = replies.GroupBy(r => r.parentId)
87+
.ToDictionary(g => g.Key, g => g);
9088

9189
def mapJsonToCommentNode(a, children, depth) {
9290
CommentNode(a.text.Replace(" src=\'/"," src=\'http://www.rsdn.ru/"),
@@ -102,17 +100,15 @@ namespace Rsdn.Tree.Models
102100
depth)
103101
}
104102

105-
def map = replyObjects.GroupBy(r => r.parentId)
106-
.ToDictionary(g => g.Key, g => g);
107-
108103
def getChildNodes(parentNodeId, depth) {
109104
mutable childNodes;
110-
if(map.TryGetValue(parentNodeId,out childNodes)) {
111-
childNodes.Map(c => mapJsonToCommentNode(loadReply(c.id), getChildNodes(c.id, depth+1), depth))
105+
106+
if(mapByParentId.TryGetValue(parentNodeId,out childNodes)) {
107+
childNodes.Map(c => mapJsonToCommentNode(c, getChildNodes(c.id, depth+1), depth))
112108
}else []
113109
}
114110

115-
def mainComment = mapJsonToCommentNode(loadReply(id), getChildNodes(id,1),0);
111+
def mainComment = mapJsonToCommentNode(mapById[id], getChildNodes(id,1),0);
116112
mainComment
117113
}
118114

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp