diff options
Diffstat (limited to 'templates/content')
-rw-r--r-- | templates/content/images/favicon.ico | bin | 3638 -> 0 bytes | |||
-rw-r--r-- | templates/content/js/com.cnprog.i18n.js | 90 | ||||
-rw-r--r-- | templates/content/js/com.cnprog.post.js | 109 | ||||
-rw-r--r-- | templates/content/js/com.cnprog.post.pack.js | 1 | ||||
-rw-r--r-- | templates/content/js/com.cnprog.utils.js | 22 | ||||
-rw-r--r-- | templates/content/js/jquery.i18n.js | 133 | ||||
-rw-r--r-- | templates/content/js/wmd/wmd.js | 34 |
7 files changed, 329 insertions, 60 deletions
diff --git a/templates/content/images/favicon.ico b/templates/content/images/favicon.ico Binary files differdeleted file mode 100644 index b5c6f578..00000000 --- a/templates/content/images/favicon.ico +++ /dev/null diff --git a/templates/content/js/com.cnprog.i18n.js b/templates/content/js/com.cnprog.i18n.js new file mode 100644 index 00000000..2d8c90a6 --- /dev/null +++ b/templates/content/js/com.cnprog.i18n.js @@ -0,0 +1,90 @@ +// Evgeny Fadeev evgeny.fadeev@gmail.com localized for english and chinese +// i18nLang variable must be set in html header to extract correct language +var i18nZh = { + 'insufficient privilege':'用户权限不在操作范围', + 'cannot pick own answer as best':'不能设置自己的回答为最佳答案', + 'anonymous users cannot select favorite questions':'匿名用户不能收藏问题,请先', + 'please login':'注册或者登录', + 'anonymous users cannot vote':'匿名用户不能投票', + '>15 points requried to upvote':'需要+15积分才能投支持票。', + '>100 points required to downvote':'需要+100积分才能投反对票。', + 'please see': '查看', + 'cannot vote for own posts':'不能给自己的帖子投票', + 'daily vote cap exhausted':'对不起,您已用完今日所有的投票。', + 'cannot revoke old vote':'这个投票已经过时,不能撤销。', + 'please confirm offensive':"确定要归类该帖为广告、人身攻击、恶意言论吗?", + 'anonymous users cannot flag offensive posts':'匿名用户不能操作,请先', + 'cannot flag message as offensive twice':'不能重复操作。', + 'flag offensive cap exhausted':'对不起,您已用完今日所有的5次‘水帖’操作。', + 'need >15 points to report spam':"需要+15积分才能归类‘垃圾帖’。", + 'confirm delete':"确定要删除/撤销删除该帖吗?", + 'anonymous users cannot delete/undelete':"匿名用户不能删除或撤销删除帖子", + 'post recovered':"操作成功!该帖子已被恢复。", + 'post deleted':"操作成功!该帖子已删除。", + 'add comment':'添加评论', + 'community reputation points':'社区积分', + 'to comment, need':'评论需要', + 'delete this comment':'删除此评论', + 'hide comments':"隐藏评论", + 'add a comment':"添加评论", + 'comments':"评论", + 'confirm delete comment':"真要删除此评论吗?", + 'characters':'字符', + 'can write':'还可写', + 'click to close':'点击消息框关闭', + 'loading...':'读取中...', + 'tags cannot be empty':'标签不能为空。', + 'tablimits info':"最多5个标签,每个标签长度小于20个字符。", + 'content cannot be empty':'内容不能为空。', + 'content minchars': '请输入至少 {0} 字符。', + 'please enter title':'请输入标题。', + 'title minchars':"请输入至少 {0} 字符。", + 'delete':'删除', + 'undelete': '取消', + 'bold':'粗体', + 'italic':'斜体', + 'link':'超链接', + 'quote':'引用', + 'preformatted text':'代码', + 'image':'图片', + 'numbered list':'数字编号列表', + 'bulleted list':'项目符号列表', + 'heading':'标题', + 'horizontal bar':'水平线', + 'undo':'撤销', + 'redo':'重做', + 'enter image url':'<b>输入图片地址</b></p><p>示例:<br />http://www.example.com/image.jpg \"我的截图\"', + 'enter url':'<b>输入Web地址</b></p><p>示例:<br />http://www.cnprog.com/ \"我的网站\"</p>"', + 'upload image':'或者上传本地图片:', +}; + +var i18nEn = { + 'to comment, need': 'to comment, need reputation ', + 'please see':'please see ', + 'community reputation points':' ', + 'upload image':'Upload image:', + 'enter image url':'enter URL of the image, e.g. http://www.example.com/image.jpg \"image title\"', + 'enter url':'enter Web address, e.g. http://www.example.com \"page title\"', + 'daily vote cap exhausted':'sorry, you\'ve used up todays vote cap', + 'cannot pick own answer as best':'cannot accept own answer', + 'cannot revoke old vote':'older votes cannot be revoked', + 'please confirm offensive':'are you sure this post is offensive, contains spam, advertising, malicious remarks, etc.?', + 'flag offensive cap exhausted':'sorry, you\'ve used up todays cap of flagging offensive messages', + 'confirm delete':'are you sure you want to delete this?', + 'anonymous users cannot delete/undelete':'anonymous users cannot delete or undelete posts', + 'post recovered':'your post is now restored!', + 'post deleted':'your post has been deleted', + 'confirm delete comment':'do you really want to delete this comment?', + 'can write':'have ', + 'tablimits info':'up to 5 tags, no more than 20 characters each', + 'content minchars': 'please enter more than {0} characters', + 'title minchars':"please enter at least {0} characters", + 'characters':'characters left', +}; + +var i18n = { + 'en':i18nEn, + 'zh':i18nZh +}; + +var i18n_dict = i18n[i18nLang]; diff --git a/templates/content/js/com.cnprog.post.js b/templates/content/js/com.cnprog.post.js index dbf5d128..e3101ea7 100644 --- a/templates/content/js/com.cnprog.post.js +++ b/templates/content/js/com.cnprog.post.js @@ -49,24 +49,37 @@ var Vote = function(){ var removeQuestionLinkIdPrefix = 'question-delete-link-';
var removeAnswerLinkIdPrefix = 'answer-delete-link-';
- var acceptAnonymousMessage = "用户权限不在操作范围";
- var acceptOwnAnswerMessage = "不能设置自己的回答为最佳答案";
- var favoriteAnonymousMessage = "匿名用户不能收藏问题,请先<a href='/account/signin/?next=/questions/{{QuestionID}}'>注册或者登录</a>";
- var voteAnonymousMessage = "匿名用户不能投票,请先<a href='/account/signin/?next=/questions/{{QuestionID}}'>注册或者登录</a>";
- var upVoteRequiredScoreMessage = "需要+15积分才能投支持票。查看<a href='/faq'>faq</a>";
- var downVoteRequiredScoreMessage = "需要+100积分才能投反对票。查看<a href='/faq'>faq</a>";
- var voteOwnDeniedMessage = "不能给自己的帖子投票";
- var voteRequiredMoreVotes = "对不起,您已用完今日所有的投票。查看<a href='/faq'>faq</a>";
- var voteDenyCancelMessage = "这个投票已经过时,不能撤销。查看<a href='/faq'>faq</a>";
- var offensiveConfirmation = "确定要归类该帖为广告、人身攻击、恶意言论吗?";
- var offensiveAnonymousMessage = "匿名用户不能操作,请先<a href='/account/signin/?next=/questions/{{QuestionID}}'>注册或者登录</a>";
- var offensiveTwiceMessage = "不能重复操作。查看<a href='/faq'>faq</a>";
- var offensiveNoFlagsLeftMessage = "对不起,您已用完今日所有的5次‘水帖’操作。查看<a href='/faq'>faq</a>";
- var offensiveNoPermissionMessage = "需要+15积分才能归类‘垃圾帖’。查看<a href='/faq'>faq</a>";
- var removeConfirmation = "确定要删除/撤销删除该帖吗?";
- var removeAnonymousMessage = "匿名用户不能删除或撤销删除帖子";
- var recoveredMessage = "操作成功!该帖子已被恢复。";
- var deletedMessage = "操作成功!该帖子已删除。"
+ var acceptAnonymousMessage = $.i18n._('insufficient privilege');
+ var acceptOwnAnswerMessage = $.i18n._('cannot pick own answer as best');
+ var favoriteAnonymousMessage = $.i18n._('anonymous user cannot select favorite questions')
+ + "<a href='/account/signin/?next=/questions/{{QuestionID}}'>"
+ + $.i18n._('please login') + "</a>";
+ var voteAnonymousMessage = $.i18n._('anonymous users cannot vote')
+ + "<a href='/account/signin/?next=/questions/{{QuestionID}}'>"
+ + $.i18n._('please login') + "</a>";
+ var upVoteRequiredScoreMessage = $.i18n._('>15 points requried to upvote')
+ + $.i18n._('please see') + "<a href='/faq'>faq</a>";
+ var downVoteRequiredScoreMessage = $.i18n._('>100 points requried to downvote')
+ + $.i18n._('please see') + "<a href='/faq'>faq</a>";
+ var voteOwnDeniedMessage = $.i18n._('cannot vote for own posts');
+ var voteRequiredMoreVotes = $.i18n._('daily vote cap exhausted')
+ + $.i18n._('please see') + "<a href='/faq'>faq</a>";
+ var voteDenyCancelMessage = $.i18n._('cannot revoke old vote')
+ + $.i18n._('please see') + "<a href='/faq'>faq</a>";
+ var offensiveConfirmation = $.i18n._('please confirm offensive');
+ var offensiveAnonymousMessage = $.i18n._('anonymous users cannot flag offensive posts')
+ + "<a href='/account/signin/?next=/questions/{{QuestionID}}'>"
+ + $.i18n._('please login') + "</a>";
+ var offensiveTwiceMessage = $.i18n._('cannot flag message as offensive twice')
+ + $.i18n._('please see') + "<a href='/faq'>faq</a>";
+ var offensiveNoFlagsLeftMessage = $.i18n._('flag offensive cap exhausted')
+ + $.i18n._('please see') + "<a href='/faq'>faq</a>";
+ var offensiveNoPermissionMessage = $.i18n._('need >15 points to report spam')
+ + $.i18n._('please see') + "<a href='/faq'>faq</a>";
+ var removeConfirmation = $.i18n._('confirm delete');
+ var removeAnonymousMessage = $.i18n._('anonymous users cannot delete/undelete');
+ var recoveredMessage = $.i18n._('post recovered');
+ var deletedMessage = $.i18n._('post deleted');
var VoteType = {
acceptAnswer : 0,
@@ -201,7 +214,7 @@ var Vote = function(){ });
getremoveQuestionLink().unbind('click').click(function(event){
- Vote.remove(this, VoteType.removeQuestion)
+ Vote.remove(this, VoteType.removeQuestion);
});
getremoveAnswersLinks().unbind('click').click(function(event){
@@ -330,15 +343,22 @@ var Vote = function(){ };
var callback_remove = function(object, voteType, data){
+ alert(data.status);
if(data.allowed == "0" && data.success == "0"){
showMessage(object, removeAnonymousMessage.replace("{{QuestionID}}", questionId));
}
- else if(data.status == "1"){
- showMessage(object, recoveredMessage);
- }
- else if(data.success == "1"){
- showMessage(object, deletedMessage);
- }
+ else if (data.success == "1"){
+ if (removeActionType == 'delete'){
+ postNode.addClass('deleted');
+ postRemoveLink.innerHTML = $.i18n._('undelete');
+ showMessage(object, deletedMessage);
+ }
+ else if (removeActionType == 'undelete') {
+ postNode.removeClass('deleted');
+ postRemoveLink.innerHTML = $.i18n._('delete');
+ showMessage(object, recoveredMessage);
+ }
+ }
};
return {
@@ -395,8 +415,23 @@ var Vote = function(){ return false;
}
if(confirm(removeConfirmation)){
- postId = object.id.substr(object.id.lastIndexOf('-') + 1);
+ bits = object.id.split('-');
+ postId = bits.pop();/* this seems to be used within submit! */
+ postType = bits.shift();
+
+ if (postType == 'answer'){
+ postNode = $('#answer-container-' + postId);
+ postRemoveLink = object;
+ if (postNode.hasClass('deleted')){
+ removeActionType = 'undelete';
+ }
+ else {
+ removeActionType = 'delete';
+ }
+ }
submit($(object), voteType, callback_remove);
+
+
}
}
}
@@ -426,7 +461,8 @@ function createComments(type) { var form = '<form id="' + formId + '" class="post-comments"><div>';
form += '<textarea name="comment" cols="60" rows="5" maxlength="300" onblur="'+ objectType +'Comments.updateTextCounter(this)" ';
form += 'onfocus="' + objectType + 'Comments.updateTextCounter(this)" onkeyup="'+ objectType +'Comments.updateTextCounter(this)"></textarea>';
- form += '<input type="submit" value="添加评论" /><br><span class="text-counter"></span>';
+ form += '<input type="submit" value="'
+ + $.i18n._('add comment') + '" /><br><span class="text-counter"></span>';
form += '<span class="form-error"></span></div></form>';
jDiv.append(form);
@@ -439,7 +475,10 @@ function createComments(type) { else {
var divId = "comments-rep-needed-" + objectType + '-' + id;
if (jDiv.find("#" + divId).length == 0) {
- jDiv.append('<div id="' + divId + '" style="color:red">评论需要 ' + repNeededForComments + ' 社区积分 - <a href="/faq" class="comment-user">查看faq</a></span>');
+ jDiv.append('<div id="' + divId + '" style="color:red">'
+ + $.i18n._('to comment, need') + ' ' +
+ + repNeededForComments + ' ' + $.i18n._('community reputation points')
+ + '<a href="/faq" class="comment-user">' + $.i18n._('please see') + 'faq</a></span>');
}
}
};
@@ -477,7 +516,7 @@ function createComments(type) { var imgHover = "/content/images/close-small-hover.png";
html += '<img onclick="' + objectType + 'Comments.deleteComment($(this), ' + json.object_id + ', \'' + json.delete_url + '\')" src="' + img;
html += '" onmouseover="$(this).attr(\'src\', \'' + imgHover + '\')" onmouseout="$(this).attr(\'src\', \'' + img
- html += '\')" title="删除此评论" />';
+ html += '\')" title="' + $.i18n._('delete this comment') + '" />';
}
html += '</div>';
@@ -524,13 +563,15 @@ function createComments(type) { renderForm(id, jDiv);
jDiv.show();
if (canPostComments(id, jDiv)) jDiv.find("textarea").get(0).focus();
- jDiv.siblings("a").unbind("click").click(function() { commentsFactory[objectType].hide(id); }).text("隐藏评论");
+ jDiv.siblings("a").unbind("click").click(function(){
+ commentsFactory[objectType].hide(id);
+ }).text($.i18n._('hide comments'));
},
hide: function(id) {
var jDiv = jDivInit(id);
var len = jDiv.children("div.comments").children().length;
- var anchorText = len == 0 ? "添加评论" : "评论 (<b>" + len + "</b>)";
+ var anchorText = len == 0 ? $.i18n._('add a comment') : $.i18n._('comments') + ' (<b>' + len + "</b>)";
jDiv.hide();
jDiv.siblings("a").unbind("click").click(function() { commentsFactory[objectType].show(id); }).html(anchorText);
@@ -538,7 +579,7 @@ function createComments(type) { },
deleteComment: function(jImg, id, deleteUrl) {
- if (confirm("真要删除此评论吗?")) {
+ if (confirm($.i18n._('confirm delete comment'))) {
jImg.hide();
appendLoaderImg(id);
$.post(deleteUrl, { dataNeeded: "forIIS7" }, function(json) {
@@ -551,7 +592,9 @@ function createComments(type) { var length = textarea.value ? textarea.value.length : 0;
var color = length > 270 ? "#f00" : length > 200 ? "#f60" : "#999";
var jSpan = $(textarea).siblings("span.text-counter");
- jSpan.html('还可写' + (300 - length) + ' 字符').css("color", color);
+ jSpan.html($.i18n._('can write')
+ + (300 - length) + ' '
+ + $.i18n._('characters')).css("color", color);
}
};
}
diff --git a/templates/content/js/com.cnprog.post.pack.js b/templates/content/js/com.cnprog.post.pack.js deleted file mode 100644 index 8af19d13..00000000 --- a/templates/content/js/com.cnprog.post.pack.js +++ /dev/null @@ -1 +0,0 @@ -var lanai={highlightSyntax:function(){var a=false;$("pre code").parent().each(function(){if(!$(this).hasClass("prettyprint")){$(this).addClass("prettyprint");a=true}});if(a){prettyPrint()}}};var Vote=function(){var M;var v;var ah;var O;var X="answer-container-";var V="vote-buttons";var s="answer-img-accept-";var T="question-img-favorite";var N="question-img-upvote-";var r="question-img-downvote-";var L="answer-img-upvote-";var ae="answer-img-downvote-";var ad="favorite-number";var j="comment-";var H="vote-number";var a="question-offensive-flag-";var t="answer-offensive-flag-";var x="offensive-flag";var aa="question-controls";var J="question-delete-link-";var b="answer-delete-link-";var o="用户权限不在操作范围";var w="不能设置自己的回答为最佳答案";var g="匿名用户不能收藏问题,请先<a href='/account/signin/?next=/questions/{{QuestionID}}'>注册或者登录</a>";var aj="匿名用户不能投票,请先<a href='/account/signin/?next=/questions/{{QuestionID}}'>注册或者登录</a>";var K="需要+15积分才能投支持票。查看<a href='/faq'>faq</a>";var Y="需要+100积分才能投反对票。查看<a href='/faq'>faq</a>";var q="不能给自己的帖子投票";var n="对不起,您已用完今日所有的投票。查看<a href='/faq'>faq</a>";var A="这个投票已经过时,不能撤销。查看<a href='/faq'>faq</a>";var u="确定要归类该帖为广告、人身攻击、恶意言论吗?";var ab="匿名用户不能操作,请先<a href='/account/signin/?next=/questions/{{QuestionID}}'>注册或者登录</a>";var C="不能重复操作。查看<a href='/faq'>faq</a>";var B="对不起,您已用完今日所有的5次‘水帖’操作。查看<a href='/faq'>faq</a>";var af="需要+15积分才能归类‘垃圾帖’。查看<a href='/faq'>faq</a>";var p="确定要删除/撤销删除该帖吗?";var W="匿名用户不能删除或撤销删除帖子";var Q="操作成功!该帖子已被恢复。";var i="操作成功!该帖子已删除。";var h={acceptAnswer:0,questionUpVote:1,questionDownVote:2,favorite:4,answerUpVote:5,answerDownVote:6,offensiveQuestion:7,offensiveAnswer:8,removeQuestion:9,removeAnswer:10};var Z=function(){var ak="div."+V+" img[class="+T+"]";return $(ak)};var I=function(){var ak="#"+ad;return $(ak)};var e=function(){var ak="div."+V+" img[id^="+N+"]";return $(ak)};var E=function(){var ak="div."+V+" img[id^="+r+"]";return $(ak)};var l=function(){var ak="div."+V+" img[id^="+L+"]";return $(ak)};var k=function(){var ak="div."+V+" img[id^="+ae+"]";return $(ak)};var m=function(al){var ak="div."+V+" img[id="+L+al+"]";return $(ak)};var y=function(al){var ak="div."+V+" img[id="+ae+al+"]";return $(ak)};var z=function(){var ak="table[id=question-table] span[class="+x+"]";return $(ak)};var c=function(){var ak="div.answer span[class="+x+"]";return $(ak)};var R=function(){var ak="div#question-controls a[id^="+J+"]";return $(ak)};var f=function(){var ak="div.answer-controls a[id^="+b+"]";return $(ak)};var U=function(an,al,am){var ak=al?"":"-on";var ao=(an==h.questionUpVote||an==h.answerUpVote)?"up":"down";am.attr("src","/content/images/vote-arrow-"+ao+ak+".png");if(al){if(an==h.questionUpVote||an==h.questionDownVote){$(e()).attr("src","/content/images/vote-arrow-up.png");$(E()).attr("src","/content/images/vote-arrow-down.png")}else{$(m(v)).attr("src","/content/images/vote-arrow-up.png");$(y(v)).attr("src","/content/images/vote-arrow-down.png")}}};var P=function(al,am){var ak=al.parent("div."+V).find("div."+H);$(ak).text(am)};var ac=function(){if(ah==O){var am="div."+V+" img[id^="+s+"]";$(am).unbind("click").click(function(aq){Vote.accept($(aq.target))})}var ao=Z();ao.unbind("click").click(function(aq){Vote.favorite($(aq.target))});var an=e();an.unbind("click").click(function(aq){Vote.vote($(aq.target),h.questionUpVote)});var ak=E();ak.unbind("click").click(function(aq){Vote.vote($(aq.target),h.questionDownVote)});var al=l();al.unbind("click").click(function(aq){Vote.vote($(aq.target),h.answerUpVote)});var ap=k();ap.unbind("click").click(function(aq){Vote.vote($(aq.target),h.answerDownVote)});z().unbind("click").click(function(aq){Vote.offensive(this,h.offensiveQuestion)});c().unbind("click").click(function(aq){Vote.offensive(this,h.offensiveAnswer)});R().unbind("click").click(function(aq){Vote.remove(this,h.removeQuestion)});f().unbind("click").click(function(aq){Vote.remove(this,h.removeAnswer)})};var G=function(ak,al,am){$.ajax({type:"POST",cache:false,dataType:"json",url:"/questions/"+M+"/vote/",data:{type:al,postId:v},error:ai,success:function(an){am(ak,al,an)}})};var ai=function(al,ak){alert("Callback invoke error: "+ak)};var d=function(al,am,ao){if(ao.allowed=="0"&&ao.success=="0"){showMessage(al,o)}else{if(ao.allowed=="-1"){showMessage(al,w)}else{if(ao.status=="1"){al.attr("src","/content/images/vote-accepted.png");$("#"+X+v).removeClass("accepted-answer");$("#"+j+v).removeClass("comment-link-accepted")}else{if(ao.success=="1"){var an="div."+V+" img[id^="+s+"]";$(an).attr("src","/content/images/vote-accepted.png");var ap=("div[id^="+X+"]");$(ap).removeClass("accepted-answer");var ak=("div[id^="+X+"] div[id^="+j+"]");$(ak).removeClass("comment-link-accepted");al.attr("src","/content/images/vote-accepted-on.png");$("#"+X+v).addClass("accepted-answer");$("#"+j+v).addClass("comment-link-accepted")}else{showMessage(al,ao.message)}}}}};var F=function(ak,al,am){if(am.allowed=="0"&&am.success=="0"){showMessage(ak,g.replace("{{QuestionID}}",M))}else{if(am.status=="1"){ak.attr("src","/content/images/vote-favorite-off.png");var an=I();an.removeClass("my-favorite-number");if(am.count==0){am.count=""}an.text(am.count)}else{if(am.success=="1"){ak.attr("src","/content/images/vote-favorite-on.png");var an=I();an.text(am.count);an.addClass("my-favorite-number")}else{showMessage(ak,am.message)}}}};var S=function(ak,al,am){if(am.allowed=="0"&&am.success=="0"){showMessage(ak,aj.replace("{{QuestionID}}",M))}else{if(am.allowed=="-3"){showMessage(ak,n)}else{if(am.allowed=="-2"){if(al==h.questionUpVote||al==h.answerUpVote){showMessage(ak,K)}else{if(al==h.questionDownVote||al==h.answerDownVote){showMessage(ak,Y)}}}else{if(am.allowed=="-1"){showMessage(ak,q)}else{if(am.status=="2"){showMessage(ak,A)}else{if(am.status=="1"){U(al,true,ak);P(ak,am.count)}else{if(am.success=="1"){U(al,false,ak);P(ak,am.count);if(am.message.length>0){showMessage(ak,am.message)}}}}}}}}};var ag=function(ak,al,am){ak=$(ak);if(am.allowed=="0"&&am.success=="0"){showMessage(ak,ab.replace("{{QuestionID}}",M))}else{if(am.allowed=="-3"){showMessage(ak,B)}else{if(am.allowed=="-2"){showMessage(ak,af)}else{if(am.status=="1"){showMessage(ak,C)}else{if(am.success=="1"){$(ak).children("span[class=darkred]").text("("+am.count+")")}}}}}};var D=function(ak,al,am){if(am.allowed=="0"&&am.success=="0"){showMessage(ak,W.replace("{{QuestionID}}",M))}else{if(am.status=="1"){showMessage(ak,Q)}else{if(am.success=="1"){showMessage(ak,i)}}}};return{init:function(ak,al,am){M=ak;ah=al;O=am;ac()},accept:function(ak){v=ak.attr("id").substring(s.length);G(ak,h.acceptAnswer,d)},favorite:function(ak){if(!O||O.toUpperCase()=="NONE"){showMessage(ak,g.replace("{{QuestionID}}",M));return false}G(ak,h.favorite,F)},vote:function(ak,al){if(!O||O.toUpperCase()=="NONE"){showMessage(ak,aj.replace("{{QuestionID}}",M));return false}if(al==h.answerUpVote){v=ak.attr("id").substring(L.length)}else{if(al==h.answerDownVote){v=ak.attr("id").substring(ae.length)}}G(ak,al,S)},offensive:function(ak,al){if(!O||O.toUpperCase()=="NONE"){showMessage($(ak),ab.replace("{{QuestionID}}",M));return false}if(confirm(u)){v=ak.id.substr(ak.id.lastIndexOf("-")+1);G(ak,al,ag)}},remove:function(ak,al){if(!O||O.toUpperCase()=="NONE"){showMessage($(ak),W.replace("{{QuestionID}}",M));return false}if(confirm(p)){v=ak.id.substr(ak.id.lastIndexOf("-")+1);G($(ak),al,D)}}}}();function createComments(i){var d=i;var b=function(k){return $("#comments-"+d+"-"+k)};var j=function(k){appendLoader("#comments-"+d+"-"+k+" div.comments")};var h=function(m,l){var k=l.siblings("#can-post-comments-"+d+"-"+m);return k.val().toLowerCase()=="true"};var f=function(o,m){var n="form-comments-"+d+"-"+o;if(h(o,m)){if(m.find("#"+n).length==0){var l='<form id="'+n+'" class="post-comments"><div>';l+='<textarea name="comment" cols="60" rows="5" maxlength="300" onblur="'+d+'Comments.updateTextCounter(this)" ';l+='onfocus="'+d+'Comments.updateTextCounter(this)" onkeyup="'+d+'Comments.updateTextCounter(this)"></textarea>';l+='<input type="submit" value="添加评论" /><br><span class="text-counter"></span>';l+='<span class="form-error"></span></div></form>';m.append(l);setupFormValidation("#"+n,{comment:{required:true,minlength:10}},"",function(){e(o,n)})}}else{var k="comments-rep-needed-"+d+"-"+o;if(m.find("#"+k).length==0){m.append('<div id="'+k+'" style="color:red">评论需要 '+repNeededForComments+' 社区积分 - <a href="/faq" class="comment-user">查看faq</a></span>')}}};var a=function(l,k){j(l);$.getJSON("/"+d+"s/"+l+"/comments/",function(m){c(l,m)})};var c=function(n,l){var m=b(n);m=m.find("div.comments");m.find("div[id^='comment-"+d+"-']").remove();removeLoader();if(l&&l.length>0){for(var k=0;k<l.length;k++){g(m,l[k])}m.children().show()}};var g=function(o,n){var m='<div id="comment-'+d+"-"+n.id+'" style="display:none">'+n.text;m+=n.user_url?' – <a href="'+n.user_url+'"':"<span";m+=' class="comment-user">'+n.user_display_name+(n.user_url?"</a>":"</span>");m+=' <span class="comment-date">('+n.add_date+")</span>";if(n.delete_url){var l="/content/images/close-small.png";var k="/content/images/close-small-hover.png";m+='<img onclick="'+d+"Comments.deleteComment($(this), "+n.object_id+", '"+n.delete_url+'\')" src="'+l;m+="\" onmouseover=\"$(this).attr('src', '"+k+"')\" onmouseout=\"$(this).attr('src', '"+l;m+='\')" title="删除此评论" />'}m+="</div>";o.append(m)};var e=function(n,m){j(n);var l="#"+m;var k=$(l+" textarea");$.ajax({type:"POST",url:"/"+d+"s/"+n+"/comments/",dataType:"json",data:{comment:k.val()},success:function(o){c(n,o);k.val("");commentsFactory[d].updateTextCounter(k);enableSubmitButton(l)},error:function(o,q,p){removeLoader();showMessage(l,o.responseText);enableSubmitButton(l)}})};return{init:function(){$("a[id^='comments-link-"+d+"-']").unbind("click").click(function(){commentsFactory[d].show($(this).attr("id").substr(("comments-link-"+d+"-").length))})},show:function(l){var k=b(l);a(l,k);f(l,k);k.show();if(h(l,k)){k.find("textarea").get(0).focus()}k.siblings("a").unbind("click").click(function(){commentsFactory[d].hide(l)}).text("隐藏评论")},hide:function(n){var m=b(n);var k=m.children("div.comments").children().length;var l=k==0?"添加评论":"评论 (<b>"+k+"</b>)";m.hide();m.siblings("a").unbind("click").click(function(){commentsFactory[d].show(n)}).html(l);m.children("div.comments").children().hide()},deleteComment:function(m,l,k){if(confirm("真要删除此评论吗?")){m.hide();j(l);$.post(k,{dataNeeded:"forIIS7"},function(n){c(l,n)},"json")}},updateTextCounter:function(l){var n=l.value?l.value.length:0;var m=n>270?"#f00":n>200?"#f60":"#999";var k=$(l).siblings("span.text-counter");k.html("还可写"+(300-n)+" 字符").css("color",m)}}}var questionComments=createComments("question");var answerComments=createComments("answer");$().ready(function(){questionComments.init();answerComments.init()});var commentsFactory={question:questionComments,answer:answerComments};var PR_SHOULD_USE_CONTINUATION=true;var PR_TAB_WIDTH=8;var PR_normalizedHtml;var PR;var prettyPrintOne;var prettyPrint;function _pr_isIE6(){var a=navigator&&navigator.userAgent&&/\bMSIE 6\./.test(navigator.userAgent);_pr_isIE6=function(){return a};return a}(function(){function W(av){av=av.split(/ /g);var aw={};for(var au=av.length;--au>=0;){var at=av[au];if(at){aw[at]=null}}return aw}var n="break continue do else for if return while ";var D=n+"auto case char const default double enum extern float goto int long register short signed sizeof static struct switch typedef union unsigned void volatile ";var w=D+"catch class delete false import new operator private protected public this throw true try ";var p=w+"alignof align_union asm axiom bool concept concept_map const_cast constexpr decltype dynamic_cast explicit export friend inline late_check mutable namespace nullptr reinterpret_cast static_assert static_cast template typeid typename typeof using virtual wchar_t where ";var G=w+"boolean byte extends final finally implements import instanceof null native package strictfp super synchronized throws transient ";var ap=G+"as base by checked decimal delegate descending event fixed foreach from group implicit in interface internal into is lock object out override orderby params readonly ref sbyte sealed stackalloc string select uint ulong unchecked unsafe ushort var ";var F=w+"debugger eval export function get null set undefined var with Infinity NaN ";var y="caller delete die do dump elsif eval exit foreach for goto if import last local my next no our print package redo require sub undef unless until use wantarray while BEGIN END ";var ab=n+"and as assert class def del elif except exec finally from global import in is lambda nonlocal not or pass print raise try with yield False True None ";var k=n+"alias and begin case class def defined elsif end ensure false in module next nil not or redo rescue retry self super then true undef unless until when yield BEGIN END ";var aa=n+"case done elif esac eval fi function in local set then until ";var M=(p+ap+F+y+ab+k+aa);var O="str";var L="kwd";var o="com";var al="typ";var Y="lit";var ah="pun";var V="pln";var q="tag";var U="dec";var ad="src";var ao="atn";var s="atv";var ak="nocode";function aq(at){return(at>="a"&&at<="z")||(at>="A"&&at<="Z")}function N(aw,au,at,av){aw.unshift(at,av||0);try{au.splice.apply(au,aw)}finally{aw.splice(0,2)}}var ai=function(){var av=["!","!=","!==","#","%","%=","&","&&","&&=","&=","(","*","*=","+=",",","-=","->","/","/=",":","::",";","<","<<","<<=","<=","=","==","===",">",">=",">>",">>=",">>>",">>>=","?","@","[","^","^=","^^","^^=","{","|","|=","||","||=","~","break","case","continue","delete","do","else","finally","instanceof","return","throw","try","typeof"];var aw="(?:(?:(?:^|[^0-9.])\\.{1,3})|(?:(?:^|[^\\+])\\+)|(?:(?:^|[^\\-])-)";for(var at=0;at<av.length;++at){var au=av[at];if(aq(au.charAt(0))){aw+="|\\b"+au}else{aw+="|"+au.replace(/([^=<>:&])/g,"\\$1")}}aw+="|^)\\s*$";return new RegExp(aw)}();var S=/&/g;var Z=/</g;var x=/>/g;var K=/\"/g;function E(at){return at.replace(S,"&").replace(Z,"<").replace(x,">").replace(K,""")}function r(at){return at.replace(S,"&").replace(Z,"<").replace(x,">")}var e=/</g;var C=/>/g;var d=/'/g;var i=/"/g;var ar=/&/g;var J=/ /g;function t(aw){var ay=aw.indexOf("&");if(ay<0){return aw}for(--ay;(ay=aw.indexOf("&#",ay+1))>=0;){var at=aw.indexOf(";",ay);if(at>=0){var av=aw.substring(ay+3,at);var ax=10;if(av&&av.charAt(0)==="x"){av=av.substring(1);ax=16}var au=parseInt(av,ax);if(!isNaN(au)){aw=(aw.substring(0,ay)+String.fromCharCode(au)+aw.substring(at+1))}}}return aw.replace(e,"<").replace(C,">").replace(d,"'").replace(i,'"').replace(ar,"&").replace(J," ")}function R(at){return"XMP"===at.tagName}function an(ax,av){switch(ax.nodeType){case 1:var au=ax.tagName.toLowerCase();av.push("<",au);for(var aw=0;aw<ax.attributes.length;++aw){var at=ax.attributes[aw];if(!at.specified){continue}av.push(" ");an(at,av)}av.push(">");for(var ay=ax.firstChild;ay;ay=ay.nextSibling){an(ay,av)}if(ax.firstChild||!/^(?:br|link|img)$/.test(au)){av.push("</",au,">")}break;case 2:av.push(ax.name.toLowerCase(),'="',E(ax.value),'"');break;case 3:case 4:av.push(r(ax.nodeValue));break}}var am=null;function b(aw){if(null===am){var au=document.createElement("PRE");au.appendChild(document.createTextNode('<!DOCTYPE foo PUBLIC "foo bar">\n<foo />'));am=!/</.test(au.innerHTML)}if(am){var av=aw.innerHTML;if(R(aw)){av=r(av)}return av}var at=[];for(var ax=aw.firstChild;ax;ax=ax.nextSibling){an(ax,at)}return at.join("")}function ag(av){var at=" ";var au=0;return function(az){var ax=null;var aC=0;for(var ay=0,aB=az.length;ay<aB;++ay){var aA=az.charAt(ay);switch(aA){case"\t":if(!ax){ax=[]}ax.push(az.substring(aC,ay));var aw=av-(au%av);au+=aw;for(;aw>=0;aw-=at.length){ax.push(at.substring(0,aw))}aC=ay+1;break;case"\n":au=0;break;default:++au}}if(!ax){return az}ax.push(az.substring(aC));return ax.join("")}}var Q=/(?:[^<]+|<!--[\s\S]*?-->|<!\[CDATA\[([\s\S]*?)\]\]>|<\/?[a-zA-Z][^>]*>|<)/g;var v=/^<!--/;var T=/^<\[CDATA\[/;var u=/^<br\b/i;var h=/^<(\/?)([a-zA-Z]+)/;function B(aF){var aB=aF.match(Q);var aE=[];var aw=0;var at=[];if(aB){for(var aA=0,av=aB.length;aA<av;++aA){var aC=aB[aA];if(aC.length>1&&aC.charAt(0)==="<"){if(v.test(aC)){continue}if(T.test(aC)){aE.push(aC.substring(9,aC.length-3));aw+=aC.length-12}else{if(u.test(aC)){aE.push("\n");++aw}else{if(aC.indexOf(ak)>=0&&ac(aC)){var au=aC.match(h)[2];var az=1;end_tag_loop:for(var ay=aA+1;ay<av;++ay){var aD=aB[ay].match(h);if(aD&&aD[2]===au){if(aD[1]==="/"){if(--az===0){break end_tag_loop}}else{++az}}}if(ay<av){at.push(aw,aB.slice(aA,ay+1).join(""));aA=ay}else{at.push(aw,aC)}}else{at.push(aw,aC)}}}}else{var ax=t(aC);aE.push(ax);aw+=ax.length}}}return{source:aE.join(""),tags:at}}function ac(at){return !!at.replace(/\s(\w+)\s*=\s*(?:\"([^\"]*)\"|'([^\']*)'|(\S+))/g,' $1="$2$3$4"').match(/[cC][lL][aA][sS][sS]=\"[^\"]*\bnocode\b/)}function j(av,au){var at={};(function(){var ay=av.concat(au);for(var az=ay.length;--az>=0;){var aC=ay[az];var aA=aC[3];if(aA){for(var aB=aA.length;--aB>=0;){at[aA.charAt(aB)]=aC}}}})();var ax=au.length;var aw=/\S/;return function(aA,aH){aH=aH||0;var aB=[aH,V];var aC="";var aJ=0;var aI=aA;while(aI.length){var ay;var aD=null;var aG;var az=at[aI.charAt(0)];if(az){aG=aI.match(az[1]);aD=aG[0];ay=az[0]}else{for(var aE=0;aE<ax;++aE){az=au[aE];var aF=az[2];if(aF&&!aF.test(aC)){continue}aG=aI.match(az[1]);if(aG){aD=aG[0];ay=az[0];break}}if(!aD){ay=V;aD=aI.substring(0,1)}}aB.push(aH+aJ,ay);aJ+=aD.length;aI=aI.substring(aD.length);if(ay!==o&&aw.test(aD)){aC=aD}}return aB}}var a=j([],[[V,/^[^<]+/,null],[U,/^<!\w[^>]*(?:>|$)/,null],[o,/^<!--[\s\S]*?(?:-->|$)/,null],[ad,/^<\?[\s\S]*?(?:\?>|$)/,null],[ad,/^<%[\s\S]*?(?:%>|$)/,null],[ad,/^<(script|style|xmp)\b[^>]*>[\s\S]*?<\/\1\b[^>]*>/i,null],[q,/^<\/?\w[^<>]*>/,null]]);var z=/^(<[^>]*>)([\s\S]*)(<\/[^>]*>)$/;function ae(ay){var av=a(ay);for(var ax=0;ax<av.length;ax+=2){if(av[ax+1]===ad){var az,au;az=av[ax];au=ax+2<av.length?av[ax+2]:ay.length;var at=ay.substring(az,au);var aw=at.match(z);if(aw){av.splice(ax,2,az,q,az+aw[1].length,ad,az+aw[1].length+(aw[2]||"").length,q)}}}return av}var X=j([[s,/^\'[^\']*(?:\'|$)/,null,"'"],[s,/^\"[^\"]*(?:\"|$)/,null,'"'],[ah,/^[<>\/=]+/,null,"<>/="]],[[q,/^[\w:\-]+/,/^</],[s,/^[\w\-]+/,/^=/],[ao,/^[\w:\-]+/,null],[V,/^\s+/,null," \t\r\n"]]);function I(ay,au){for(var aw=0;aw<au.length;aw+=2){var ax=au[aw+1];if(ax===q){var aA,at;aA=au[aw];at=aw+2<au.length?au[aw+2]:ay.length;var av=ay.substring(aA,at);var az=X(av,aA);N(az,au,aw,2);aw+=az.length-2}}return au}function m(aw){var ay=[],av=[];if(aw.tripleQuotedStrings){ay.push([O,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(aw.multiLineStrings){ay.push([O,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{ay.push([O,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}av.push([V,/^(?:[^\'\"\`\/\#]+)/,null," \r\n"]);if(aw.hashComments){ay.push([o,/^#[^\r\n]*/,null,"#"])}if(aw.cStyleComments){av.push([o,/^\/\/[^\r\n]*/,null]);av.push([o,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(aw.regexLiterals){var aA=("^/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+(?:/|$)");av.push([O,new RegExp(aA),ai])}var ax=W(aw.keywords);aw=null;var au=j(ay,av);var az=j([],[[V,/^\s+/,null," \r\n"],[V,/^[a-z_$@][a-z_$@0-9]*/i,null],[Y,/^0x[a-f0-9]+[a-z]/i,null],[Y,/^(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d+)(?:e[+\-]?\d+)?[a-z]*/i,null,"123456789"],[ah,/^[^\s\w\.$@]+/,null]]);function at(aB,aF){for(var aJ=0;aJ<aF.length;aJ+=2){var aC=aF[aJ+1];if(aC===V){var aD,aH,aL,aK;aD=aF[aJ];aH=aJ+2<aF.length?aF[aJ+2]:aB.length;aL=aB.substring(aD,aH);aK=az(aL,aD);for(var aI=0,aE=aK.length;aI<aE;aI+=2){var aM=aK[aI+1];if(aM===V){var aO=aK[aI];var aN=aI+2<aE?aK[aI+2]:aL.length;var aG=aB.substring(aO,aN);if(aG==="."){aK[aI+1]=ah}else{if(aG in ax){aK[aI+1]=L}else{if(/^@?[A-Z][A-Z$]*[a-z][A-Za-z$]*$/.test(aG)){aK[aI+1]=aG.charAt(0)==="@"?Y:al}}}}}N(aK,aF,aJ,2);aJ+=aK.length-2}}return aF}return function(aC){var aB=au(aC);aB=at(aC,aB);return aB}}var af=m({keywords:M,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function aj(at,ax){for(var aA=0;aA<ax.length;aA+=2){var au=ax[aA+1];if(au===ad){var av,ay;av=ax[aA];ay=aA+2<ax.length?ax[aA+2]:at.length;var aB=af(at.substring(av,ay));for(var az=0,aw=aB.length;az<aw;az+=2){aB[az]+=av}N(aB,ax,aA,2);aA+=aB.length-2}}return ax}function c(at,aB){var aI=false;for(var aF=0;aF<aB.length;aF+=2){var av=aB[aF+1];var ax,aD;if(av===ao){ax=aB[aF];aD=aF+2<aB.length?aB[aF+2]:at.length;aI=/^on|^style$/i.test(at.substring(ax,aD))}else{if(av===s){if(aI){ax=aB[aF];aD=aF+2<aB.length?aB[aF+2]:at.length;var aG=at.substring(ax,aD);var au=aG.length;var aA=(au>=2&&/^[\"\']/.test(aG)&&aG.charAt(0)===aG.charAt(au-1));var aw;var ay;var aC;if(aA){ay=ax+1;aC=aD-1;aw=aG}else{ay=ax+1;aC=aD-1;aw=aG.substring(1,aG.length-1)}var aH=af(aw);for(var aE=0,az=aH.length;aE<az;aE+=2){aH[aE]+=ay}if(aA){aH.push(aC,s);N(aH,aB,aF+2,0)}else{N(aH,aB,aF,2)}}aI=false}}}return aB}function l(au){var at=ae(au);at=I(au,at);at=aj(au,at);at=c(au,at);return at}function P(aJ,au,ay){var aB=[];var aI=0;var ax=null;var aC=null;var av=0;var aH=0;var az=ag(PR_TAB_WIDTH);var aw=/([\r\n ]) /g;var aF=/(^| ) /gm;var aA=/\r\n?|\n/g;var aD=/[ \r\n]$/;var aE=true;function aG(aK){if(aK>aI){if(ax&&ax!==aC){aB.push("</span>");ax=null}if(!ax&&aC){ax=aC;aB.push('<span class="',ax,'">')}var aL=r(az(aJ.substring(aI,aK))).replace(aE?aF:aw,"$1 ");aE=aD.test(aL);aB.push(aL.replace(aA,"<br />"));aI=aK}}while(true){var at;if(av<au.length){if(aH<ay.length){at=au[av]<=ay[aH]}else{at=true}}else{at=false}if(at){aG(au[av]);if(ax){aB.push("</span>");ax=null}aB.push(au[av+1]);av+=2}else{if(aH<ay.length){aG(ay[aH]);aC=ay[aH+1];aH+=2}else{break}}}aG(aJ.length);if(ax){aB.push("</span>")}return aB.join("")}var A={};function g(av,aw){for(var at=aw.length;--at>=0;){var au=aw[at];if(!A.hasOwnProperty(au)){A[au]=av}else{if("console" in window){console.log("cannot override language handler %s",au)}}}}g(af,["default-code"]);g(l,["default-markup","html","htm","xhtml","xml","xsl"]);g(m({keywords:p,hashComments:true,cStyleComments:true}),["c","cc","cpp","cs","cxx","cyc"]);g(m({keywords:G,cStyleComments:true}),["java"]);g(m({keywords:aa,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);g(m({keywords:ab,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);g(m({keywords:y,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);g(m({keywords:k,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);g(m({keywords:F,cStyleComments:true,regexLiterals:true}),["js"]);function H(ay,aw){try{var az=B(ay);var av=az.source;var at=az.tags;if(!A.hasOwnProperty(aw)){aw=/^\s*</.test(av)?"default-markup":"default-code"}var au=A[aw].call({},av);return P(av,at,au)}catch(ax){if("console" in window){console.log(ax);console.trace()}return ay}}function f(az){var aA=_pr_isIE6();var au=[document.getElementsByTagName("pre"),document.getElementsByTagName("code"),document.getElementsByTagName("xmp")];var ay=[];for(var aw=0;aw<au.length;++aw){for(var av=0;av<au[aw].length;++av){ay.push(au[aw][av])}}au=null;var at=0;function ax(){var aG=(PR_SHOULD_USE_CONTINUATION?new Date().getTime()+250:Infinity);for(;at<ay.length&&new Date().getTime()<aG;at++){var aH=ay[at];if(aH.className&&aH.className.indexOf("prettyprint")>=0){var aD=aH.className.match(/\blang-(\w+)\b/);if(aD){aD=aD[1]}var aM=false;for(var aB=aH.parentNode;aB;aB=aB.parentNode){if((aB.tagName==="pre"||aB.tagName==="code"||aB.tagName==="xmp")&&aB.className&&aB.className.indexOf("prettyprint")>=0){aM=true;break}}if(!aM){var aJ=b(aH);aJ=aJ.replace(/(?:\r\n?|\n)$/,"");var aN=H(aJ,aD);if(!R(aH)){aH.innerHTML=aN}else{var aC=document.createElement("PRE");for(var aF=0;aF<aH.attributes.length;++aF){var aO=aH.attributes[aF];if(aO.specified){var aK=aO.name.toLowerCase();if(aK==="class"){aC.className=aO.value}else{aC.setAttribute(aO.name,aO.value)}}}aC.innerHTML=aN;aH.parentNode.replaceChild(aC,aH);aH=aC}if(aA&&aH.tagName==="PRE"){var aI=aH.getElementsByTagName("br");for(var aE=aI.length;--aE>=0;){var aL=aI[aE];aL.parentNode.replaceChild(document.createTextNode("\r\n"),aL)}}}}}if(at<ay.length){setTimeout(ax,250)}else{if(az){az()}}}ax()}window.PR_normalizedHtml=an;window.prettyPrintOne=H;window.prettyPrint=f;window.PR={createSimpleLexer:j,registerLangHandler:g,sourceDecorator:m,PR_ATTRIB_NAME:ao,PR_ATTRIB_VALUE:s,PR_COMMENT:o,PR_DECLARATION:U,PR_KEYWORD:L,PR_LITERAL:Y,PR_NOCODE:ak,PR_PLAIN:V,PR_PUNCTUATION:ah,PR_SOURCE:ad,PR_STRING:O,PR_TAG:q,PR_TYPE:al}})();
\ No newline at end of file diff --git a/templates/content/js/com.cnprog.utils.js b/templates/content/js/com.cnprog.utils.js index a5f0e982..683b7a3f 100644 --- a/templates/content/js/com.cnprog.utils.js +++ b/templates/content/js/com.cnprog.utils.js @@ -1,5 +1,6 @@ var showMessage = function(object, msg) { - var div = $('<div class="vote-notification"><h3>' + msg + '</h3>(点击消息框关闭)</div>'); + var div = $('<div class="vote-notification"><h3>' + msg + '</h3>(' + + $.i18n._('click to close') + ')</div>'); div.click(function(event) { $(".vote-notification").fadeOut("fast", function() { $(this).remove(); }); @@ -33,7 +34,12 @@ var notify = function() { } (); function appendLoader(containerSelector) { - $(containerSelector).append('<img class="ajax-loader" src="/content/images/indicator.gif" title="读取中..." alt="读取中..." />'); + $(containerSelector).append('<img class="ajax-loader" ' + +'src="/content/images/indicator.gif" title="' + +$.i18n._('loading...') + +'" alt="' + +$.i18n._('loading...') + +'" />'); } function removeLoader() { @@ -96,16 +102,16 @@ var CPValidator = function(){ getQuestionFormMessages: function(){ return { tags: { - required: " 标签不能为空。", - maxlength: " 最多5个标签,每个标签长度小于20个字符。" + required: " " + $.i18n._('tags cannot be empty'), + maxlength: " " + $.i18n._('tablimits info'), }, text: { - required: " 内容不能为空。", - minlength: jQuery.format(" 请输入至少 {0} 字符。") + required: " " + $.i18n._('content cannot be empty'), + minlength: jQuery.format(' ' + $.i18n._('content minchars')) }, title: { - required: " 请输入标题。", - minlength: jQuery.format(" 请输入至少 {0} 字符。") + required: " " + $.i18n._('please enter title'), + minlength: jQuery.format(' ' + $.i18n._('title minchars')) } }; } diff --git a/templates/content/js/jquery.i18n.js b/templates/content/js/jquery.i18n.js new file mode 100644 index 00000000..0a155a31 --- /dev/null +++ b/templates/content/js/jquery.i18n.js @@ -0,0 +1,133 @@ +/* + * jQuery i18n plugin + * @requires jQuery v1.1 or later + * + * Examples at: http://recurser.com/articles/2008/02/21/jquery-i18n-translation-plugin/ + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + * + * Based on 'javascript i18n that almost doesn't suck' by markos + * http://markos.gaivo.net/blog/?p=100 + * + * Revision: $Id$ + * Version: 1.0.0 Feb-10-2008 + */ + (function($) { +/** + * i18n provides a mechanism for translating strings using a jscript dictionary. + * + */ + + +/* + * i18n property list + */ +$.i18n = { + +/** + * setDictionary() + * Initialise the dictionary and translate nodes + * + * @param property_list i18n_dict : The dictionary to use for translation + */ + setDictionary: function(i18n_dict) { + i18n_dict = i18n_dict; + }, + +/** + * _() + * The actual translation function. Looks the given string up in the + * dictionary and returns the translation if one exists. If a translation + * is not found, returns the original word + * + * @param string str : The string to translate + * @param property_list params : params for using printf() on the string + * @return string : Translated word + * + */ + _: function (str, params) { + var transl = str; + if (i18n_dict&& i18n_dict[str]) { + transl = i18n_dict[str]; + } + return this.printf(transl, params); + }, + +/** + * toEntity() + * Change non-ASCII characters to entity representation + * + * @param string str : The string to transform + * @return string result : Original string with non-ASCII content converted to entities + * + */ + toEntity: function (str) { + var result = ''; + for (var i=0;i<str.length; i++) { + if (str.charCodeAt(i) > 128) + result += "&#"+str.charCodeAt(i)+";"; + else + result += str.charAt(i); + } + return result; + }, + +/** + * stripStr() + * + * @param string str : The string to strip + * @return string result : Stripped string + * + */ + stripStr: function(str) { + return str.replace(/^\s*/, "").replace(/\s*$/, ""); + }, + +/** + * stripStrML() + * + * @param string str : The multi-line string to strip + * @return string result : Stripped string + * + */ + stripStrML: function(str) { + // Split because m flag doesn't exist before JS1.5 and we need to + // strip newlines anyway + var parts = str.split('\n'); + for (var i=0; i<parts.length; i++) + parts[i] = stripStr(parts[i]); + + // Don't join with empty strings, because it "concats" words + // And strip again + return stripStr(parts.join(" ")); + }, + +/* + * printf() + * C-printf like function, which substitutes %s with parameters + * given in list. %%s is used to escape %s. + * + * Doesn't work in IE5.0 (splice) + * + * @param string S : string to perform printf on. + * @param string L : Array of arguments for printf() + */ + printf: function(S, L) { + if (!L) return S; + + var nS = ""; + var tS = S.split("%s"); + + for(var i=0; i<L.length; i++) { + if (tS[i].lastIndexOf('%') == tS[i].length-1 && i != L.length-1) + tS[i] += "s"+tS.splice(i+1,1)[0]; + nS += tS[i] + L[i]; + } + return nS + tS[tS.length-1]; + } + +}; + + +})(jQuery); diff --git a/templates/content/js/wmd/wmd.js b/templates/content/js/wmd/wmd.js index d83780d6..7b611dba 100644 --- a/templates/content/js/wmd/wmd.js +++ b/templates/content/js/wmd/wmd.js @@ -27,18 +27,18 @@ Attacklab.wmdBase = function(){ global.isOpera = /opera/.test(nav.userAgent.toLowerCase()); global.isKonqueror = /konqueror/.test(nav.userAgent.toLowerCase()); - var toolbar_strong_label = "粗体 <strong> Ctrl-B"; - var toolbar_emphasis_label = "斜体 <em> Ctrl-I"; - var toolbar_hyperlink_label = "超链接 <a> Ctrl-L"; - var toolbar_blockquote_label = "引用 <blockquote> Ctrl-."; - var toolbar_code_label = "代码 <pre><code> Ctrl-K"; - var toolbar_image_label = "图片 <img> Ctrl-G"; - var toolbar_numbered_label = "数字编号列表 <ol> Ctrl-O"; - var toolbar_bulleted_label = "项目符号列表 <ul> Ctrl-U"; - var toolbar_heading_label = "标题 <h1>/<h2> Ctrl-H"; - var toolbar_horizontal_label = "水平线 <hr> Ctrl-R"; - var toolbar_undo_label = "撤销 Ctrl-Z"; - var toolbar_redo_label = "重做 Ctrl-Y"; + var toolbar_strong_label = $.i18n._('bold') + " <strong> Ctrl-B"; + var toolbar_emphasis_label = $.i18n._('italic') + " <em> Ctrl-I"; + var toolbar_hyperlink_label = $.i18n._('link') + " <a> Ctrl-L"; + var toolbar_blockquote_label = $.i18n._('quote') + " <blockquote> Ctrl-."; + var toolbar_code_label = $.i18n._('preformatted text') + " <pre><code> Ctrl-K"; + var toolbar_image_label = $.i18n._('image') + " <img> Ctrl-G"; + var toolbar_numbered_label = $.i18n._('numbered list') + " <ol> Ctrl-O"; + var toolbar_bulleted_label = $.i18n._('bulleted list') + " <ul> Ctrl-U"; + var toolbar_heading_label = $.i18n._('heading') + " <h1>/<h2> Ctrl-H"; + var toolbar_horizontal_label = $.i18n._('horizontal bar') + " <hr> Ctrl-R"; + var toolbar_undo_label = $.i18n._('undo') + " Ctrl-Z"; + var toolbar_redo_label = $.i18n._('redo') + " Ctrl-Y"; // ------------------------------------------------------------------- // YOUR CHANGES GO HERE @@ -49,11 +49,9 @@ Attacklab.wmdBase = function(){ // The text that appears on the upper part of the dialog box when // entering links. - var imageDialogText = "<p style='margin-top: 0px'><b>输入图片地址</b></p><p>示例:<br />"+ - "http://www.cnprog.com/images/temp.jpg \"我的截图\"</p>"; - var linkDialogText = "<p style='margin-top: 0px'><b>输入Web地址</b></p><p>示例:<br />"+ - "http://www.cnprog.com/ \"我的网站\"</p>"; - var uploadImageHTML ="<div>或者上传本地图片:</div>" + + var imageDialogText = "<p style='margin-top: 0px'>" + $.i18n._('enter image url') + '</p>'; + var linkDialogText = "<p style='margin-top: 0px'>" + $.i18n._('enter url') + '</p>'; + var uploadImageHTML ="<div>" + $.i18n._('upload image') + "</div>" + "<input type=\"file\" name=\"file-upload\" id=\"file-upload\" size=\"26\" "+ "onchange=\"return ajaxFileUpload($('#image-url'));\"/><br>" + "<img id=\"loading\" src=\"/content/images/indicator.gif\" style=\"display:none;\"/>"; @@ -1079,7 +1077,7 @@ Attacklab.wmdBase = function(){ } else { // mac and other non-Windows platforms - redoButton.title = "重做 - Ctrl+Shift+Z"; + redoButton.title = $.i18n._('redo') + " - Ctrl+Shift+Z"; } redoButton.XShift = "-220px"; redoButton.execute = function(manager){ |