Make all JS functions and variables camelCase
According to conventions.
This commit is contained in:
parent
3939470679
commit
8a38274280
|
@ -24,22 +24,22 @@ SortFilterProxyModel {
|
|||
return model.setProperty(index, prop, value)
|
||||
}
|
||||
|
||||
function extend(new_items) {
|
||||
for (var i = 0; i < new_items.length; i++) {
|
||||
model.append(new_items[i])
|
||||
function extend(newItems) {
|
||||
for (var i = 0; i < newItems.length; i++) {
|
||||
model.append(newItems[i])
|
||||
}
|
||||
}
|
||||
|
||||
function getIndices(where_roles_are, max_results=null, max_tries=null) {
|
||||
// max_results, max_tries: null or int
|
||||
function getIndices(whereRolesAre, maxResults=null, maxTries=null) {
|
||||
// maxResults, maxTries: null or int
|
||||
var results = []
|
||||
|
||||
for (var i = 0; i < model.count; i++) {
|
||||
var item = model.get(i)
|
||||
var include = true
|
||||
|
||||
for (var role in where_roles_are) {
|
||||
if (item[role] != where_roles_are[role]) {
|
||||
for (var role in whereRolesAre) {
|
||||
if (item[role] != whereRolesAre[role]) {
|
||||
include = false
|
||||
break
|
||||
}
|
||||
|
@ -47,20 +47,20 @@ SortFilterProxyModel {
|
|||
|
||||
if (include) {
|
||||
results.push(i)
|
||||
if (max_results && results.length >= max_results) {
|
||||
if (maxResults && results.length >= maxResults) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if (max_tries && i >= max_tries) {
|
||||
if (maxTries && i >= maxTries) {
|
||||
break
|
||||
}
|
||||
}
|
||||
return results
|
||||
}
|
||||
|
||||
function getWhere(roles_are, max_results=null, max_tries=null) {
|
||||
var indices = getIndices(roles_are, max_results, max_tries)
|
||||
function getWhere(rolesAre, maxResults=null, maxTries=null) {
|
||||
var indices = getIndices(rolesAre, maxResults, maxTries)
|
||||
var items = []
|
||||
|
||||
for (var i = 0; i < indices.length; i++) {
|
||||
|
@ -69,36 +69,36 @@ SortFilterProxyModel {
|
|||
return items
|
||||
}
|
||||
|
||||
function forEachWhere(roles_are, func, max_results=null, max_tries=null) {
|
||||
var items = getWhere(roles_are, max_results, max_tries)
|
||||
function forEachWhere(rolesAre, func, maxResults=null, maxTries=null) {
|
||||
var items = getWhere(rolesAre, maxResults, maxTries)
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
func(items[i])
|
||||
}
|
||||
}
|
||||
|
||||
function upsert(
|
||||
where_roles_are, new_item, update_if_exist=true, max_tries=null
|
||||
whereRolesAre, newItem, updateIfExist=true, maxTries=null
|
||||
) {
|
||||
var indices = getIndices(where_roles_are, 1, max_tries)
|
||||
var indices = getIndices(whereRolesAre, 1, maxTries)
|
||||
|
||||
if (indices.length == 0) {
|
||||
model.append(new_item)
|
||||
model.append(newItem)
|
||||
return model.get(model.count)
|
||||
}
|
||||
|
||||
var existing = model.get(indices[0])
|
||||
if (! update_if_exist) { return existing }
|
||||
if (! updateIfExist) { return existing }
|
||||
|
||||
// Really update only if existing and new item have a difference
|
||||
for (var role in existing) {
|
||||
if (Boolean(existing[role].getTime)) {
|
||||
if (existing[role].getTime() != new_item[role].getTime()) {
|
||||
model.set(indices[0], new_item)
|
||||
if (existing[role].getTime() != newItem[role].getTime()) {
|
||||
model.set(indices[0], newItem)
|
||||
return existing
|
||||
}
|
||||
} else {
|
||||
if (existing[role] != new_item[role]) {
|
||||
model.set(indices[0], new_item)
|
||||
if (existing[role] != newItem[role]) {
|
||||
model.set(indices[0], newItem)
|
||||
return existing
|
||||
}
|
||||
}
|
||||
|
@ -112,8 +112,8 @@ SortFilterProxyModel {
|
|||
return item
|
||||
}
|
||||
|
||||
function popWhere(roles_are, max_results=null, max_tries=null) {
|
||||
var indices = getIndices(roles_are, max_results, max_tries)
|
||||
function popWhere(rolesAre, maxResults=null, maxTries=null) {
|
||||
var indices = getIndices(rolesAre, maxResults, maxTries)
|
||||
var items = []
|
||||
|
||||
for (var i = 0; i < indices.length; i++) {
|
||||
|
@ -124,11 +124,11 @@ SortFilterProxyModel {
|
|||
}
|
||||
|
||||
|
||||
function toObject(item_list=sortFilteredModel) {
|
||||
var obj_list = []
|
||||
function toObject(itemList=sortFilteredModel) {
|
||||
var objList = []
|
||||
|
||||
for (var i = 0; i < item_list.count; i++) {
|
||||
var item = item_list.get(i)
|
||||
for (var i = 0; i < itemList.count; i++) {
|
||||
var item = itemList.get(i)
|
||||
var obj = JSON.parse(JSON.stringify(item))
|
||||
|
||||
for (var role in obj) {
|
||||
|
@ -136,9 +136,9 @@ SortFilterProxyModel {
|
|||
obj[role] = toObject(item[role])
|
||||
}
|
||||
}
|
||||
obj_list.push(obj)
|
||||
objList.push(obj)
|
||||
}
|
||||
return obj_list
|
||||
return objList
|
||||
}
|
||||
|
||||
function toJson() {
|
||||
|
|
|
@ -49,7 +49,7 @@ HRectangle {
|
|||
eventList.canLoad = false
|
||||
py.callClientCoro(
|
||||
chatPage.userId, "load_past_events", [chatPage.roomId],
|
||||
more_to_load => { eventList.canLoad = more_to_load }
|
||||
moreToLoad => { eventList.canLoad = moreToLoad }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,12 +6,12 @@ import SortFilterProxyModel 0.2
|
|||
import "../Base"
|
||||
|
||||
HListModel {
|
||||
function lastEventOf(room_id) {
|
||||
function lastEventOf(roomId) {
|
||||
// Return an event item or undefined if none found
|
||||
|
||||
for (var i = 0; i < count; i++) {
|
||||
var item = get(i) // TODO: standardize
|
||||
if (item.roomId == room_id) { return item }
|
||||
if (item.roomId == roomId) { return item }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,8 +29,8 @@ Item {
|
|||
button.loading = true
|
||||
var args = [idField.text, passwordField.text]
|
||||
|
||||
py.callCoro("login_client", args, user_id => {
|
||||
pageStack.showPage("RememberAccount", {loginWith, user_id})
|
||||
py.callCoro("login_client", args, userId => {
|
||||
pageStack.showPage("RememberAccount", {loginWith, userId})
|
||||
button.loading = false
|
||||
})
|
||||
},
|
||||
|
|
|
@ -26,11 +26,11 @@ Python {
|
|||
call("APP.call_backend_coro", [name, uuid, args])
|
||||
}
|
||||
|
||||
function callClientCoro(account_id, name, args=[], callback=null) {
|
||||
function callClientCoro(accountId, name, args=[], callback=null) {
|
||||
var uuid = Math.random() + "." + name
|
||||
|
||||
pendingCoroutines[uuid] = callback || function() {}
|
||||
call("APP.call_client_coro", [account_id, name, uuid, args])
|
||||
call("APP.call_client_coro", [accountId, name, uuid, args])
|
||||
}
|
||||
|
||||
Component.onCompleted: {
|
||||
|
|
|
@ -15,14 +15,14 @@ function hsla(hue, saturation, lightness, alpha=1.0) {
|
|||
}
|
||||
|
||||
|
||||
function arrayToModelItem(keys_name, array) {
|
||||
function arrayToModelItem(keysName, array) {
|
||||
// Convert an array to an object suitable to be in a model, example:
|
||||
// [1, 2, 3] → [{keys_name: 1}, {keys_name: 2}, {keys_name: 3}]
|
||||
// [1, 2, 3] → [{keysName: 1}, {keysName: 2}, {keysName: 3}]
|
||||
var items = []
|
||||
|
||||
for (var i = 0; i < array.length; i++) {
|
||||
var obj = {}
|
||||
obj[keys_name] = array[i]
|
||||
obj[keysName] = array[i]
|
||||
items.push(obj)
|
||||
}
|
||||
return items
|
||||
|
@ -59,10 +59,10 @@ function nameColor(name) {
|
|||
}
|
||||
|
||||
|
||||
function coloredNameHtml(name, user_id, display_text=null) {
|
||||
function coloredNameHtml(name, userId, displayText=null) {
|
||||
// substring: remove leading @
|
||||
return "<font color='" + nameColor(name || alt_id.substring(1)) + "'>" +
|
||||
escapeHtml(display_text || name || alt_id) +
|
||||
return "<font color='" + nameColor(name || userId.substring(1)) + "'>" +
|
||||
escapeHtml(displayText || name || userId) +
|
||||
"</font>"
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user