Skip to content

Commit e6c09d0

Browse files
committed
Documented dperuser.js while working on issue #117
1 parent 3b3a9c9 commit e6c09d0

File tree

1 file changed

+47
-18
lines changed

1 file changed

+47
-18
lines changed

load/dperuser.js

+47-18
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ userRecords = {
6464
* finds the point where the comment header stops and data begins
6565
* infile:
6666
* the currently open data file to read
67-
* returns:
67+
* return:
6868
* the file object with the pointer located at the point where
6969
* data begins
7070
* throws:
@@ -115,9 +115,9 @@ userRecords = {
115115
/*
116116
* summary:
117117
* method loads the dDoc-specific settings file
118-
* returns:
118+
* return:
119119
* the per-user settings sub-object
120-
* logs an error and returns null on failure
120+
* logs an error and throws exception on failure
121121
*/
122122
loadSettingsBlob: function () {
123123
var settingsFile = new File(userRecords.userDir
@@ -139,7 +139,6 @@ userRecords = {
139139
throw new dDocException("Unable to open " +
140140
userRecords.userDir + userRecords.settingsFilename,
141141
"Can't open user records!", 1);
142-
//return null;
143142
}
144143

145144
settingsFile = this.stripComments(settingsFile);
@@ -151,15 +150,13 @@ userRecords = {
151150
+ e.toString() + "\n");
152151
throw new dDocException("Err: " + e.toString(), "Exception" +
153152
" reading dDoc settings", 2);
154-
//return null;
155153
} finally {
156154
settingsFile.close();
157155
}
158156

159157
if ((blob == null) || (blob.length < 2)) {
160158
throw new dDocException("Exception: blob too small",
161159
"blob null or length < 2", 3);
162-
//return null;
163160
}
164161

165162
blob = JSON.parse(blob);
@@ -172,7 +169,7 @@ userRecords = {
172169
* the user number
173170
* userid:
174171
* synchronet user number to load
175-
* returns:
172+
* return:
176173
* the current user's settings object
177174
* if no settings for the current user are found, it returns a
178175
* settings object with all debugging options defaulting to false
@@ -203,6 +200,12 @@ userRecords = {
203200
/*
204201
* summary:
205202
* Saves the per-user settings to the DDOC settings file.
203+
* userid:
204+
* User id #
205+
* settings:
206+
* Not sure if this is the set of settings just for the user or if
207+
* for some reason the global settings variable is being passed
208+
* through here; looking at the calling code will be useful
206209
*/
207210
saveSettings: function (userid, settings) {
208211
var json = this.loadSettingsBlob();
@@ -228,13 +231,17 @@ userRecords = {
228231
* summary:
229232
* method is a wrapper for opening a file of any particular
230233
* mode; serves as a wrapper for the try/catch shit to not
231-
* be so redundant in code
232-
* fname:
233-
* filename/path to open
234+
* be so redundant in code; this should be utilized in some more
235+
* places, I kind of forgot about using this when I was working on
236+
* dperroom.js and potentially a few other spots where the wheel
237+
* has been invented again
238+
* fObj:
239+
* filename/path of the File object
234240
* mode:
235241
* Synchronet API's mode specification for File.open()
236242
* return:
237-
* Returns null for error, open file object for success
243+
* Returns open file object for success; throws exception on
244+
* error
238245
*/
239246
openFileWrap: function (fObj, mode) {
240247
try {
@@ -245,17 +252,26 @@ userRecords = {
245252
fObj.close();
246253
throw new dDocException("Exception in openFileWrap",
247254
e.toString(), 1);
248-
//return null;
249255
}
250256

251257
return fObj;
252258
}
253259
},
260+
//sub-object
254261
userDataUI: {
255262
//pushing/pulling output from the user (sorry, I can't stop using that
256263
//terminology now)
257264

258265
// ----++++****====userDataUI methods====****++++----
266+
/*
267+
* summary:
268+
* Method handles looking up a user by the user name and
269+
* fetches the data from userRecords.userDataIO.loadSettings()
270+
* in order to determine various bits of information like the
271+
* doing field and info field
272+
* uname:
273+
* Name of the user to profile
274+
*/
259275
profileUser : function (uname) {
260276
var profileeSettings = { };
261277
var unum, uObj;
@@ -290,7 +306,7 @@ userRecords = {
290306
* summary:
291307
* obtains a new list of lines of text to utilize as the
292308
* info field from the user
293-
* returns:
309+
* return:
294310
* this (up to 5 line) array of user info text
295311
*/
296312
getInfo: function () {
@@ -315,7 +331,7 @@ userRecords = {
315331
/*
316332
* summary:
317333
* Asks the user for a new doing message
318-
* returns:
334+
* return:
319335
* String value of the new doing message
320336
*/
321337
getDoing: function() {
@@ -336,6 +352,8 @@ userRecords = {
336352
* userid:
337353
* synchronet user number of the user whose debug flags
338354
* are being set
355+
* return:
356+
* new settings object
339357
* TODO:
340358
* connect this function with a sysop settings menu somewhere
341359
* so that sysops can set their own and others' debugging options
@@ -366,6 +384,13 @@ userRecords = {
366384
userRecords.userDataIO.saveSettings(userid, tmpSettings);
367385
return tmpSettings;
368386
},
387+
/*
388+
* summary:
389+
* Method displays the different possible debugging options
390+
* for the user as well as their true/false selected values
391+
* userid:
392+
* User id # of the user being examined
393+
*/
369394
displayDebugFlags: function (userid) {
370395
var flags = Object.keys(
371396
userRecords.userDataIO.loadSettings(userid).debug);
@@ -376,6 +401,12 @@ userRecords = {
376401
high_intensity + userSettings.debug[opt] + "\n");
377402
}
378403
},
404+
/*
405+
* summary:
406+
* Method displays the user information blurb (sans header)
407+
* userid:
408+
* User id # for the user being queried
409+
*/
379410
displayInfo: function (userid) {
380411
var info = userRecords.userDataIO.loadSettings(userid).info;
381412
var i;
@@ -388,6 +419,7 @@ userRecords = {
388419
}
389420

390421
},
422+
//sub-object
391423
userConfig = {
392424
//'c'onfig menu stuph
393425

@@ -399,7 +431,7 @@ userConfig = {
399431
// ----++++****====userConfig methods====****++++----
400432
/*
401433
* summary:
402-
* menu choice response for user configuration options
434+
* menu choice response for user configuration options
403435
*/
404436
reConfigure: function () {
405437
var stillAlahv = true, uResponse = null;
@@ -438,9 +470,6 @@ userConfig = {
438470
console.putmsg(excuse);
439471
break;
440472
}
441-
442473
}
443-
444474
}
445-
446475
}

0 commit comments

Comments
 (0)