mirror of
https://github.com/Neetpone/ponepaste.git
synced 2025-03-12 06:30:07 +01:00
I dont know
This commit is contained in:
parent
7050190174
commit
22ca916daf
5 changed files with 54 additions and 51 deletions
|
@ -12,11 +12,11 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"scrivo/highlight.php": "v9.18.1.7",
|
|
||||||
"ext-pdo": "*",
|
"ext-pdo": "*",
|
||||||
"ext-openssl": "*",
|
"ext-openssl": "*",
|
||||||
"erusev/parsedown": "^1.7",
|
|
||||||
"ext-gd": "*",
|
"ext-gd": "*",
|
||||||
"ext-mbstring": "*"
|
"ext-mbstring": "*",
|
||||||
|
"scrivo/highlight.php": "v9.18.1.7",
|
||||||
|
"erusev/parsedown": "^1.7"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
27
js/dom.js
Normal file
27
js/dom.js
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
const $ = function(selector) {
|
||||||
|
return document.querySelector(selector);
|
||||||
|
};
|
||||||
|
|
||||||
|
const $$ = function(selector) {
|
||||||
|
return document.querySelectorAll(selector) || [];
|
||||||
|
};
|
||||||
|
|
||||||
|
const makeEl = function(html) {
|
||||||
|
const template = document.createElement('template');
|
||||||
|
|
||||||
|
template.innerHTML = html.trim();
|
||||||
|
|
||||||
|
return template.content.firstChild;
|
||||||
|
};
|
||||||
|
|
||||||
|
const escape = function(unsafe) {
|
||||||
|
return unsafe
|
||||||
|
.replace(/&/g, "&")
|
||||||
|
.replace(/</g, "<")
|
||||||
|
.replace(/>/g, ">")
|
||||||
|
.replace(/"/g, """)
|
||||||
|
.replace(/'/g, "'");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export { $, $$, makeEl, escape };
|
25
js/main.js
25
js/main.js
|
@ -1,17 +1,14 @@
|
||||||
import { TagsInput } from './tag_input';
|
import { $$ } from './dom';
|
||||||
|
import { TagsInput } from "./tag_input";
|
||||||
|
|
||||||
class Meme {
|
const setupSite = function() {
|
||||||
constructor() {
|
Array.prototype.forEach.call($$('.js-tag-input'), (el) => {
|
||||||
alert('xss');
|
new TagsInput(el).attach();
|
||||||
}
|
});
|
||||||
|
};
|
||||||
|
|
||||||
meme() {
|
if (document.readyState !== 'loading') {
|
||||||
console.log('meme');
|
setupSite();
|
||||||
}
|
} else {
|
||||||
|
document.addEventListener('DOMContentLoaded', setupSite);
|
||||||
}
|
}
|
||||||
|
|
||||||
const meme = new Meme();
|
|
||||||
|
|
||||||
meme.meme();
|
|
||||||
|
|
||||||
new TagsInput(null);
|
|
|
@ -1,19 +1,4 @@
|
||||||
function htmlToElement(html) {
|
import { makeEl, escape } from "./dom";
|
||||||
const template = document.createElement('template');
|
|
||||||
|
|
||||||
template.innerHTML = html.trim();
|
|
||||||
|
|
||||||
return template.content.firstChild;
|
|
||||||
}
|
|
||||||
|
|
||||||
function escapeHtml(unsafe) {
|
|
||||||
return unsafe
|
|
||||||
.replace(/&/g, "&")
|
|
||||||
.replace(/</g, "<")
|
|
||||||
.replace(/>/g, ">")
|
|
||||||
.replace(/"/g, """)
|
|
||||||
.replace(/'/g, "'");
|
|
||||||
}
|
|
||||||
|
|
||||||
class TagsInput {
|
class TagsInput {
|
||||||
constructor(element, options = {}) {
|
constructor(element, options = {}) {
|
||||||
|
@ -29,12 +14,19 @@ class TagsInput {
|
||||||
attach() {
|
attach() {
|
||||||
this.element.style.display = 'none';
|
this.element.style.display = 'none';
|
||||||
|
|
||||||
this.containerNode = htmlToElement('<div class="tags-input"></div>');
|
this.containerNode = makeEl('<div class="tags-input"></div>');
|
||||||
this.inputNode = htmlToElement('<input class="input" type="text" placeholder="10 tags maximum" value="" />');
|
this.inputNode = makeEl('<input class="input" type="text" placeholder="10 tags maximum" value="" />');
|
||||||
this.containerNode.appendChild(this.inputNode);
|
this.containerNode.appendChild(this.inputNode);
|
||||||
|
|
||||||
this.element.parentNode.insertBefore(this.containerNode, this.element.nextSibling);
|
this.element.parentNode.insertBefore(this.containerNode, this.element.nextSibling);
|
||||||
|
|
||||||
|
/* Load existing tags from input */
|
||||||
|
if (this.element.value) {
|
||||||
|
for (const tag of this.element.value.split(',')) {
|
||||||
|
this.addTag(tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Handle addition and removal of tags via key-presses */
|
/* Handle addition and removal of tags via key-presses */
|
||||||
this.containerNode.addEventListener('keydown', this._handleInputKeyUp.bind(this));
|
this.containerNode.addEventListener('keydown', this._handleInputKeyUp.bind(this));
|
||||||
|
|
||||||
|
@ -70,7 +62,7 @@ class TagsInput {
|
||||||
this.tags.push(tagValue.toLowerCase());
|
this.tags.push(tagValue.toLowerCase());
|
||||||
|
|
||||||
this.inputNode.parentNode.insertBefore(
|
this.inputNode.parentNode.insertBefore(
|
||||||
htmlToElement('<span class="tag is-info" data-value="' + escapeHtml(tagValue) + '">' + escapeHtml(tagValue) + '<span class="delete is-small" /></span>'),
|
makeEl('<span class="tag is-info" data-value="' + escape(tagValue) + '">' + escape(tagValue) + '<span class="delete is-small" /></span>'),
|
||||||
this.inputNode
|
this.inputNode
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -109,4 +101,4 @@ class TagsInput {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { TagsInput };
|
export { TagsInput };
|
||||||
|
|
|
@ -1,16 +1,4 @@
|
||||||
<link rel="stylesheet" href="theme/bulma/css/bulma-tagsinput.min.css"/>
|
<link rel="stylesheet" href="theme/bulma/css/bulma-tagsinput.min.css"/>
|
||||||
<script src="/js/tag_input.js"></script>
|
|
||||||
<script>
|
|
||||||
function setupTagsInput() {
|
|
||||||
new TagsInput(document.getElementById('tags-with-source')).attach();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (document.readyState !== 'loading') {
|
|
||||||
setupTagsInput();
|
|
||||||
} else {
|
|
||||||
document.addEventListener('DOMContentLoaded', setupTagsInput);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<main class="bd-main">
|
<main class="bd-main">
|
||||||
<div class="bd-side-background"></div>
|
<div class="bd-side-background"></div>
|
||||||
<div class="bd-main-container container">
|
<div class="bd-main-container container">
|
||||||
|
@ -202,7 +190,7 @@
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label">Tags</label>
|
<label class="label">Tags</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<input id="tags-with-source" name="tag_input" class="input"
|
<input name="tag_input" class="input js-tag-input"
|
||||||
value="<?php echo (isset($_POST['tag_input'])) ? pp_html_escape($_POST['tag_input']) : ''; // Pre-populate if we come here on an error" ?>">
|
value="<?php echo (isset($_POST['tag_input'])) ? pp_html_escape($_POST['tag_input']) : ''; // Pre-populate if we come here on an error" ?>">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -213,7 +201,6 @@
|
||||||
|
|
||||||
|
|
||||||
<div class='row is-full'>
|
<div class='row is-full'>
|
||||||
|
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
<div class="column is-5">
|
<div class="column is-5">
|
||||||
<nav class="level">
|
<nav class="level">
|
||||||
|
|
Loading…
Add table
Reference in a new issue