Files
tamabox/templates/question/new-question-template.html.bak
T
tamakyi e3e59e7c69 chore: baseline snapshot before moderation-strictness feature
Repo .git was damaged (refs/ missing, index truncated, object store near-empty).
Repaired via git init (rebuilt refs), stale index preserved as .git/index.corrupt-20260910.bak,
then full worktree committed as a rollback baseline.
2026-09-10 10:56:27 +08:00

145 lines
5.8 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{{ if not .CanAsk }}
<div>
<div uk-alert class="uk-text-center">
<p>提问箱的主人设置了仅注册用户才能提问,你需要先登录才能向他提问。</p>
</div>
<div class="uk-margin uk-text-center">
<a class="uk-button uk-button-primary" href="/login?to={{.CurrentURI}}">前往登录</a>
</div>
</div>
{{ else }}
<form method="post" action="/_/{{.PageUser.Domain}}" enctype="multipart/form-data" id="form">
{{ .CSRFTokenHTML }}
{{if .PageUser.AskPassword}}
<input type="hidden" name="ask_password" id="ask_password_input" value="">
{{end}}
<input type="hidden" name="start_chat_val" id="start_chat_val" value="false">
<div class="uk-margin uk-text-center">
<textarea name="content" class="uk-textarea" rows="5" placeholder="在此处撰写你的问题..."
maxlength="1000">{{.content}}</textarea>
<div x-data="{ files: null }" style="width: 100%; background-color: #f8f8f8; display: flex; padding-top: 5px; padding-bottom: 5px; align-items: center; justify-content: start;gap: 5px">
<div uk-form-custom>
<a href="#" class="uk-icon-link" uk-icon="image" style="margin-left: 10px"></a>
<span style="font-size: 12px" x-text="files ? files[0].name : '添加图片'"></span>
<input id="uploader" name="images" type="file" accept="image/*" x-on:change="files = Object.values($event.target.files)">
</div>
<button x-show="files" type="button" class="uk-icon-link" uk-icon="close" style="margin-left: 10px;"
@click="files = null"></button>
</div>
</div>
<div class="uk-margin uk-grid-small">
<label class="uk-text-small">
<input name="private" class="uk-checkbox" type="checkbox"> 回复后不公开
</label>
<label class="uk-text-small">
<input name="receive_reply_via_email" id="notify-checkbox" class="uk-checkbox" type="checkbox"> 接收通知
</label>
<div id="email-container" style="width: 100%; display: none;" class="uk-margin-small-top">
<input class="uk-input uk-form-small" type="email" name="receive_reply_email" id="email-input" placeholder="请输入你的邮箱地址">
</div>
</div>
<div class="uk-margin uk-text-center">
<div class="uk-grid-small uk-flex-center" uk-grid>
<div>
<button type="submit" class="uk-button uk-button-primary g-recaptcha"
data-sitekey="{{.RecaptchaSiteKey}}" data-callback="onSubmit"
id="normal-submit-btn">发送提问</button>
</div>
{{ if and .LoggedUser .PageUser.AllowChat }}
<div>
<button type="button" class="uk-button uk-button-secondary" id="chat-submit-btn">发起私聊</button>
<div class="uk-text-meta">消息上限:{{.PageUser.ChatMaxMessages}}条</div>
</div>
{{ else if not .LoggedUser }}
<div>
<button type="button" class="uk-button uk-button-secondary" id="chat-submit-btn">发起私聊</button>
</div>
{{ else }}
<div>
<button type="button" class="uk-button uk-button-secondary" disabled uk-tooltip="该提问箱未开启私聊">发起私聊</button>
</div>
{{ end }}
</div>
</div>
</form>
<script>
// 邮箱显隐与验证逻辑
var notifyCheckbox = document.getElementById('notify-checkbox');
var emailContainer = document.getElementById('email-container');
var emailInput = document.getElementById('email-input');
if (notifyCheckbox && emailContainer && emailInput) {
notifyCheckbox.addEventListener('change', function() {
if (this.checked) {
emailContainer.style.display = 'block';
emailInput.setAttribute('required', 'required');
} else {
emailContainer.style.display = 'none';
emailInput.removeAttribute('required');
emailInput.value = ''; // 清空已填内容
}
});
}
// 私聊按钮点击处理
var chatBtn = document.getElementById('chat-submit-btn');
if (chatBtn) {
chatBtn.addEventListener('click', function() {
var isLogged = {{ if .LoggedUser }}true{{ else }}false{{ end }};
if (!isLogged) {
var currentURI = '{{.CurrentURI}}';
UIkit.modal.dialog(
'<div class="uk-text-center uk-padding" style="min-height: 150px; display: flex; flex-direction: column; justify-content: center;">' +
'<h3 class="uk-modal-title uk-margin-small-bottom">需要登录</h3>' +
'<p class="uk-text-muted uk-margin-small-bottom">发起私聊需要登录账号</p>' +
'<a href="/login?to=' + encodeURIComponent(currentURI) + '" class="uk-button uk-button-primary">去登录</a>' +
'</div>',
{width: '400px'}
);
return;
}
// 已登录,设置私聊标识并触发提交
document.getElementById('start_chat_val').value = 'true';
document.getElementById('normal-submit-btn').click();
});
}
function onSubmit(token) {
var btn = document.querySelector('.g-recaptcha');
var originalText = btn.innerText;
// 手动验证邮箱(字段名已修正为 receive_reply_email)
if (notifyCheckbox && notifyCheckbox.checked && emailInput && emailInput.value.trim() === '') {
alert('请填写接收通知的邮箱地址');
grecaptcha.reset(); // 重置验证码
return;
}
btn.disabled = true;
btn.innerText = '验证中...';
var needPassword = {{if .PageUser.AskPassword}}true{{else}}false{{end}};
if (needPassword) {
UIkit.modal.prompt('此提问箱需要密码', '', 'password')
.then(function(password) {
if (password) {
document.getElementById('ask_password_input').value = password;
document.getElementById('form').submit();
} else {
btn.disabled = false;
btn.innerText = originalText;
grecaptcha.reset();
}
});
} else {
document.getElementById('form').submit();
}
}
</script>
{{ end }}