diff --git a/build/embed.js b/build/embed.js index 8b8be80..fa32cad 100644 --- a/build/embed.js +++ b/build/embed.js @@ -1 +1 @@ -!function(){"use strict";var n="function"==typeof fetch?fetch.bind():function(n,t){return t=t||{},new Promise(function(e,s){function a(){var n,t=[],e=[],s={};return o.getAllResponseHeaders().replace(/^(.*?):\s*([\s\S]*?)$/gm,function(a,o,c){t.push(o=o.toLowerCase()),e.push([o,c]),n=s[o],s[o]=n?n+","+c:c}),{ok:1==(o.status/200|0),status:o.status,statusText:o.statusText,url:o.responseURL,clone:a,text:function(){return Promise.resolve(o.responseText)},json:function(){return Promise.resolve(o.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([o.response]))},headers:{keys:function(){return t},entries:function(){return e},get:function(n){return s[n.toLowerCase()]},has:function(n){return n.toLowerCase()in s}}}}var o=new XMLHttpRequest;o.open(t.method||"get",n);for(var c in t.headers)o.setRequestHeader(c,t.headers[c]);o.withCredentials="include"==t.credentials,o.onload=function(){e(a())},o.onerror=s,o.send(t.body)})},t=function(n){var t,e="";return n.user?e+='\n
\n
\n \n \n  \n
\n (signed in as @'+(null==(t=n.user.name)?"":t)+' :: sign out)\n
\n':(e+="\nTo post a comment you need to sign in via
\n",n.auth.forEach(function(n,s){e+="\n "+(null==(t=s?" or ":"")?"":t)+'\n"}),e+="\n"),e+='\n"};!function(){function e(){n(l,{credentials:"include",headers:{"Content-Type":"application/json"}}).then(function(n){return n.json()}).then(function(a){s(u).innerHTML=t(a);var o=s(u+" textarea.schnack-body"),c=s(u+" .schnack-form blockquote.schnack-body"),r=s(u+" .schnack-button"),d=s(u+" .schnack-preview"),h=s(u+" .schnack-write");if(r&&(r.addEventListener("click",function(t){var s=o.value;n(l,{credentials:"include",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({comment:s})}).then(function(n){return n.json()}).then(function(n){console.log(n),e()})}),d.addEventListener("click",function(t){var e=o.value;o.style.display="none",d.style.display="none",c.style.display="block",h.style.display="inline",n(i+"/markdown",{credentials:"include",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({comment:e})}).then(function(n){return n.json()}).then(function(n){console.log(n),c.innerHTML=n.html})}),h.addEventListener("click",function(n){o.style.display="block",d.style.display="inline",c.style.display="none",h.style.display="none"})),a.user){var p=s("a.schnack-signout");p&&p.addEventListener("click",function(t){t.preventDefault(),n(i+"/signout",{credentials:"include",headers:{"Content-Type":"application/json"}}).then(function(n){return n.json()}).then(function(n){console.log(n),e()})})}else a.auth.forEach(function(n){var t=s(u+" .schnack-signin-"+n.id);t&&t.addEventListener("click",function(t){var s=window.open(i+"/auth/"+n.id,n.name+" Sign-In","resizable,scrollbars,status,width=600,height=500");window.__schnack_wait_for_oauth=function(){s.close(),e()}})});if(a.user&&a.user.admin){var f=function(t){var s=t.target.dataset;n(i+"/"+s.class+"/"+s.target+"/"+s.action,{credentials:"include",method:"POST",headers:{"Content-Type":"application/json"},body:""}).then(function(n){return n.json()}).then(function(n){console.log(n),e()})};document.querySelectorAll(".schnack-action").forEach(function(n){n.addEventListener("click",f)})}})}var s=function(n){return document.querySelector(n)},a=s("script[data-schnack-target]");if(!a)return console.warn("schnack script tag needs some data attributes");var o=a.dataset,c=o.schnackSlug,r=new URL(a.getAttribute("src")),i=r.protocol+"//"+r.host,l=i+"/comments/"+c,u=o.schnackTarget;document.domain=r.host.split(".").slice(1).join("."),e()}()}(); +!function(){"use strict";var n="function"==typeof fetch?fetch.bind():function(n,t){return t=t||{},new Promise(function(e,s){function a(){var n,t=[],e=[],s={};return o.getAllResponseHeaders().replace(/^(.*?):\s*([\s\S]*?)$/gm,function(a,o,c){t.push(o=o.toLowerCase()),e.push([o,c]),n=s[o],s[o]=n?n+","+c:c}),{ok:1==(o.status/200|0),status:o.status,statusText:o.statusText,url:o.responseURL,clone:a,text:function(){return Promise.resolve(o.responseText)},json:function(){return Promise.resolve(o.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([o.response]))},headers:{keys:function(){return t},entries:function(){return e},get:function(n){return s[n.toLowerCase()]},has:function(n){return n.toLowerCase()in s}}}}var o=new XMLHttpRequest;o.open(t.method||"get",n);for(var c in t.headers)o.setRequestHeader(c,t.headers[c]);o.withCredentials="include"==t.credentials,o.onload=function(){e(a())},o.onerror=s,o.send(t.body)})},t=function(n){var t,e="";return n.user?e+='\n
\n \n \n
\n \n  \n
\n (signed in as @'+(null==(t=n.user.name)?"":t)+' :: sign out)\n
\n':(e+="\nTo post a comment you need to sign in via
\n",n.auth.forEach(function(n,s){e+="\n "+(null==(t=s?" or ":"")?"":t)+'\n"}),e+="\n"),e+='\n"};!function(){function e(){n(l,{credentials:"include",headers:{"Content-Type":"application/json"}}).then(function(n){return n.json()}).then(function(a){s(u).innerHTML=t(a);var o=s(u+" textarea.schnack-body"),c=s(u+" .schnack-form blockquote.schnack-body"),r=s(u+" .schnack-button"),d=s(u+" .schnack-preview"),h=s(u+" .schnack-write");if(r&&(r.addEventListener("click",function(t){var s=o.value;n(l,{credentials:"include",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({comment:s})}).then(function(n){return n.json()}).then(function(n){console.log(n),e()})}),d.addEventListener("click",function(t){var e=o.value;o.style.display="none",d.style.display="none",c.style.display="block",h.style.display="inline",n(i+"/markdown",{credentials:"include",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({comment:e})}).then(function(n){return n.json()}).then(function(n){console.log(n),c.innerHTML=n.html})}),h.addEventListener("click",function(n){o.style.display="inline",d.style.display="inline",c.style.display="none",h.style.display="none"})),a.user){var p=s("a.schnack-signout");p&&p.addEventListener("click",function(t){t.preventDefault(),n(i+"/signout",{credentials:"include",headers:{"Content-Type":"application/json"}}).then(function(n){return n.json()}).then(function(n){console.log(n),e()})})}else a.auth.forEach(function(n){var t=s(u+" .schnack-signin-"+n.id);t&&t.addEventListener("click",function(t){var s=window.open(i+"/auth/"+n.id,n.name+" Sign-In","resizable,scrollbars,status,width=600,height=500");window.__schnack_wait_for_oauth=function(){s.close(),e()}})});if(a.user&&a.user.admin){var f=function(t){var s=t.target.dataset;n(i+"/"+s.class+"/"+s.target+"/"+s.action,{credentials:"include",method:"POST",headers:{"Content-Type":"application/json"},body:""}).then(function(n){return n.json()}).then(function(n){console.log(n),e()})};document.querySelectorAll(".schnack-action").forEach(function(n){n.addEventListener("click",f)})}})}var s=function(n){return document.querySelector(n)},a=s("script[data-schnack-target]");if(!a)return console.warn("schnack script tag needs some data attributes");var o=a.dataset,c=o.schnackSlug,r=new URL(a.getAttribute("src")),i=r.protocol+"//"+r.host,l=i+"/comments/"+c,u=o.schnackTarget;document.domain=r.host.split(".").slice(1).join("."),e()}()}(); diff --git a/src/embed/comments.jst.html b/src/embed/comments.jst.html index 5bc089d..5aacaaa 100644 --- a/src/embed/comments.jst.html +++ b/src/embed/comments.jst.html @@ -1,7 +1,8 @@ <% if (data.user) { %>
-
+ +
 
diff --git a/src/embed/index.js b/src/embed/index.js index ff43769..4d39d07 100644 --- a/src/embed/index.js +++ b/src/embed/index.js @@ -70,7 +70,7 @@ import comments_tpl from './comments.jst.html'; }); writeBtn.addEventListener('click', (d) => { - textarea.style.display = 'block'; + textarea.style.display = 'inline'; previewBtn.style.display = 'inline'; preview.style.display = 'none'; writeBtn.style.display = 'none';