134 lines
4.4 KiB
HTML
134 lines
4.4 KiB
HTML
{{template "home/header.html" .}}
|
|
|
|
<section>
|
|
</section>
|
|
{{$isMarkDown := .isMarkDown}}
|
|
|
|
<div id="queryNote" style="height:300px;padding-top:80px" align="center">
|
|
{{ .userName }}分享了笔记<br/><br>
|
|
|
|
您需要输入分享密码才能查看:<br><br>
|
|
<input type="password" id="sharePass" />
|
|
<button id="showShareNote">点击查看</button><br/><br/>
|
|
<span id="showMsg"></span>
|
|
</div>
|
|
|
|
<div id="noteContainer" style="display:none">
|
|
|
|
</div>
|
|
|
|
|
|
{{template "home/footer.html"}}
|
|
|
|
<script src="/js/jquery-1.9.0.min.js"></script>
|
|
<script src="/js/bootstrap.js"></script>
|
|
<script src="/js/common-min.js"></script>
|
|
<script>
|
|
|
|
var noteId = {{ .noteId }};
|
|
var isMarkDown = {{ .isMarkDown}}
|
|
|
|
String.prototype.format = function() {
|
|
var s = this,
|
|
i = arguments.length;
|
|
|
|
while (i--) {
|
|
s = s.replace(new RegExp('\\{' + i + '\\}', 'gm'), arguments[i]);
|
|
}
|
|
return s;
|
|
};
|
|
|
|
|
|
var getHost = function(url) {
|
|
var host = "null";
|
|
if(typeof url == "undefined"
|
|
|| null == url)
|
|
url = window.location.href;
|
|
var regex = /.*\:\/\/([^\/]*).*/;
|
|
var match = url.match(regex);
|
|
if(typeof match != "undefined"
|
|
&& null != match)
|
|
host = match[1];
|
|
return "http://" + host;
|
|
}
|
|
|
|
$(function() {
|
|
|
|
$("#showShareNote").on("click", function() {
|
|
$("#showMsg").html("");
|
|
var url = "/share/verify4ShareNote";
|
|
|
|
var sharePass = $("#sharePass").val();
|
|
var data = {noteId: noteId, sharePass: sharePass};
|
|
ajaxPost(url, data, function(re) {
|
|
if(reIsOk(re)) {
|
|
$("#queryNote").css("display", "none");
|
|
var title = re.Item.Title;
|
|
var content = re.Msg;
|
|
var imgSrc = re.Item.ImgSrc;
|
|
var htmlContent = "<div><h1 height='50px'>{0}</h1></div><hr/><div style='vertical-align:center'><p height='auto'>{1}<br>{2}</p>";
|
|
|
|
var attaches = re.List;
|
|
var attachesHtml = "";
|
|
if (attaches.length > 0) {
|
|
var token = re.Id;
|
|
for (var i=0; i<attaches.length; i++) {
|
|
var linkUrl = "{0}/attach/download?attachId={1}&token={2}".format(getHost(), attaches[i].AttachId, token);
|
|
attachesHtml += "<p><a href='{0}' target='_blank' data-mce-href='{1}' >附件{2}</a></p><br/>".format(linkUrl, linkUrl, i+1);
|
|
}
|
|
}
|
|
|
|
htmlContent = htmlContent.format(title, content, attachesHtml) + "</div>";
|
|
|
|
|
|
/* if (isMarkDown) {
|
|
var converter = Markdown.getSanitizingConverter();
|
|
Markdown.Extra.init(converter, {extensions: ["tables", "fenced_code_gfm", "def_list"]});
|
|
var mdDesc = converter.makeHtml(desc);
|
|
$("pre").addClass("prettyprint linenums");
|
|
prettyPrint();
|
|
MathJax.Hub.Queue(["Typeset",MathJax.Hub,"wmd-preview"]);
|
|
htmlContent = "<div><h1 height='50px'>"+title+"</h1></div><hr/><div style='vertical-align:center'><p height='auto'>"
|
|
+mdDesc+"</p></div>";
|
|
} else {
|
|
htmlContent = "<div><h1 height='50px'>"+title+"</h1></div><hr/><div style='vertical-align:center'><p height='auto'>"
|
|
+desc+"</p></div>";
|
|
} */
|
|
|
|
|
|
$("#noteContainer").css("display", "block").css("height", "auto")
|
|
.css("padding-top", "20px").css("text-align", "center")
|
|
.css("margin-left", "auto").css("margin-right", "auto");
|
|
|
|
$("#noteContainer").html(htmlContent);
|
|
} else {
|
|
$("#showMsg").html("<font color='red'>密码错误</font>");
|
|
}
|
|
});
|
|
});
|
|
|
|
// 平滑滚动
|
|
$(".smooth-scroll").click(function(e) {
|
|
e.preventDefault();
|
|
var t = $(this).attr("target");
|
|
var targetOffset = $(t).offset().top - 80;
|
|
$('html,body').animate({scrollTop: targetOffset}, 300);
|
|
});
|
|
});
|
|
</script>
|
|
|
|
{{if $isMarkDown}}
|
|
<script src="/public/mdeditor/editor/pagedown/Markdown.Converter.js"></script>
|
|
<script src="/public/mdeditor/editor/pagedown/Markdown.Sanitizer.js"></script>
|
|
<script src="/public/mdeditor/editor/pagedown/Markdown.Editor.js"></script>
|
|
<script src="/public/mdeditor/editor/pagedown/local/Markdown.local.zh.js"></script>
|
|
<script src="/public/mdeditor/editor/Markdown.Extra.js"></script>
|
|
<script src="/public/mdeditor/editor/editor.js"></script>
|
|
<script src="/public/js/google-code-prettify/prettify.js"></script>
|
|
<!--mathjax-->
|
|
<script type="text/x-mathjax-config">
|
|
MathJax.Hub.Config({ tex2jax: { inlineMath: [['$','$'], ["\\(","\\)"]], processEscapes: true }, messageStyle: "none"});
|
|
</script>
|
|
<script src="/public/mdeditor/editor/mathJax.js"></script>
|
|
<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
|
{{end}} |