jokersudoku-feedback.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <!doctype html>
  2. <html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover"><meta name="referrer" content="no-referrer"><title>Bug Reports & Suggestions · JokerSudoku</title><style>
  3. :root{color-scheme:light;--blue:#287de0;--ink:#203854;--muted:#64758a;--line:#dde6f0;--bg:#f1f6fc}
  4. *{box-sizing:border-box}body{margin:0;background:var(--bg);color:var(--ink);font:16px/1.6 -apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif}button,input,textarea,select{font:inherit}button,a{touch-action:manipulation}button{cursor:pointer}button:disabled{cursor:default;opacity:.55}button:focus-visible,a:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible{outline:3px solid #eeb735;outline-offset:4px}
  5. .shell{max-width:780px;margin:auto;padding:24px 20px 40px}header{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:30px}.brand{display:flex;gap:10px;align-items:center;font-weight:800;letter-spacing:-.4px}.mark{display:grid;place-items:center;width:38px;height:38px;border-radius:12px;background:var(--ink);color:#ffd777;font-size:25px}.language{background:transparent;color:var(--muted);border:1px solid var(--line);border-radius:10px;padding:6px 8px;min-height:44px}.eyebrow{font-size:12px;letter-spacing:2px;color:var(--blue);font-weight:700}h1{font-size:clamp(28px,5vw,38px);line-height:1.2;letter-spacing:-1px;margin:12px 0 16px}p{margin:0 0 20px}.intro{color:var(--muted);max-width:620px}.card{background:#fff;border:1px solid var(--line);border-radius:22px;padding:24px;margin:18px 0;box-shadow:0 5px 22px #20385404}.number{color:var(--blue);font-size:12px;font-weight:800;letter-spacing:1.5px;margin-bottom:8px}fieldset{min-width:0}legend{float:left;width:100%;font-weight:650;line-height:1.5;padding:0;margin:0 0 20px}.choices{display:flex;gap:12px;clear:both}.choice{position:relative;flex:1;cursor:pointer}.choice input{position:absolute;opacity:0;inset:0;width:100%;height:100%;margin:0}.choice span{display:block;text-align:center;border:1px solid var(--line);border-radius:12px;padding:11px 8px;color:var(--muted)}.choice input:checked+span{border-color:var(--blue);background:#edf5ff;color:var(--blue);box-shadow:inset 0 0 0 1px var(--blue)}.choice input:focus-visible+span{outline:3px solid #eeb735;outline-offset:3px}label.heading{display:block;font-weight:650;margin-bottom:12px}.optional{font-size:13px;font-weight:400;color:var(--muted)}textarea,input[type=text],input[type=email]{display:block;width:100%;background:#f9fbfe;color:var(--ink);border:1px solid var(--line);border-radius:12px;padding:14px;resize:vertical}textarea{min-height:130px}.count,.hint{font-size:12px;color:var(--muted)}.count{text-align:right;margin-top:6px}.actions{display:flex;gap:12px;margin:24px 0 18px}.button{min-height:50px;padding:12px 20px;border:0;border-radius:14px;font-weight:650;flex:1;background:var(--blue);color:#fff;text-decoration:none;text-align:center}.button.secondary{color:var(--ink);background:#fff;border:1px solid var(--line)}.entry{width:100%;padding:18px;display:flex;align-items:center;justify-content:space-between;gap:14px;background:transparent;border:1px solid var(--line);border-radius:14px;color:var(--ink);text-align:left}.entry small{display:block;color:var(--muted);font-weight:400;margin-top:2px}.status{white-space:pre-wrap;color:#b34421;margin:12px 0;min-height:0}.status:empty{display:none}.status.success{color:#16754d}footer{color:var(--muted);font-size:12px;text-align:center;margin-top:26px}a{color:var(--blue)}.upload{position:relative;display:block;border:1.5px dashed #b6cce4;border-radius:14px;padding:25px 16px;text-align:center;background:#f9fbfe;color:var(--blue);cursor:pointer}.upload input{position:absolute;inset:0;width:100%;height:100%;opacity:0;cursor:pointer}.previews{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:12px;margin-top:16px}.shot{position:relative;min-width:0}.shot img{display:block;object-fit:cover;width:100%;height:125px;border-radius:12px;border:1px solid var(--line)}.shot button{position:absolute;right:5px;top:5px;border:0;border-radius:50%;background:#203854e6;color:#fff;width:36px;height:36px}.shot small{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;color:var(--muted)}
  6. @media(max-width:430px){.shell{padding:20px 16px 32px}.card{padding:20px}.actions{gap:10px}.button{padding:12px 14px}.brand{font-size:15px}.previews{grid-template-columns:repeat(2,minmax(0,1fr))}}@media(prefers-reduced-motion:no-preference){button{transition:background .15s,opacity .15s}}
  7. </style></head><body>
  8. <main class="shell"><header><div class="brand"><span class="mark" aria-hidden="true">♛</span>JokerSudoku</div><select class="language" id="language" aria-label="Language"><option value="en">English</option><option value="zh-Hans">简体中文</option></select></header><div class="eyebrow" data-i18n="eyebrow"></div><h1 data-i18n="title"></h1><p class="intro" data-i18n="intro"></p><form id="report"><section class="card"><label class="heading" for="details" data-i18n="details"></label><textarea id="details" name="message" maxlength="5000" required data-placeholder="placeholder"></textarea><div class="count"><span id="count">0</span> / 5000</div></section><section class="card"><label class="heading" for="screenshots"><span data-i18n="screenshots"></span> <span class="optional" data-i18n="optional"></span></label><p class="hint" data-i18n="redact"></p><label class="upload"><input type="file" id="screenshots" accept="image/jpeg,image/png,image/webp" multiple><span data-i18n="choose"></span><br><span class="hint" data-i18n="limits"></span></label><div class="previews" id="previews"></div></section><p class="hint" data-i18n="dataNote"></p><p class="status" id="status" role="status" aria-live="polite"></p><div class="actions"><button class="button" id="submit" type="submit" data-i18n="submit"></button></div></form><footer>Joker Sudoku · <a id="privacy" href="jokersudoku.html" target="_blank" rel="noopener noreferrer" data-i18n="privacy">Privacy Policy</a></footer></main><script>
  9. 'use strict';
  10. const PRIVACY_URL = 'http://a806b934804d0f0ab.awsglobalaccelerator.com/privacy/jokersudoku.html';
  11. const ENDPOINT = 'http://166.117.214.174/api/platform/config';
  12. const CHANNEL = '269';
  13. const MAX_FILES = 3, MAX_FILE_BYTES = 2 * 1024 * 1024, MAX_TOTAL_BYTES = 5 * 1024 * 1024;
  14. const copy = {
  15. en:{pageTitle:'Bug Reports & Suggestions',eyebrow:'MAKE EVERY SQUARE BETTER',title:'We’re listening.',intro:'Found a bug or have an idea? Describe what happened, what you expected, and the steps to reproduce it.',details:'Your report',placeholder:'For example: I paused a puzzle, returned to the home screen, then…',screenshots:'Screenshots',optional:'(optional)',redact:'Remove any personal or sensitive information from screenshots before uploading.',choose:'Choose screenshots',limits:'Up to 3 JPG, PNG or WebP images. 2 MB each, 5 MB total.',dataNote:'Submitting sends your text and selected screenshots to Joker Sudoku. A failed request keeps your text and images on this page so you can retry. Please read the Privacy Policy before submitting.',submit:'Submit feedback',sending:'Submitting…',privacy:'Privacy Policy',remove:'Remove screenshot',badFile:'Choose JPG, PNG or WebP images within the stated size and count limits.',readFailed:'This image could not be read. Please choose another image.',empty:'Please describe your issue or suggestion.',success:'Thank you. The server confirmed receipt of your feedback.',unconfirmed:'The server responded but did not confirm that your feedback was saved. Your input has been kept. Please contact support@jokersudoku.com if needed.',failed:'The report could not be submitted. Check your connection and try again. Your input has been kept.',mixed:'This secure page cannot send feedback to an HTTP endpoint. The operator must enable HTTPS for the feedback API.',timeout:'The request timed out. Your input has been kept; please try again.'},
  16. 'zh-Hans':{pageTitle:'Bug 反馈与优化建议',eyebrow:'让每一格体验更好',title:'你的声音,我们在听。',intro:'发现问题,或有新点子?请描述实际情况、你期待的结果,以及重现问题的操作步骤。',details:'问题描述或优化建议',placeholder:'例如:暂停数独后返回主页,再次继续游戏时…',screenshots:'截图',optional:'(选填)',redact:'上传前请遮挡截图中的个人信息及其他敏感内容。',choose:'选择截图',limits:'最多 3 张 JPG、PNG 或 WebP,每张不超过 2 MB,总计不超过 5 MB。',dataNote:'提交后,你填写的文字和选择的截图将发送给 Joker Sudoku。请求失败时,本页保留内容供你重试。提交前请阅读隐私政策。',submit:'提交反馈',sending:'正在提交…',privacy:'隐私政策',remove:'移除截图',badFile:'请选择符合数量及大小限制的 JPG、PNG 或 WebP 图片。',readFailed:'无法读取该图片,请重新选择。',empty:'请填写问题描述或优化建议。',success:'感谢反馈,服务器已确认收到你的内容。',unconfirmed:'服务器已响应,但未确认反馈已保存。输入内容已保留,必要时请联系 support@jokersudoku.com。',failed:'提交失败,请检查网络后重试。输入内容已保留。',mixed:'当前安全网页无法向 HTTP 接口发送反馈,需要运营方为反馈接口启用 HTTPS。',timeout:'请求超时,输入内容已保留,请重试。'}
  17. };
  18. function nativeCall(action, params = {}) {
  19. if (window.iosapp && typeof window.iosapp.postMessage === 'function') {
  20. window.iosapp.postMessage(action, JSON.stringify(params));
  21. return true;
  22. }
  23. return false;
  24. }
  25. if (!window.iosapp && window.webkit?.messageHandlers?.iosapp) {
  26. window.iosapp = Object.freeze({postMessage(action, params) {
  27. window.webkit.messageHandlers.iosapp.postMessage({action, params: params ?? '{}'});
  28. }});
  29. }
  30. function privacyDestination() {
  31. const candidate = window.iosapp?.privacyURL || new URLSearchParams(location.search).get('privacyurl');
  32. try {
  33. const url = new URL(candidate);
  34. if (['https:', 'http:'].includes(url.protocol) && !url.username && !url.password) return url.href;
  35. } catch (_) {}
  36. return PRIVACY_URL;
  37. }
  38. let lang = new URLSearchParams(location.search).get('lang')?.startsWith('zh') ? 'zh-Hans' : 'en';
  39. const $ = id => document.getElementById(id);
  40. function t(key) { return copy[lang][key]; }
  41. function renderLanguage() {
  42. document.documentElement.lang = lang;
  43. $('language').value = lang;
  44. document.querySelectorAll('[data-i18n]').forEach(node => { node.textContent = t(node.dataset.i18n); });
  45. document.querySelectorAll('[data-placeholder]').forEach(node => { node.placeholder = t(node.dataset.placeholder); });
  46. document.title = t('pageTitle') + ' · JokerSudoku';
  47. }
  48. $('language').addEventListener('change', event => { lang = event.target.value; renderLanguage(); });
  49. $('privacy').addEventListener('click', event => {
  50. event.preventDefault();
  51. try { if (!nativeCall('openWindow', {url:privacyDestination()})) window.open(privacyDestination(), '_blank', 'noopener,noreferrer'); }
  52. catch (_) { showStatus('failed'); }
  53. });
  54. const files = [];
  55. let reading = false, busy = false;
  56. function showStatus(key, success = false) { $('status').textContent = t(key); $('status').classList.toggle('success', success); }
  57. function renderPreviews() {
  58. $('previews').replaceChildren();
  59. files.forEach((entry,index) => {
  60. const tile = document.createElement('div'); tile.className = 'shot';
  61. const image = document.createElement('img'); image.src = entry.preview; image.alt = entry.file.name;
  62. const remove = document.createElement('button'); remove.type = 'button'; remove.textContent = '×'; remove.setAttribute('aria-label',t('remove')); remove.disabled = busy;
  63. remove.addEventListener('click', () => { URL.revokeObjectURL(entry.preview); files.splice(index,1); renderPreviews(); });
  64. const name = document.createElement('small'); name.textContent = entry.file.name;
  65. tile.append(image,remove,name); $('previews').append(tile);
  66. });
  67. }
  68. $('screenshots').addEventListener('change', async event => {
  69. const chosen = Array.from(event.target.files || []); event.target.value = '';
  70. if (busy || reading) return;
  71. const size = files.reduce((sum,entry) => sum + entry.file.size,0) + chosen.reduce((sum,file) => sum + file.size,0);
  72. if (files.length + chosen.length > MAX_FILES || size > MAX_TOTAL_BYTES || chosen.some(file => !['image/jpeg','image/png','image/webp'].includes(file.type) || file.size === 0 || file.size > MAX_FILE_BYTES)) { showStatus('badFile'); return; }
  73. reading = true; $('submit').disabled = true; $('screenshots').disabled = true;
  74. const additions = [];
  75. try {
  76. for (const file of chosen) {
  77. const preview = URL.createObjectURL(file);
  78. const image = new Image(); image.src = preview;
  79. try { await image.decode(); } catch (error) { URL.revokeObjectURL(preview); throw error; }
  80. additions.push({file, preview});
  81. }
  82. files.push(...additions); $('status').textContent = ''; renderPreviews();
  83. } catch (_) { additions.forEach(entry => URL.revokeObjectURL(entry.preview)); showStatus('readFailed'); }
  84. finally { reading = false; $('submit').disabled = false; $('screenshots').disabled = false; }
  85. });
  86. $('details').addEventListener('input', () => { $('count').textContent = $('details').value.length; });
  87. function readDataURL(file) { return new Promise((resolve,reject) => { const reader = new FileReader(); reader.onload = () => resolve(reader.result); reader.onerror = reject; reader.onabort = reject; reader.readAsDataURL(file); }); }
  88. $('report').addEventListener('submit', async event => {
  89. event.preventDefault();
  90. if (busy || reading || !$('report').reportValidity()) return;
  91. const message = $('details').value.trim();
  92. if (!message) { showStatus('empty'); return; }
  93. if (location.protocol === 'https:' && new URL(ENDPOINT).protocol === 'http:') { showStatus('mixed'); return; }
  94. busy = true; $('submit').disabled = true; $('details').disabled = true; $('screenshots').disabled = true; renderPreviews(); $('submit').textContent = t('sending'); $('status').textContent = '';
  95. const controller = new AbortController(); const timer = setTimeout(() => controller.abort(),30000);
  96. try {
  97. const screenshots = await Promise.all(files.map(async ({file}) => ({name:file.name,type:file.type,size:file.size,data_url:await readDataURL(file)})));
  98. const feedback = {type:'bug_feedback',message,screenshots,submitted_at:new Date().toISOString()};
  99. const data = {channel:CHANNEL,language:lang,player_info_9:JSON.stringify(feedback)};
  100. const result = await fetch(ENDPOINT,{method:'POST',headers:{'Content-Type':'application/json','Accept':'application/json'},body:JSON.stringify({data}),credentials:'omit',referrerPolicy:'no-referrer',signal:controller.signal});
  101. if (!result.ok) throw new Error('http_error');
  102. const receipt = await result.json().catch(() => null);
  103. // Config envelopes are not feedback acknowledgements.
  104. const acknowledged = receipt && receipt.success !== false && receipt.status !== 'error' && (receipt.success === true || receipt.status === 'success' || receipt.code === 0 || receipt.code === 200) && !(typeof receipt.data === 'string' && receipt.data.startsWith('v2:'));
  105. if (!acknowledged) { showStatus('unconfirmed'); return; }
  106. showStatus('success',true); $('report').reset(); $('count').textContent = '0'; files.forEach(entry => URL.revokeObjectURL(entry.preview)); files.length = 0;
  107. } catch (error) { showStatus(error.name === 'AbortError' ? 'timeout' : 'failed'); }
  108. finally { clearTimeout(timer); busy = false; $('submit').disabled = false; $('details').disabled = false; $('screenshots').disabled = false; $('submit').textContent = t('submit'); renderPreviews(); }
  109. });
  110. window.addEventListener('pagehide', () => files.forEach(entry => URL.revokeObjectURL(entry.preview)));
  111. renderLanguage();
  112. </script></body></html>