Skip to content

Commit 6ed66b5

Browse files
Consistently use var name theClass and not klass
1 parent f8565c7 commit 6ed66b5

7 files changed

Lines changed: 33 additions & 33 deletions

File tree

src/authn/authn.ts

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -452,14 +452,14 @@ async function ensureOneTypeIndex (context: AuthenticationContext, isPublic: boo
452452
*/
453453
export async function findAppInstances (
454454
context: AuthenticationContext,
455-
klass: $rdf.NamedNode,
455+
theClass: $rdf.NamedNode,
456456
isPublic: boolean
457457
): Promise<AuthenticationContext> {
458458
const fetcher = kb.fetcher
459459
if (isPublic === undefined) {
460460
// Then both public and private
461-
await findAppInstances(context, klass, true)
462-
await findAppInstances(context, klass, false)
461+
await findAppInstances(context, theClass, true)
462+
await findAppInstances(context, theClass, false)
463463
return context
464464
}
465465

@@ -471,7 +471,7 @@ export async function findAppInstances (
471471
const index = context.index as { [key: string]: Array<$rdf.NamedNode> }
472472
const thisIndex = index[visibility]
473473
const registrations = thisIndex
474-
.map(ix => kb.each(undefined, ns.solid('forClass'), klass, ix))
474+
.map(ix => kb.each(undefined, ns.solid('forClass'), theClass, ix))
475475
.flat()
476476
const instances = registrations
477477
.map(reg => kb.each(reg, ns.solid('instance')))
@@ -494,7 +494,7 @@ export async function findAppInstances (
494494
} catch (err) {
495495
const e = new Error(`[FAI] Unable to load containers${err}`)
496496
console.log(e) // complain
497-
widgets.complain(context, `Error looking for ${utils.label(klass)}: ${err}`)
497+
widgets.complain(context, `Error looking for ${utils.label(theClass)}: ${err}`)
498498
// but then ignore it
499499
// throw new Error(e)
500500
}
@@ -530,7 +530,7 @@ function updatePromise (
530530
export async function registerInTypeIndex (
531531
context: AuthenticationContext,
532532
instance: $rdf.NamedNode,
533-
klass: $rdf.NamedNode,
533+
theClass: $rdf.NamedNode,
534534
isPublic: boolean
535535
): Promise<AuthenticationContext> {
536536
await ensureOneTypeIndex(context, isPublic)
@@ -546,7 +546,7 @@ export async function registerInTypeIndex (
546546
const ins = [
547547
// See https://github.com/solid/solid/blob/master/proposals/data-discovery.md
548548
$rdf.st(registration, ns.rdf('type'), ns.solid('TypeRegistration'), index),
549-
$rdf.st(registration, ns.solid('forClass'), klass, index),
549+
$rdf.st(registration, ns.solid('forClass'), theClass, index),
550550
$rdf.st(registration, ns.solid('instance'), instance, index)
551551
]
552552
try {
@@ -564,7 +564,7 @@ export async function registerInTypeIndex (
564564
export function registrationControl (
565565
context: AuthenticationContext,
566566
instance,
567-
klass
567+
theClass
568568
): Promise<AuthenticationContext | void> {
569569
const dom = context.dom
570570
if (!dom || !context.div) {
@@ -584,14 +584,14 @@ export function registrationControl (
584584
const registrations = kb
585585
.each(undefined, ns.solid('instance'), instance)
586586
.filter(function (r) {
587-
return kb.holds(r, ns.solid('forClass'), klass)
587+
return kb.holds(r, ns.solid('forClass'), theClass)
588588
})
589589
const reg = registrations.length
590590
? registrations[0]
591591
: widgets.newThing(index)
592592
return [
593593
$rdf.st(reg, ns.solid('instance'), instance, index),
594-
$rdf.st(reg, ns.solid('forClass'), klass, index)
594+
$rdf.st(reg, ns.solid('forClass'), theClass, index)
595595
]
596596
}
597597

@@ -712,7 +712,7 @@ export function registrationList (context: AuthenticationContext, options: {
712712
}
713713

714714
/*
715-
//const containers = kb.each(klass, ns.solid('instanceContainer'));
715+
//const containers = kb.each(theClass, ns.solid('instanceContainer'));
716716
if (containers.length) {
717717
fetcher.load(containers).then(function(xhrs){
718718
for (const i=0; i<containers.length; i++) {

src/chat/bookmarks.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ function updatePromise (del, ins) {
9494
/** Find a user's bookmarks
9595
*/
9696
export async function findBookmarkDocument (userContext) {
97-
const klass = BOOK('Bookmark')
97+
const theClass = BOOK('Bookmark')
9898
const fileTail = 'bookmarks.ttl'
9999
const isPublic = true
100100

101-
await UI.authn.findAppInstances(userContext, klass, isPublic) // public -- only look for public links
101+
await UI.authn.findAppInstances(userContext, theClass, isPublic) // public -- only look for public links
102102
if (userContext.instances && userContext.instances.length > 0) {
103103
userContext.bookmarkDocument = userContext.instances[0]
104104
if (userContext.instances.length > 1) {
@@ -120,7 +120,7 @@ export async function findBookmarkDocument (userContext) {
120120
await UI.authn.registerInTypeIndex(
121121
userContext,
122122
newBookmarkFile,
123-
klass,
123+
theClass,
124124
true
125125
) // public
126126
userContext.bookmarkDocument = newBookmarkFile

src/chat/messageTools.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@ export function sentimentStripLinked (target, doc) {
9595
])
9696
sentiments.sort()
9797
sentiments.forEach(ss => {
98-
const [klass, agent] = ss
98+
const [theClass, agent] = ss
9999
var res
100100
if (agent) {
101101
res = dom.createElement('a')
102102
res.setAttribute('href', agent.uri)
103103
} else {
104104
res = dom.createTextNode('')
105105
}
106-
res.textContent = emoji[klass] || '*'
106+
res.textContent = emoji[theClass] || '*'
107107
strip.appendChild(res)
108108
})
109109
}

src/preferences.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function recordSharedPreferences (subject, context) {
5858

5959
// Construct a personal defaults node in the preferences file for a given class of object
6060
//
61-
function recordPersonalDefaults (klass, context) {
61+
function recordPersonalDefaults (theClass, context) {
6262
return new Promise(function (resolve, reject) {
6363
authn.logInLoadPreferences(context).then(
6464
context => {
@@ -72,7 +72,7 @@ function recordPersonalDefaults (klass, context) {
7272
var regs = kb.each(
7373
null,
7474
ns.solid('forClass'),
75-
klass,
75+
theClass,
7676
context.preferencesFile
7777
)
7878
var ins = []
@@ -101,7 +101,7 @@ function recordPersonalDefaults (klass, context) {
101101
ns.solid('TypeRegistration'),
102102
context.preferencesFile
103103
),
104-
$rdf.st(reg, ns.solid('forClass'), klass, context.preferencesFile)
104+
$rdf.st(reg, ns.solid('forClass'), theClass, context.preferencesFile)
105105
]
106106
}
107107
prefs = widgets.newThing(context.preferencesFile)
@@ -115,7 +115,7 @@ function recordPersonalDefaults (klass, context) {
115115
)
116116
kb.updater.update([], ins, function (uri, ok, errm) {
117117
if (!ok) {
118-
reject(new Error('Setting preferences for ' + klass + ': ' + errm))
118+
reject(new Error('Setting preferences for ' + theClass + ': ' + errm))
119119
} else {
120120
context.personalDefaults = prefs
121121
resolve(context)
@@ -129,7 +129,7 @@ function recordPersonalDefaults (klass, context) {
129129
})
130130
}
131131

132-
function renderPreferencesForm (subject, klass, preferencesForm, context) {
132+
function renderPreferencesForm (subject, theClass, preferencesForm, context) {
133133
var prefContainer = context.dom.createElement('div')
134134
pad.participationObject(subject, subject.doc(), context.me).then(
135135
participation => {
@@ -166,7 +166,7 @@ function renderPreferencesForm (subject, klass, preferencesForm, context) {
166166
)
167167

168168
heading('My default view of any ' + context.noun)
169-
recordPersonalDefaults(klass, context).then(
169+
recordPersonalDefaults(theClass, context).then(
170170
context => {
171171
widgets.appendForm(
172172
dom,
@@ -220,15 +220,15 @@ function toJS (term) {
220220
// This is the function which acuakly reads and combines the preferences
221221
//
222222
// @@ make it much more tolerant of missing buts of prefernces
223-
function getPreferencesForClass (subject, klass, predicates, context) {
223+
function getPreferencesForClass (subject, theClass, predicates, context) {
224224
return new Promise(function (resolve, reject) {
225225
recordSharedPreferences(subject, context).then(context => {
226226
var sharedPreferences = context.sharedPreferences
227227
if (context.me) {
228228
pad
229229
.participationObject(subject, subject.doc(), context.me)
230230
.then(participation => {
231-
recordPersonalDefaults(klass, context).then(context => {
231+
recordPersonalDefaults(theClass, context).then(context => {
232232
var results = []
233233
var personalDefaults = context.personalDefaults
234234
predicates.forEach(pred => {

src/widgets/buttons.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,8 @@ export function setImage (element: HTMLElement, thing: NamedNode) { // 20191230a
374374
for (var k in iconForClass) {
375375
const pref = k.split(':')[0]
376376
const id = k.split(':')[1]
377-
const klass = ns[pref](id)
378-
iconForClassMap[klass.uri] = uri.join(iconForClass[k], iconBase)
377+
const theClass = ns[pref](id)
378+
iconForClassMap[theClass.uri] = uri.join(iconForClass[k], iconBase)
379379
}
380380

381381
const happy = trySetImage(element, thing, iconForClassMap)
@@ -525,22 +525,22 @@ export function continueButton (dom: HTMLDocument, handler: (event: any) => void
525525
/* Grab a name for a new thing
526526
*
527527
* Form to get the name of a new thing before we create it
528-
* @params klass Misspelt to avoid clashing with the JavaScript keyword
528+
* @params theClass Misspelt to avoid clashing with the JavaScript keyword
529529
* @returns: a promise of (a name or null if cancelled)
530530
*/
531531
export function askName (
532532
dom: HTMLDocument,
533533
kb: IndexedFormula,
534534
container: HTMLDivElement,
535535
predicate?: NamedNode,
536-
klass?: NamedNode,
536+
theClass?: NamedNode,
537537
noun?: string) {
538538
// eslint-disable-next-line promise/param-names
539539
return new Promise(function (resolve, _reject) {
540540
var form = dom.createElement('div') // form is broken as HTML behaviour can resurface on js error
541541
// classLabel = utils.label(ns.vcard('Individual'))
542542
predicate = predicate || ns.foaf('name') // eg 'name' in user's language
543-
noun = noun || (klass ? utils.label(klass) : ' ') // eg 'folder' in users's language
543+
noun = noun || (theClass ? utils.label(theClass) : ' ') // eg 'folder' in users's language
544544
var prompt = noun + ' ' + utils.label(predicate) + ': '
545545
form.appendChild(dom.createElement('p')).textContent = prompt
546546
var namefield = dom.createElement('input')

test/unit/preferences.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ describe('Preferences.renderPreferencesForm', () => {
4242
})
4343
it('runs', () => {
4444
const subject = sym('https://test.test')
45-
const klass = {}
45+
const theClass = {}
4646
const preferencesForm = {}
4747
const context = { dom }
4848
expect(Preferences.renderPreferencesForm(
49-
subject, klass, preferencesForm, context
49+
subject, theClass, preferencesForm, context
5050
)).toBeTruthy()
5151
})
5252
})

test/unit/widgets/buttons.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ describe('askName', () => {
7676
const kb = graph()
7777
const container = element
7878
const predicate = {} as NamedNode
79-
const klass = {} as NamedNode
79+
const theClass = {} as NamedNode
8080
const noun = ''
81-
expect(await askName(dom, kb, container, predicate, klass, noun)).toBeTruthy()
81+
expect(await askName(dom, kb, container, predicate, theClass, noun)).toBeTruthy()
8282
})
8383
})
8484

0 commit comments

Comments
 (0)