FeedMonkey HTML5 RSS Feed Reader

Check-in [0b9f3fb4e1]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Streamline the login var references
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/clean | trunk | master
Files: files | file ages | folders
SHA3-256:0b9f3fb4e136a3ae72c4ec133aa20c37a898f1dc220ae08ea15b7c0d8660fa97
User & Date: vandys 2019-03-02 14:52:25
Context
2019-03-02
16:28
Move to ES6 classes. Tidy some control flow. Use let/const where appropriate. Move to 4-space indentation. Normalize "if (...)" spacing. check-in: 50e5705971 user: vandys tags: origin/clean, trunk, master
14:52
Streamline the login var references check-in: 0b9f3fb4e1 user: vandys tags: origin/clean, trunk, master
2019-03-01
14:36
Start streamlining id refs check-in: 270e670bdb user: vandys tags: origin/clean, trunk, master
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to index.html.

66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
      </p>
      <p class="backends">
        <label class="button"><input type="radio" name="backend" value="TinyTinyRSS" checked="checked" /> Tiny Tiny RSS</label>
        <label class="button"><input type="radio" name="backend" value="OwnCloud" /> ownCloud News</label>
        <label class="button"><input type="radio" name="backend" value="Pond" /> Pond</label>
      </p>
      <p>
        <label for="url">URL:</label>
        <input class="button" type="text" name="url" id="url" value="" placeholder="http://example.com/tt-rss/" x-inputmode="verbatim" autocorrect="off" />
        <label for="un">Username:</label>
        <input class="button" type="text" name="user" id="un" value="" placeholder="username" x-inputmode="verbatim" autocorrect="off" />          
        <label for="pw">Password:</label>
        <input class="button" type="password" name="pass" id="pw" value="" placeholder="password" x-inputmode="verbatim" autocorrect="off" />      
      </p>
      <p>
        <button class="button" type="submit">Sign in</button>
      </p>
    </form>
  </article>
</section>







|
|
|
|
|
|







66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
      </p>
      <p class="backends">
        <label class="button"><input type="radio" name="backend" value="TinyTinyRSS" checked="checked" /> Tiny Tiny RSS</label>
        <label class="button"><input type="radio" name="backend" value="OwnCloud" /> ownCloud News</label>
        <label class="button"><input type="radio" name="backend" value="Pond" /> Pond</label>
      </p>
      <p>
        <label for="formurl">URL:</label>
        <input class="button" type="text" id="formurl" value="" placeholder="http://example.com/tt-rss/" x-inputmode="verbatim" autocorrect="off" />
        <label for="formun">Username:</label>
        <input class="button" type="text" id="formun" value="" placeholder="username" x-inputmode="verbatim" autocorrect="off" />          
        <label for="formpw">Password:</label>
        <input class="button" type="password" id="formpw" value="" placeholder="password" x-inputmode="verbatim" autocorrect="off" />      
      </p>
      <p>
        <button class="button" type="submit">Sign in</button>
      </p>
    </form>
  </article>
</section>

Changes to js/Login.js.

17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
..
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
..
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
..
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
...
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140

Login.prototype.log_in = function() {
	this.app.changeToPage("#login");
	$("#login form").backend.forEach(function(o, i) {
		o.addEventListener("change", function(e) {
			if(e.target.checked) {
				if(e.target.value == "OwnCloud") {
					$("#url").placeholder = "http://example.com/owncloud/";
				} else if(e.target.value == "Pond") {
					$("#url").placeholder = "http://example.com/pond/";
				} else {
					$("#url").placeholder = "http://example.com/tt-rss/";
				}
			}
		});
	});
	$("#login form").addEventListener('submit', this.authenticate.bind(this));
};

................................................................................
	e.preventDefault();
 	e.stopPropagation();

 	var backend = "TinyTinyRSS";
 	if($("#login form").backend[1].checked) backend = "OwnCloud";
 	else if($("#login form").backend[2].checked) backend = "Pond";

	var server_url = $("#url").value;
	var user = $("#un").value;
	var password = $("#pw").value;

	if(!this.onLine()) {
		alert("You need to be on line to log in to your server.");
		return false;
	}

	var errs = [];
................................................................................
				var auth = btoa(user + ':' + password);
				localStorage.server_url = server_url;
                                localStorage.username = user;
				localStorage.session_id = auth;
				localStorage.backend = "OwnCloud";
				_this.app.after_login(localStorage.backend);

				$("#url").value = "";
				$("#un").value = "";
				$("#pw").value = "";
			} else {
				alert("Something went wrong, please check every input field and try again.");
			}
		});
	} else if(backend == "Pond") {

		Pond.login(server_url, user, password, function(data) {
................................................................................
			if(data.session_token) {
				localStorage.server_url = server_url;
                                localStorage.username = user;
				localStorage.session_id = data.session_token;
				localStorage.backend = "Pond";
				_this.app.after_login(localStorage.backend);

				$("#url").value = "";
				$("#un").value = "";
				$("#pw").value = "";
			}
		});

	} else {
		TinyTinyRSS.login(server_url, user, password, function(data) {
			if(data.error) {
				if(data.error == "API_DISABLED") {
................................................................................
			} else {
				localStorage.server_url = server_url;
                                localStorage.username = user;
				localStorage.session_id = data.session_id;
				localStorage.backend = "TinyTinyRSS";
				_this.app.after_login(localStorage.backend);
				
				$("#url").value = "";
				$("#un").value = "";
				$("#pw").value = "";
			}
		});
	}

	return false;
};

Login.prototype.fillLoginFormFromLocalStorage = function() {
        var serverUrl = localStorage.server_url;
        if (serverUrl) {
            $("#url").value = serverUrl;
        }
        var userName = localStorage.username;
        if (userName) {
            $("#un").value = userName;
        }
        var backendName = localStorage.backend;
        if (backendName === "TinyTinyRSS") {
            $("#login form").backend[0].checked = true;
        }
        else if (backendName === "OwnCloud") {
            $("#login form").backend[1].checked = true;







|

|

|







 







|
|
|







 







|
|
|







 







|
|
|







 







|
|
|










|



|







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
..
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
..
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
..
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
...
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140

Login.prototype.log_in = function() {
	this.app.changeToPage("#login");
	$("#login form").backend.forEach(function(o, i) {
		o.addEventListener("change", function(e) {
			if(e.target.checked) {
				if(e.target.value == "OwnCloud") {
					formurl.placeholder = "http://example.com/owncloud/";
				} else if(e.target.value == "Pond") {
					formurl.placeholder = "http://example.com/pond/";
				} else {
					formurl.placeholder = "http://example.com/tt-rss/";
				}
			}
		});
	});
	$("#login form").addEventListener('submit', this.authenticate.bind(this));
};

................................................................................
	e.preventDefault();
 	e.stopPropagation();

 	var backend = "TinyTinyRSS";
 	if($("#login form").backend[1].checked) backend = "OwnCloud";
 	else if($("#login form").backend[2].checked) backend = "Pond";

	var server_url = formurl.value;
	var user = formun.value;
	var password = formpw.value;

	if(!this.onLine()) {
		alert("You need to be on line to log in to your server.");
		return false;
	}

	var errs = [];
................................................................................
				var auth = btoa(user + ':' + password);
				localStorage.server_url = server_url;
                                localStorage.username = user;
				localStorage.session_id = auth;
				localStorage.backend = "OwnCloud";
				_this.app.after_login(localStorage.backend);

				formurl.value = "";
				formun.value = "";
				formpw.value = "";
			} else {
				alert("Something went wrong, please check every input field and try again.");
			}
		});
	} else if(backend == "Pond") {

		Pond.login(server_url, user, password, function(data) {
................................................................................
			if(data.session_token) {
				localStorage.server_url = server_url;
                                localStorage.username = user;
				localStorage.session_id = data.session_token;
				localStorage.backend = "Pond";
				_this.app.after_login(localStorage.backend);

				formurl.value = "";
				formun.value = "";
				formpw.value = "";
			}
		});

	} else {
		TinyTinyRSS.login(server_url, user, password, function(data) {
			if(data.error) {
				if(data.error == "API_DISABLED") {
................................................................................
			} else {
				localStorage.server_url = server_url;
                                localStorage.username = user;
				localStorage.session_id = data.session_id;
				localStorage.backend = "TinyTinyRSS";
				_this.app.after_login(localStorage.backend);
				
				formurl.value = "";
				formun.value = "";
				formpw.value = "";
			}
		});
	}

	return false;
};

Login.prototype.fillLoginFormFromLocalStorage = function() {
        var serverUrl = localStorage.server_url;
        if (serverUrl) {
            formurl.value = serverUrl;
        }
        var userName = localStorage.username;
        if (userName) {
            formun.value = userName;
        }
        var backendName = localStorage.backend;
        if (backendName === "TinyTinyRSS") {
            $("#login form").backend[0].checked = true;
        }
        else if (backendName === "OwnCloud") {
            $("#login form").backend[1].checked = true;