Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>
- <%>Here will be page title</%>
- </title>
- <!-- fs?f=w/ -->
- <META content="text/html; charset=utf-8" http-equiv=Content-Type>
- <link rel="stylesheet" href="fs?f=w/styles/style-showthread.css">
- <!-- -->
- <script type="text/javascript">
- window.storage = {
- "ROOT_URL": "localhost:24971",
- "branch": "<%>Here will be branch of current threads, delimited by '/'</%>",
- "branch_nodes": "<%>Array of branch nodes goes here, splitten by ','</%>",
- "branch_posts": <%>JSON Array with posts goes here. Display only current page</%>,
- "page_count": <%>Amount of pages goes here</%>,
- "edit_mode": false,
- "edit_id": -1,
- "expanders": [],
- "users": {},
- "can_send": true
- };
- window.onload = function() {
- initExpanders();
- rebuildBlockquotes();
- var id = setInterval(function() {
- scrollToSelectedID();
- clearInterval(id);
- }, 1000);
- };
- function initExpanders() {
- // <div class="expander-view">
- // <div class="expander-header"></div>
- // <div class="expander-body"></div>
- // </div>
- var expanders = document.getElementsByClassName("expander-view");
- for (var i = 0; i < expanders.length; i++) {
- var expander = {
- active: false,
- c0: expanders[i].getElementsByClassName("expander-header")[0],
- c1: expanders[i].getElementsByClassName("expander-body")[0]
- };
- expander.change = function() {
- if (expander.active)
- expander.c1.style.display = "none";
- else
- expander.c1.style.display = "block";
- expander.active = !expander.active;
- };
- expander.expand = function() {
- expander.c1.style.display = "block";
- expander.active = true;
- };
- expander.collapse = collapse = function() {
- expander.c1.style.display = "none";
- expander.active = false;
- };
- expander.c0.onclick = expander.change;
- expander.collapse();
- window.storage.expanders.push(expander);
- }
- }
- function rebuildBlockquotes() {
- // <div class="blockquote">
- var blockquotes = document.getElementsByClassName("blockquote");
- for (var i = 0; i < blockquotes.length; i++) {
- var text = blockquotes[i].innerHTML;
- // Text block background
- text = blockquote(text, "REDB", "span style=\"background-color:red\"", true);
- text = blockquote(text, "GREENB", "span style=\"background-color:green\"", true);
- text = blockquote(text, "BLUEB", "span style=\"background-color:blue\"", true);
- text = blockquote(text, "YELLOWB", "span style=\"background-color:yellow\"", true);
- // Text block color
- text = blockquote(text, "RED", "span style=\"color:red\"", true);
- text = blockquote(text, "GREEN", "span style=\"color:green\"", true);
- text = blockquote(text, "BLUE", "span style=\"color:blue\"", true);
- text = blockquote(text, "YELLOW", "span style=\"color:yellow\"", true);
- // XXX: Parse BLOCKQUOTE attributes
- text = blockquote(text, "B", "b");
- text = blockquote(text, "I", "i");
- text = blockquote(text, "U", "u");
- text = blockquote(text, "H1", "h1");
- text = blockquote(text, "H2", "h2");
- text = blockquote(text, "H3", "h3");
- text = blockquote(text, "H4", "h4");
- text = blockquote(text, "H5", "h5");
- text = blockquote(text, "H6", "h6");
- text = blockquote(text, "FRAME", "iframe");
- text = blockquote(text, "IMG", "img");
- text = blockquote(text, "VIDEO", "video");
- text = blockquote(text, "AUDIO", "audio");
- text = blockquote(text, "SOURCE", "source");
- text = blockquote(text, "A", "a");
- if (blockquotechanges == 0)
- continue;
- blockquotechanges = 0;
- blockquotes[i].innerHTML = text;
- // Additional function for opening images in new tab on click
- var images = blockquotes[i].getElementsByTagName("img");
- for (j in images) {
- const image_ = images[j];
- if (typeof image_ != "object")
- continue;
- image_.setAttribute('title', 'CLICK to open');
- image_.onclick = function(e) {
- e.preventDefault();
- // if (e.ctrlKey)
- window.open(image_.src, '_blank').focus();
- };
- }
- }
- }
- var blockquotechanges = 0;
- function blockquote(string, block, tag, excludeMatch) {
- string = string.replace(new RegExp("\\[(" + block + ").*?\\]", "g"), function(match) {
- match = match.substr(1 + block.length, match.length - 2 - block.length);
- blockquotechanges++;
- return "<" + tag + (excludeMatch ? "" : match) + ">";
- });
- string = string.replace(new RegExp("\\[/(" + block + ")\\]", "g"), "</" + tag.split(" ")[0] + ">");
- return string;
- }
- function createThread() {
- var name = prompt("Enter Thread name");
- if (name != undefined && name != null && name.match(/([A-Z0-9a-zа-яА-Я])+([A-Z.0-9a-zа-яА-Я\-_() ])*/g)) {
- name = name.trim();
- var xhr = new XMLHttpRequest;
- xhr.open("GET", "/st?a=c&t=" + window.storage.branch + "&n=" + name + "&token=" + getCookie("token"), false);
- xhr.send();
- if (xhr.status != 200)
- alert(xhr.responseText);
- else
- window.location = "/st?t=" + xhr.responseText;
- } else if (name == undefined || name == null || name.length == 0) return;
- else alert("Invalid name: " + name + "\nExpected to match pattern ([A-Z0-9a-z])+([A-Z.0-9a-z\-_() ])*");
- }
- function deleteThread(e, elem, name) {
- if (name != undefined && name != null) {
- if (!e.ctrlKey)
- if (!confirm("Delete Thread " + name + "?")) return;
- name = name.trim();
- var xhr = new XMLHttpRequest;
- xhr.open("GET", "/st?a=d&t=" + window.storage.branch + "&n=" + name + "&token=" + getCookie("token"), false);
- xhr.send();
- if (xhr.status != 200)
- alert(xhr.responseText);
- else if (!e.ctrlKey)
- window.location = "/st?t=" + xhr.responseText;
- else if (e.ctrlKey) {
- elem.style.backgroundColor = "red";
- }
- }
- }
- function getUser(id) {
- var user = window.storage.users[id];
- if (user == null || user == undefined) {
- user = {};
- if (getCookie("id") == (id + "")) {
- user = {};
- user.login = getCookie("login");
- user.id = getCookie("id");
- user.is_moder = getCookie("is_moder");
- user.is_admin = getCookie("is_admin");
- user.token = getCookie("token");
- window.storage.users[id] = user;
- } else {
- var xhr = new XMLHttpRequest;
- xhr.open("GET", "/us?a=gbid&id=" + id, false);
- xhr.send();
- if (xhr.status != 200)
- console.log(xhr.responseText);
- else {
- user = {};
- var json = JSON.parse(xhr.responseText);
- user["login"] = json.login;
- user["id"] = json.id;
- user["is_moder"] = json.is_moder;
- user["is_admin"] = json.is_admin;
- user["token"] = json.token;
- window.storage.users[id] = user;
- }
- }
- }
- return user;
- }
- function deletePost(e, elem, id) {
- if (id != undefined && id != null) {
- var xhr = new XMLHttpRequest;
- xhr.open("GET", "/st?a=dp&id=" + id + "&token=" + getCookie("token"), false);
- xhr.send();
- if (xhr.status != 200)
- alert(xhr.responseText);
- else if (!e.ctrlKey)
- window.location = "/st?t=" + window.storage.branch;
- else if (e.ctrlKey) {
- elem.style.backgroundColor = "red";
- }
- }
- }
- function setCookie(cname, cvalue, exdays) {
- var d = new Date();
- d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
- var expires = "expires=" + d.toUTCString();
- document.cookie = cname + "=" + cvalue + "; " + expires;
- }
- function getCookie(cname) {
- var name = cname + "=";
- var ca = document.cookie.split(';');
- for (var i = 0; i < ca.length; i++) {
- var c = ca[i];
- while (c.charAt(0) == ' ') {
- c = c.substring(1);
- }
- if (c.indexOf(name) == 0) {
- return c.substring(name.length, c.length);
- }
- }
- return undefined;
- }
- (function() {
- if (getCookie("token") == undefined || getCookie("token").length == 0)
- return;
- // validate user token in background
- var xhr = new XMLHttpRequest;
- xhr.open("GET", "/us?a=v&token=" + getCookie("token"), false);
- xhr.send();
- if (xhr.status != 200)
- console.log(xhr.responseText);
- else if (xhr.responseText[0] == "0") {
- setCookie("login", "");
- setCookie("id", "id");
- setCookie("token", "");
- window.location.reload();
- }
- })();
- function scrollIntoView(eleID) {
- var e = document.getElementById(eleID);
- if (!!e && e.scrollIntoView) {
- e.scrollIntoView();
- }
- }
- function getParameter(name) {
- if (name = (new RegExp('[?&]' + encodeURIComponent(name) + '=([^&]*)')).exec(location.search))
- return decodeURIComponent(name[1]);
- }
- function scrollToSelectedID() {
- var id = getParameter("id");
- if (id != null && id != undefined && id != "")
- scrollIntoView(id);
- }
- </script>
- </head>
- <body>
- <div class="header">
- <div style="width: 100%; border: 1px solid black; text-align: right">
- <div style="display: inline-block; position: absolute; left: 1%" id="logged-as"></div>
- <input type="email" alt="login" placeholder="login" id="login">
- <input type="password" alt="password" placeholder="password" id="password">
- <input type="button" value="register" id="register-button">
- <input type="button" value="login" id="login-button">
- <input type="button" value="change password" id="change-password-button">
- </div>
- <script type="text/javascript">
- (function() {
- document.getElementById("logged-as").innerHTML += "<b>" + getCookie("login") + "</b>";
- document.getElementById("login-button").onclick = function() {
- var login = document.getElementById("login").value;
- var password = document.getElementById("password").value;
- var xhr = new XMLHttpRequest;
- xhr.open("GET", "/us?a=l&login=" + login + "&password=" + password, false);
- xhr.send();
- if (xhr.status != 200)
- alert(xhr.responseText);
- else {
- var json = JSON.parse(xhr.responseText);
- setCookie("login", json.login);
- setCookie("id", json.id);
- setCookie("is_moder", json.is_moder);
- setCookie("is_admin", json.is_admin);
- setCookie("token", json.token);
- window.location.reload();
- }
- };
- document.getElementById("register-button").onclick = function() {
- var login = document.getElementById("login").value;
- var password = document.getElementById("password").value;
- var xhr = new XMLHttpRequest;
- xhr.open("GET", "/us?a=r&login=" + login + "&password=" + password, false);
- xhr.send();
- if (xhr.status != 200)
- alert(xhr.responseText);
- else {
- var json = JSON.parse(xhr.responseText);
- setCookie("login", json.login);
- setCookie("id", json.id);
- setCookie("is_moder", json.is_moder);
- setCookie("is_admin", json.is_admin);
- setCookie("token", json.token);
- window.location.reload();
- }
- };
- document.getElementById("change-password-button").onclick = function() {
- var password = document.getElementById("password").value;
- var xhr = new XMLHttpRequest;
- xhr.open("GET", "/us?a=cp&password=" + password + "&token=" + getCookie("token"), false);
- xhr.send();
- if (xhr.status != 200)
- alert(xhr.responseText);
- else {
- var json = JSON.parse(xhr.responseText);
- setCookie("login", json.login);
- setCookie("id", json.id);
- setCookie("is_moder", json.is_moder);
- setCookie("is_admin", json.is_admin);
- setCookie("token", json.token);
- window.location.reload();
- }
- };
- })();
- </script>
- <div class="header-subsection" id="branch"></div>
- <script type="text/javascript">
- (function() {
- var elem = document.getElementById("branch");
- var parts = window.storage.branch.split("\/");
- window.storage.cur_node = parts[parts.length - 1];
- for (var i = 0; i < parts.length; i++) {
- if (i == 0)
- elem.innerHTML += "<a href=\"/st?t=/\">$</a>";
- elem.innerHTML += " / ";
- var url = "/st?t=";
- for (var j = 0; j < i + 1; j++) {
- url += "/";
- url += parts[j];
- }
- var link = document.createElement(i == parts.length - 1 ? "b" : "a");
- link.setAttribute("href", url);
- link.innerHTML = parts[i];
- elem.appendChild(link);
- }
- })();
- </script>
- <div class="h-splitter"></div>
- <div class="header-subsection">
- <div class="expander-view">
- <div class="expander-header" id="branch-expander-header"></div>
- <div class="h-splitter"></div>
- <div class="expander-body" id="branch-expander-body">
- </div>
- <script type="text/javascript">
- (function() {
- document.getElementById("branch-expander-header").innerHTML = "/" + window.storage.cur_node + " =>";
- var body = document.getElementById("branch-expander-body");
- if (!(getCookie("token") == "" || getCookie("token") == undefined))
- body.innerHTML += '<div onclick="createThread()">+ Thread</div>';
- if (window.storage.branch_nodes.length == 0)
- return;
- window.storage.nodes_t = window.storage.branch_nodes.split(",");
- window.storage.nodes = [];
- for (var i = 0; i < window.storage.nodes_t.length; i++)
- window.storage.nodes[i] = window.storage.nodes_t[i].split("/");
- for (var i = 0; i < window.storage.nodes.length; i++) {
- var url = (window.storage.branch.endsWith("/") ? window.storage.branch.substr(0, window.storage.branch.length - 1) : window.storage.branch);
- url += "/" + window.storage.nodes[i][0].trim();
- var link = document.createElement("a");
- link.setAttribute("href", "/st?t=" + (url.startsWith("/") ? url : ("/" + url)));
- link.innerHTML = "/" + window.storage.nodes[i][0].trim();
- body.appendChild(link);
- if (getCookie("is_admin") == 1 || getCookie("id") == window.storage.nodes[i][1])
- body.innerHTML += ' <a class="delete" onclick="deleteThread(event, this,\'' + window.storage.nodes[i][0] + '\')">(delete)</a>'
- if (i < window.storage.nodes.length - 1)
- body.appendChild(document.createElement("div"));
- }
- })();
- </script>
- </div>
- <div style="border: 1px solid black; display: inline-block; width: 100%" id="pages0"></div>
- <div style="width: 100%; border: 1px solid black; text-align: center" onclick="window.scrollTo(0, document.body.scrollHeight);">↓↓↓ на дно ↓↓↓</div>
- </div>
- </div>
- <br>
- <div class="content" id="content-block"></div>
- <script type="text/javascript">
- function editPost(event, post_id) {
- window.storage.edit_mode = true;
- window.storage.edit_id = post_id;
- document.getElementById("post-text").value = window.storage.posts_by_id[post_id].message;
- document.getElementById("post-text").focus();
- }
- (function() {
- var elem = document.getElementById("content-block");
- window.storage.posts_by_id = {};
- for (var i = 0; i < window.storage.branch_posts.length; i++) {
- window.storage.posts_by_id[window.storage.branch_posts[i].id] = window.storage.branch_posts[i];
- var post = window.storage.branch_posts[i];
- var innerHTML = '<div class="h-splitter"></div>';
- innerHTML += '<div class="post-header">'; // Post header data hoes here:
- innerHTML += '<b>' + getUser(post.author_id).login + '</b> ';
- var d = new Date(post.date),
- dformat = [d.getMonth() + 1,
- d.getDate(),
- d.getFullYear()
- ].join('/') + ' ' + [d.getHours(),
- d.getMinutes(),
- d.getSeconds()
- ].join(':');
- innerHTML += '<div style="display:inline-block" id=\"' + post.id + '\"><i>' + dformat + '</i></div> ';
- innerHTML += '<div style="display:inline-block"><a href="/st?a=pid&id=' + post.id + '"><b>#' + post.id + '</b></a></div> ';
- if (getCookie("is_moder") == 1 || getCookie("is_admin") == 1 || post.author_id == getCookie("id")) {
- innerHTML += '<div class="delete" style="display:inline-block" onclick="deletePost(event, this, ' + post.id + ')">(delete)</div>';
- innerHTML += '<div class="edit" style="display:inline-block" onclick="editPost(event, ' + post.id + ')">(edit)</div>';
- }
- innerHTML += '</div>';
- innerHTML += '<br>';
- innerHTML += '<div class="blockquote"><pre>' + post.message + '</pre></div>';
- elem.innerHTML += innerHTML;
- }
- })();
- </script>
- <div style="width: 100%; border: 1px solid black; text-align: center" onclick="window.scrollTo(0, 0);">↑↑↑ с дна ↑↑↑</div>
- <br>
- <div class="post-writer">
- <script type="text/javascript">
- function insertImage() {
- var url = prompt("Paste image URL here");
- if (url == null || url == undefined || url.length == 0)
- return;
- insertText("[IMG width=300 src=\"" + url + "\"]", true);
- }
- function insertVideo() {
- var url = prompt("Paste video URL here");
- if (url == null || url == undefined || url.length == 0)
- return;
- insertText("[VIDEO controls][SOURCE src=\"" + url + "\" type=\"" + (url.endsWith("mp4") ? "video/mp4" : (url.endsWith("webm") ? "video/webm" : (url.endsWith("ogg") ? "video/ogg" : ""))) + "\"][/VIDEO]", true);
- }
- function insertYoutube() {
- var url = prompt("Paste youtube video URL here");
- if (url == null || url == undefined || url.length == 0)
- return;
- var url_split = url.split("/");
- var url_split = url_split[url_split.length - 1].split("=");
- insertText("[FRAME width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/" + url_split[url_split.length - 1] + "\" frameborder=\"0\" allowfullscreen]", true);
- }
- function insertCoub() {
- var url = prompt("Paste youtube video URL here");
- if (url == null || url == undefined || url.length == 0)
- return;
- var url_split = url.split("/");
- insertText("[FRAME width=\"400\" height=\"224\" src=\"https://coub.com/embed/" + url_split[url_split.length - 1] + "?muted=false&autostart=false&originalSize=false&startWithHD=false\" frameborder=\"0\" allowfullscreen]", true);
- }
- function insertAudio() {
- var url = prompt("Paste audio URL here");
- if (url == null || url == undefined || url.length == 0)
- return;
- insertText("[AUDIO controls][SOURCE src=\"" + url + "\" type=\"" + (url.endsWith("mp3") ? "audio/mpeg" : (url.endsWith("ogg") ? "audio/ogg" : (url.endsWith("wav") ? "audio/wav" : ""))) + "\"][/AUDIO]", true);
- }
- function insertIFrame() {
- var url = prompt("Paste frame URL here");
- if (url == null || url == undefined || url.length == 0)
- return;
- insertText("[FRAME src=\"" + url + "\"]", true);
- }
- function insertURL() {
- var url = prompt("Paste URL here");
- if (url == null || url == undefined || url.length == 0)
- return;
- var url_split = url.split("/");
- insertText("[A href=\"" + url + "\"]" + url_split[url_split.length - 1] + "[/A]", true);
- }
- function insertPostID() {
- var id = prompt("Paste post id here");
- if (id == null || id == undefined || id.length == 0 || !(/[0-9]/g.test(id)))
- return;
- insertText('[A href="/st?a=pid&id=' + id + '"]#' + id + '[/A]', true);
- }
- function uploadFile() {
- if (!window.storage.can_send)
- alert("Wait till file will be uploaded");
- pickAndUploadFile("*", function() {
- console.log("shit");
- document.getElementById("upload-status").innerHTML = "uploaded";
- var url_split = window.storage.lastUpload.split("=");
- url_split = url_split[url_split.length - 1].split("/");
- url_split = url_split[url_split.length - 1];
- insertText("[A href=\"/fs?f=/u/" + url_split + "\"]" + url_split + "[/A]", true);
- });
- }
- function uploadImage() {
- if (!window.storage.can_send)
- alert("Wait till file will be uploaded");
- pickAndUploadFile("image/jpeg,image/png,image/gif", function() {
- console.log("shit");
- document.getElementById("upload-status").innerHTML = "uploaded";
- var url_split = window.storage.lastUpload.split("=");
- url_split = url_split[url_split.length - 1].split("/");
- url_split = url_split[url_split.length - 1];
- insertText("[IMG width=300 src=\"/fs?f=/u/" + url_split + "\" alt=\"" + url_split + "\"]", true);
- });
- }
- function pickAndUploadFile(mime_type, success) {
- if (!window.storage.can_send)
- alert("Wait till file will be uploaded");
- document.getElementById("input_file").accept = mime_type;
- document.getElementById("input_file").onchange = function() {
- if (this.value == null || this.value == undefined || this.value == "")
- return;
- if (this.value.size / 1024 / 1024 > 24)
- alert("File too large");
- var xhr = new XMLHttpRequest();
- var file = document.getElementById("input_file").files[0];
- var fileName = this.value;
- var target = "/fs?u=" + randomString(40) + "." + fileName.substring(fileName.indexOf('.') + 1, fileName.length) || fileName;
- window.storage.lastUpload = target;
- var mimeType = "application/x-www-form-urlencoded";
- window.storage.can_send = false;
- xhr.open('POST', target, true);
- xhr.setRequestHeader('Content-Type', mimeType);
- xhr.setRequestHeader('Content-Disposition', 'attachment; filename="' + encodeURIComponent(fileName) + '"');
- xhr.upload.onprogress = function(event) {
- window.storage.can_send = event.loaded >= event.total;
- if (event.loaded < event.total)
- document.getElementById("upload-status").innerHTML = (event.loaded / event.total * 100) + "%";
- };
- xhr.onload = function() {
- window.storage.can_send = true;
- if (this.status == 200)
- success(this, fileName);
- else
- document.getElementById("upload-status").innerHTML = "error " + this.status;
- }
- xhr.onerror = function() {
- document.getElementById("upload-status").innerHTML = "error " + this.status;
- };
- window.storage.can_send = false;
- xhr.send(file);
- };
- document.getElementById("input_file").click();
- }
- function randomString(size) {
- var text = "";
- var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_";
- for (var i = 0; i < size; i++)
- text += possible.charAt(Math.floor(Math.random() * possible.length));
- return text;
- }
- function insert(block) {
- insertText("[" + block + "]", true);
- insertText("[/" + block + "]", false);
- }
- function insertText(text, moveToEnd) {
- var textfield = document.getElementById("post-text");
- var cursor = textfield.selectionStart;
- var left = textfield.value.substr(0, cursor);
- var right = textfield.value.substr(cursor, textfield.value.length - cursor);
- textfield.value = left + text + right;
- textfield.focus();
- if (moveToEnd) {
- textfield.selectionStart = cursor + text.length;
- textfield.selectionEnd = cursor + text.length;
- } else {
- textfield.selectionStart = cursor;
- textfield.selectionEnd = cursor;
- }
- }
- </script>
- <div style="border: 1px solid black; width: 100%">
- <div class="insert" onclick="insertImage()">+ IMAGE</div>
- <div class="insert" onclick="insertVideo()">+ VIDEO</div>
- <div class="insert" onclick="insertYoutube()">+ YOUTUBE</div>
- <div class="insert" onclick="insertCoub()">+ COUB</div>
- <div class="insert" onclick="insertAudio()">+ AUDIO</div>
- <div class="insert" onclick="insertIFrame()">+ FRAME</div>
- <div class="insert" onclick="insertURL()">+ URL</div>
- <div class="insert" onclick="uploadFile()">UPLOAD FILE</div>
- <div class="insert" onclick="uploadImage()">UPLOAD IMAGE</div>
- <div class="insert" onclick="insertPostID()">+ POST ID</div>
- <div class="insert" onclick="insert('DIV')">+ DIV</div>
- <div class="insert" onclick="insert('B')">+ BOLD</div>
- <div class="insert" onclick="insert('I')">+ ITALIC</div>
- <div class="insert" onclick="insert('U')">+ UNDERLINE</div>
- <div class="insert" onclick="insert('H1')">+ H1</div>
- <div class="insert" onclick="insert('H2')">+ H2</div>
- <div class="insert" onclick="insert('H3')">+ H3</div>
- <div class="insert" onclick="insert('H4')">+ H4</div>
- <div class="insert" onclick="insert('H5')">+ H5</div>
- <div class="insert" onclick="insert('H6')">+ H6</div>
- <div class="insert" onclick="uploadFile">+ H6</div>
- <div id="upload-status"></div>
- <input type="file" style="display: none" id="input_file">
- </div>
- <textarea id="post-text" style="width:100%; height:10rem"></textarea>
- <div align="right"><input type="button" value="submit" id="post-send"></div>
- <script type="text/javascript">
- (function() {
- var post_send = document.getElementById("post-send");
- post_send.onclick = function(event) {
- if (!window.storage.can_send)
- alert("Wait untill file load");
- var post_text = document.getElementById("post-text").value;
- var xhr = new XMLHttpRequest;
- if (window.storage.edit_mode)
- xhr.open("GET", "/st?a=ep&id=" + window.storage.edit_id + "&m=" + encodeURIComponent(post_text) + "&token=" + getCookie("token"), false);
- else
- xhr.open("GET", "/st?a=wp&t=" + window.storage.branch + "&m=" + encodeURIComponent(post_text) + "&token=" + getCookie("token"), false);
- xhr.send();
- if (xhr.status != 200)
- alert(xhr.responseText);
- else if (!event.ctrlKey)
- window.location = "/st?a=pid&id=" + xhr.responseText;
- else
- post_send.style.backgroundColor = "red";
- };
- })();
- </script>
- </div>
- <br>
- <div style="border: 1px solid black; display: inline-block; width: 100%" id="pages1"></div>
- <script type="text/javascript">
- (function() {
- var elem0 = document.getElementById("pages0");
- var elem1 = document.getElementById("pages1");
- for (var i = 0; i < window.storage.page_count; i++) {
- elem0.innerHTML += '<a href="st?t=' + window.storage.branch + '&p=' + i + '">' + i + '</a>';
- elem1.innerHTML += '<a href="st?t=' + window.storage.branch + '&p=' + i + '">' + i + '</a>';
- if (i < window.storage.page_count - 1) {
- elem0.innerHTML += ', ';
- elem1.innerHTML += ', ';
- }
- }
- })();
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement