git ssb

30+

cel / git-ssb-web



Commit d0d23d8d9e03d38b5f6a89d3ab680cd659544746

Use strings for inline scripts instead of toString

toString seems broken with pkg
cel committed on 4/10/2020, 8:12:43 PM
Parent: e095c75a1ef7824b16689d3ef626435a90ca42ca

Files changed

lib/forms.jschanged
lib/forms.jsView
@@ -1,8 +1,35 @@
11 var h = require('pull-hyperscript')
22 var u = require('./util')
33 var forms = exports
44
5 +var issueCommentScript = `;(function () {
6 + var container = [].slice.call(document.querySelectorAll('.post-form')).pop() || document.body
7 + var $ = container.querySelector.bind(container)
8 + $('.tab-links').style.display = 'block'
9 + $('.tab2-link').onclick = function (e) {
10 + with (new XMLHttpRequest()) {
11 + open('POST', '', true)
12 + onload = function() {
13 + $('.preview-text').innerHTML = responseText
14 + }
15 + var repoInput = $('.repo-id')
16 + send('action=markdown' +
17 + (repoInput ? '&repo=' + encodeURIComponent(repoInput.value) : '') +
18 + '&text=' + encodeURIComponent($('.post-text').value))
19 + }
20 + }
21 +}())`
22 +
23 +var issueCommentButtonScript = `;(function () {
24 + var btn = document.getElementById('comment-close-btn')
25 + document.getElementById('post-text').onkeyup = function (e) {
26 + btn.setAttribute('value', this.value
27 + ? btn.getAttribute('data-value-withcomment')
28 + : btn.getAttribute('data-value-nocomment'))
29 + }
30 +}())`
31 +
532 forms.post = function (req, repo, placeholder, rows) {
633 return '<div class="post-form">' +
734 '<input type="radio" class="tab-radio" id="tab1" name="tab" checked="checked"/>' +
835 '<input type="radio" class="tab-radio" id="tab2" name="tab"/>' +
@@ -53,35 +80,8 @@
5380 header
5481 ])
5582 }
5683
57-var issueCommentScript = '(' + function () {
58- var container = [].slice.call(document.querySelectorAll('.post-form')).pop() || document.body
59- var $ = container.querySelector.bind(container)
60- $('.tab-links').style.display = 'block'
61- $('.tab2-link').onclick = function (e) {
62- with (new XMLHttpRequest()) {
63- open('POST', '', true)
64- onload = function() {
65- $('.preview-text').innerHTML = responseText
66- }
67- var repoInput = $('.repo-id')
68- send('action=markdown' +
69- (repoInput ? '&repo=' + encodeURIComponent(repoInput.value) : '') +
70- '&text=' + encodeURIComponent($('.post-text').value))
71- }
72- }
73-}.toString() + ')()'
74-
75-var issueCommentButtonScript = '(' + function () {
76- var btn = document.getElementById('comment-close-btn')
77- document.getElementById('post-text').onkeyup = function (e) {
78- btn.setAttribute('value', this.value
79- ? btn.getAttribute('data-value-withcomment')
80- : btn.getAttribute('data-value-nocomment'))
81- }
82-}.toString() + ')()'
83-
8484 forms.issueComment = function (req, issue, repo, branch, type) {
8585 return '<section><form action="" method="post">' +
8686 '<input type="hidden" name="action" value="comment">' +
8787 '<input type="hidden" name="id" value="' + issue.id + '">' +

Built with git-ssb-web