1var app = new Vue({ 2 el: '#app', 3 components: { 4 qrcode: VueQrcode 5 }, 6 data: { 7 isLogin: false, 8 useCaptcha: false, 9 originalURL: "", 10 shortURL: "", 11 qrcodeURL: "", 12 utms: ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"], 13 utm: {}, 14 error_msg: "", 15 meta_image: "", 16 meta_title: "", 17 meta_desc: "", 18 beforeCut: true, 19 cutBtnDisabled: false, 20 arrow: "â¼", 21 bsCollapse: "", 22 contactUsername: "", 23 contactEmail: "", 24 contactContent: "" 25 }, 26 methods: { 27 setArrow: function () { 28 if (this.arrow === "â¼") { 29 this.arrow = "â²" 30 } else { 31 this.arrow = "â¼" 32 } 33 }, 34 openCollapse(show) { 35 const collapseElement = document.getElementById('collapseSection') 36 const bsCollapse = new bootstrap.Collapse(collapseElement, {toggle: false}) 37 console.log(bsCollapse) 38 bsCollapse.show() 39 this.arrow = "â²" 40 }, 41 shorten: function () { 42 if (this.useCaptcha) { 43 grecaptcha.execute(); 44 } else { 45 this.cutURL(); 46 } 47 }, 48 cutURL: function () { 49 var self = this 50 let body = {url: self.originalURL} 51 this.utms.map(function (str) { 52 if (self.utm[str] !== "") { 53 body[str] = self.utm[str] 54 } 55 }) 56 if (this.useCaptcha) { 57 let code = grecaptcha.getResponse() 58 if (typeof (code) !== 'string' || code === '') { 59 console.log("recaptcha not found") 60 swal.fire({ 61 text: self.$refs.bad_request.innerText, 62 icon: 'error', 63 showConfirmButton: true 64 }).then(function () { 65 location.reload() 66 }) 67 } 68 body.code = code 69 } 70 71 self.cutBtnDisabled = true 72 swal.fire({ 73 title: self.$refs.cutting.innerText, 74 allowOutsideClick: false 75 }) 76 swal.showLoading() 77 axios.post("/shorten/v4", body, {headers: {'X-CSRF-Token': this.$refs.csrf.innerText}}) 78 .then(function (res) { 79 swal.close() 80 const data = res.data 81 self.beforeCut = false 82 self.shortURL = "https://" + window.location.host + "/" + data.shorten_id 83 self.meta_title = data.title 84 self.meta_image = data.image 85 self.meta_desc = data.desc 86 self.qrcodeURL = data.qrcode_url 87 swal.fire({ 88 text: self.$refs.cutSuccessMsg.value, 89 title: self.shortURL, 90 icon: 'success', 91 timer: 2000,
92 showConfirmButton: false 93 }) 94 self.cutBtnDisabled = false 95 self.openCollapse() 96 if (self.useCaptcha) { 97 grecaptcha.reset() 98 } 99 }) 100 .catch(function (err) { 101 swal.close() 102 console.log(err) 103 if (err.response.status === 403) { 104 swal.fire({ 105 text: self.$refs.timeout.innerText, 106 icon: 'error', 107 showConfirmButton: true 108 }).then(function (result) { 109 location.reload() 110 }) 111 } else if (err.response.status === 413) { 112 swal.fire({ 113 text: self.$refs.too_long.innerText, 114 icon: 'error', 115 showConfirmButton: true 116 }) 117 } else { 118 swal.fire({ 119 text: self.$refs.bad_request.innerText, 120 icon: 'error', 121 showConfirmButton: true 122 }).then(function () { 123 location.reload() 124 }) 125 } 126 self.cutBtnDisabled = false 127 }) 128 }, 129 clear: function () { 130 this.originalURL = "" 131 }, 132 copy: function () { 133 const clipboard = new Clipboard('.copyButton') 134 clipboard.on('success', this.onCopy) 135 clipboard.on('error', this.onError) 136 }, 137 onCopy: function (e) { 138 console.log(e) 139 swal.fire({ 140 text: this.$refs.copySuccessMsg.innerText, 141 title: e.text, 142 icon: 'success', 143 timer: 2000,
144 showConfirmButton: false 145 }) 146 }, 147 onError: function (e) { 148 swal.fire({ 149 title: "Failed to copy", 150 icon: 'error', 151 timer: 2000, 152 showConfirmButton: false 153 }) 154 }, 155 downloadPic: function () { 156 const canvas = this.$refs.qrcode.$el.qrious.canvas 157 canvas.toBlob(function (blob) { 158 saveAs(blob, "qrcode.png") 159 }) 160 }, 161 sendContactMessage: function () { 162 swal.showLoading() 163 var self = this 164 const body = { 165 "name": this.contactUsername, 166 "email": this.contactEmail, 167 "content": this.contactContent 168 } 169 axios.post("/main/api/contact", body, {headers: {'X-CSRF-Token': this.$refs.csrf.innerText}}) 170 .then(function (result) { 171 swal.close() 172 swal.fire({ 173 text: self.$refs.contactSuccessMsg.innerText, 174 icon: "success", 175 showConfirmButton: true 176 }) 177 }) 178 .catch(err => { 179 swal.close() 180 const data = err.response.data 181 swal.fire({ 182 text: data.msg, 183 icon: 'error', 184 showConfirmButton: true 185 }) 186 }) 187 } 188 }, 189 mounted: function () { 190 this.$refs.shortenBox.placeholder = this.$refs.shorten_box_placeholder.innerText 191 this.isLogin = this.$refs.isLogin.value === "true" 192 this.useCaptcha = this.$refs.skey.value !== "" 193 if (this.useCaptcha) { 194 console.log("start recaptcha") 195 initInvisibleRecaptcha(this.$refs.skey.value, this.cutURL) 196 console.log("init success") 197 } 198 // Initialize contact form data 199 if (this.$refs.contactEmail) { 200 this.contactEmail = this.$refs.contactEmail.innerText 201 } 202 if (this.$refs.contactUsername) { 203 this.contactUsername = this.$refs.contactUsername.innerText 204 } 205 } 206}) 207 208window.onload = function () { 209 const url = new URL(window.location.href); 210 if (url.searchParams.has("url")) { 211 this.app.originalURL = url.searchParams.get("url") 212 this.app.cutURL() 213 } 214}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.