Browse code

Add titles to the posts

Dario Rodriguez authored on 08/07/2014 11:34:03
Showing 1 changed files
... ...
@@ -2,24 +2,31 @@
2 2
 "use strict";
3 3
 
4 4
 function request(querytext, func, errorfunc) {
5
-	var req = new XMLHttpRequest();
6
-	req.onreadystatechange = function() {
7
-		if (req.readyState !== 4) {
8
-			return;
9
-		}
10
-		if (req.status !== 200) {
11
-			errorfunc();
12
-			return;
13
-		}
14
-		func(req.responseText);
15
-	};
16
-	req.open("GET",querytext);
17
-	req.send();
5
+        var req = new XMLHttpRequest();
6
+        req.onreadystatechange = function() {
7
+                if (req.readyState !== 4) {
8
+                        return;
9
+                }
10
+                if (req.status !== 200) {
11
+                        errorfunc();
12
+                        return;
13
+                }
14
+                func(req.responseText);
15
+        };
16
+        req.open("GET",querytext);
17
+        req.send();
18 18
 }
19 19
 
20 20
 donewpost.onclick = function(e) {
21
-	request("/newpost"+window.location.search+"&t="+encodeURIComponent(document.getElementById("wysihtml5-editor").value),function(r) {
22
-		window.location="/posts.html"+window.location.search;},function() {});
21
+        var requri=[];
22
+        requri.push("/newpost");
23
+        requri.push(window.location.search);
24
+        requri.push("&h=");
25
+        requri.push(encodeURIComponent(document.getElementById("title").value));
26
+        requri.push("&t=");
27
+        requri.push(encodeURIComponent(document.getElementById("wysihtml5-editor").value));
28
+        request(requri.join(""),function(r) {
29
+                window.location="/posts.html"+window.location.search;},function() {});
23 30
 };
24 31
 
25 32
 }());
Browse code

post fixes

Dario Rodriguez authored on 26/06/2014 23:00:40
Showing 1 changed files
... ...
@@ -19,7 +19,7 @@ function request(querytext, func, errorfunc) {
19 19
 
20 20
 donewpost.onclick = function(e) {
21 21
 	request("/newpost"+window.location.search+"&t="+encodeURIComponent(document.getElementById("wysihtml5-editor").value),function(r) {
22
-		window.location="/posts.html"+window.location.search+"&n=r";},function() {});
22
+		window.location="/posts.html"+window.location.search;},function() {});
23 23
 };
24 24
 
25 25
 }());
Browse code

add the editor and the posts part

Dario Rodriguez authored on 26/06/2014 22:41:33
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,25 @@
1
+(function () {
2
+"use strict";
3
+
4
+function request(querytext, func, errorfunc) {
5
+	var req = new XMLHttpRequest();
6
+	req.onreadystatechange = function() {
7
+		if (req.readyState !== 4) {
8
+			return;
9
+		}
10
+		if (req.status !== 200) {
11
+			errorfunc();
12
+			return;
13
+		}
14
+		func(req.responseText);
15
+	};
16
+	req.open("GET",querytext);
17
+	req.send();
18
+}
19
+
20
+donewpost.onclick = function(e) {
21
+	request("/newpost"+window.location.search+"&t="+encodeURIComponent(document.getElementById("wysihtml5-editor").value),function(r) {
22
+		window.location="/posts.html"+window.location.search+"&n=r";},function() {});
23
+};
24
+
25
+}());