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); }
public static string ResolveRequest(string request) { if (request == prevRequest) { Console.WriteLine("Same request"); return(HTMLManager.GetMemeHTMLPage("memes"));; } int m = 0; if (int.TryParse(request, out m)) { //return "memeID="+m; } request = WebUtility.UrlDecode(request); Console.WriteLine(request); if (new List <string>(BaseManager.getGenresNames()).Contains(request)) { return(HTMLManager.GetMemesHTML(request)); } if (request.StartsWith("memeName")) { string[] args = request.Split('&'); List <string> genres = new List <string>(); string link = ""; string lyrics = ""; string name = ""; foreach (var item in args) { if (item.Contains("memeLink=")) { link = item.Replace("memeLink=", ""); } if (item.Contains("memeName=")) { name = item.Replace("memeName=", ""); } if (item.Contains("lyrics=")) { lyrics = item.Replace("lyrics=", ""); } if (item.Contains("genre=")) { genres.Add(item.Replace("genre=", "").Replace("+", " ")); } } Create(name, link, genres.ToArray(), lyrics); } else if (request.EndsWith("Button=")) { string s = ""; s = request.Replace("Button=", ""); s = s.Replace("+", " "); return(GoToGenre(s)); } else if (request.StartsWith("deleteMemeName=")) { string s = ""; s = request.Replace("deleteMemeName=", ""); Delete(s); } return(HTMLManager.GetMemeHTMLPage("memes")); //request. }