public static string GetMemesHTML(string memeClass) { string responseMemes = ""; string memeFormat = "<img src=\"{0}\" alt=\"{1}\">"; foreach (var m in BaseManager.RequestNodes($"MATCH (n:memeClass{{name:\"{memeClass}\"}})<-[]-(m:meme) RETURN m LIMIT 25")) { responseMemes += string.Format(memeFormat, m.Properties["link"], "theres no meme" /* m.Properties["lyrics"]*/); } return(responseMemes); }
public static string GetMemeHTMLPage(string memeClass = "wolf memes") { Console.WriteLine("send page with " + memeClass); string js = "\n" + "<script type=\"text/javascript\">" + "let buttonCountMinus = document.getElementById(\"buttonCountMinus\");" + "let count = document.getElementById(\"buttonCountNumber\");" + "let count2 = document.getElementById(\"num\");let number = 1;let price = 350;" + "function httpGet1(data){ var http = new XMLHttpRequest();var url = 'http://localhost:8888/';http.open('GET', url, true);http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');" + "http.onreadystatechange = function() { if (http.readyState == 4 && http.status == 200) { alert('ready',http.responseText) } }\n" + "http.send(data); alert(http.responseText);}; let buttonCountPlus = document.getElementById(\"buttonCountPlus\");" + "function httpGet(data){ var xmlHttp = new XMLHttpRequest(); xmlHttp.onreadystatechange = function () { if (xmlHttp.readyState == 4 && xmlHttp.status == 200) { document.getElementById(\"output\").innerHTML=xmlHttp.responseText; } }; xmlHttp.open('POST', 'http://localhost:8888/', true); xmlHttp.send(data); alert(xmlHttp.responseText);} " + "buttonCountPlus.onclick = function() { if (number <= 3) { number++; count.innerHTML = number; count2.value = number * price; httpGet1(number) } };" + " buttonCountMinus.onclick = function() { if (number >= 2) { number--; count.innerHTML = number; count2.value = number * price; httpGet(); } };" + "\n</script>\n"; string responseStart = "<html><head><meta charset='utf8'><title>Meme page</title></head><body>Привет мир!"; string inputField = "<p><input type=\"text\" id=\"mainMemeInput\"> <button id=\"find\" onclick=\"find()\">find</button></p>"; string headerField = "<input type=\"button\" id=\"buttonCountPlus\" value=\" + \">" + "<input type = \"button\" id = \"buttonCountMinus\" value = \"-\" >" + "<div id = \"buttonCountNumber\" > 1 </div >" + "<input type = \"hidden\" value = \"1\" id = \"num\" name = \"num\" > "; string inputField2 = "<form method=\"POST\" action=\"http://localhost:8888/connection?post=gggkkk/\">" + " <p> Текст:<br><textarea name = \"message\"></textarea></p>" + " <p><button type = \"submit\"> Отправить </button></p>" + " </form> "; string ing3 = "<form method=\"POST\" name=\"authorization\" action=\"http://localhost:8888/connection\"> " + "<form action=\"\" method=\"POST\">" + CreateInputField("Удалить", "deleteMemeName") + "<br><br><br><br>" + "</form>" + CreateInputField("Название", "memeName") + "<br>" + CreateInputField("Ссылка", "memeLink") + "<br>" + CreateInputField("Текст", "lyrics") + "<br>" + CreateSelector("selectorOFGenres", "genre", BaseManager.getGenresNames(), true) + " <input type = \"submit\" value = \"Cоздать\">" + " </form> "; string responseEnd = "</body></html>"; string memeClasses = "meme classes:: "; memeClasses += "\n";//"<form action=\"\" method=\"POST\">"; foreach (var g in BaseManager.RequestNodes("match (n:memeClass) return n")) { memeClasses += //"<form action=\"\" method=\"POST\">"+ $"<button name = \"{g.Properties["name"] + "Button"}\" getThisMemeGenre=\"{g.Properties["name"]}\" onclick=\"httpGet('{g.Properties["name"]}')\"> {g.Properties["name"]} </button>"; // Console.WriteLine(g.Properties["name"]); } memeClasses += "\n";// "</form>"; string responseStr = responseStart + headerField + ing3 + memeClasses + "<br>" + "<div id='output'>" + GetMemesHTML(memeClass) + "</div>" + js + responseEnd; return(responseStr); }