Skip to content

Commit

Permalink
Remove camel case ignore rule in ESLint (#278)
Browse files Browse the repository at this point in the history
* Made all identifers in components/ in camelCase to remove camelCase rule of ESLint

* Made identifiers in apps folder to be in camelCase

* changed anno_delte to annoDelte

* Fixed camelCase in init.js and table.html

* Update spyglass.js

merge request #278
variable name changing ====> `_target_viewer` => `_targetViewer`.

* Update uicallbacks.js

1. `toolbar._main_tools` => `toolbar._mainTools`, there are 8 places in `apps/veiwer/uicallbacks.js` that need to change when you change the variable`_main_tools` to `_mainTools`  in `components/toolbar/toolbar.js`. [line 17, 23, 1053, 1079, 1092, 1096, 1215, 1221]
2. `toolbar._sub_tools` => `toolbar._subTools`, there are 3 places in `apps/segment/segment.js`(2 places - line 850, 851 removed), `apps/labeling/labeling.js` (1 place - line 84) that need to change when you change the variable`_sub_tools` to `_subTools`  in `components/toolbar/toolbar.js`.

* Update labeling.js

`toolbar._sub_tools` => `toolbar._subTools`

* Update segment.js

`toolbar._sub_tools` => `toolbar._subTools`

Co-authored-by: nanli-emory <40213692+nanli-emory@users.noreply.github.com>
  • Loading branch information
cjchirag7 and nanli-emory authored Apr 3, 2020
1 parent e89b21a commit b0509cf
Show file tree
Hide file tree
Showing 18 changed files with 393 additions and 392 deletions.
1 change: 0 additions & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module.exports = {
"require-jsdoc" : 0,
"valid-jsdoc" : 0,
"max-len" : ["error", { "code": 120 ,"ignoreTemplateLiterals": true},],
"camelcase" : 0,
"no-unused-vars" : 0,
"no-var" : 0,
"new-cap" : 0,
Expand Down
4 changes: 2 additions & 2 deletions apps/heatmap/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,6 @@ function createExportEditData() {
}
function getUserId() {
const token = getCookie('token');
const token_data = parseJwt(token);
return token_data.name;
const tokenData = parseJwt(token);
return tokenData.name;
}
12 changes: 6 additions & 6 deletions apps/heatmap/uicallbacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function toggleViewerMode(opt) {
}

// mainfest
function multSelector_action(size) {
function multSelectorAction(size) {
// hidden main viewer's bottom right control and get navigator
$CAMIC.viewer.controls.bottomright.style.display = 'none';
// if(event.data.length == 0){
Expand Down Expand Up @@ -126,12 +126,12 @@ function openSecondaryViewer() {
// minor.classList.add('display');
minor.classList.add('right');

const nav_size = {
const navSize = {
'height': $CAMIC.viewer.controls.bottomright.querySelector('.navigator').style.height,
'width': $CAMIC.viewer.controls.bottomright.querySelector('.navigator').style.width,
};
setTimeout(function() {
multSelector_action(nav_size);
multSelectorAction(navSize);
}, 100);
}

Expand Down Expand Up @@ -464,7 +464,7 @@ async function saveEditData() {


// delete old one
let create_date = now;
let createDate = now;

if (ImgloaderMode!='imgbox') {
// find editor data
Expand All @@ -477,7 +477,7 @@ async function saveEditData() {
}

if (data.length!==0) {
create_date = data[0].create_date;
createDate = data[0].create_date;
const del = await $CAMIC.store.deleteHeatmapEdit(user, slide, exec);
// error
if (del.hasError&&del.hasError==true) {
Expand All @@ -489,7 +489,7 @@ async function saveEditData() {
// add new one
const add = await $CAMIC.store.addHeatmapEdit({
user_id: user,
create_date: create_date,
create_date: createDate,
update_date: now,
provenance: $D.heatMapData.provenance,
data: editData,
Expand Down
14 changes: 7 additions & 7 deletions apps/labeling/labeling.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function initCore() {

$CAMIC.viewer.addHandler('open', function() {
if ($CAMIC.viewer.pmanager)$CAMIC.viewer.pmanager.on();
if (!$CAMIC.viewer.measureInstance) $UI.toolbar._sub_tools[2].style.display = 'none';
if (!$CAMIC.viewer.measureInstance) $UI.toolbar._subTools[2].style.display = 'none';
});

// ui init
Expand Down Expand Up @@ -221,12 +221,12 @@ function getPatchsZip(data) {
delete p.label;
delete p.widthInClient;
});
const meta_content = [['name', 'location'], [data.name, data.location]];
const patch_cols = ['id', 'color', 'note', 'isPoint', 'x', 'y', 'width', 'height', 'location'];
const patches_content = [patch_cols];
const metaContent = [['name', 'location'], [data.name, data.location]];
const patchCols = ['id', 'color', 'note', 'isPoint', 'x', 'y', 'width', 'height', 'location'];
const patchesContent = [patchCols];

data.patches.forEach((p, idx)=>{
patches_content.push([idx,
patchesContent.push([idx,
p['color'],
p['note'],
p['isPoint'],
Expand All @@ -237,8 +237,8 @@ function getPatchsZip(data) {
p['location']]);
});

zip.file(`metadata.csv`, meta_content.map((r)=>r.join(',')).join('\n'));
zip.file(`patches.csv`, patches_content.map((r)=>r.join(',')).join('\n'));
zip.file(`metadata.csv`, metaContent.map((r)=>r.join(',')).join('\n'));
zip.file(`patches.csv`, patchesContent.map((r)=>r.join(',')).join('\n'));

zip.generateAsync({type: 'blob'})
.then(function(content) {
Expand Down
31 changes: 16 additions & 15 deletions apps/loader/chunked_upload.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// expects changeStatus to be defined from loader.js

var start_url = '../loader/upload/start';
var continue_url = '../loader/upload/continue/';
var finish_url = '../loader/upload/finish/';
var startUrl = '../loader/upload/start';
var continueUrl = '../loader/upload/continue/';
var finishUrl = '../loader/upload/finish/';

var chunkSize = 5*1024*1024;

// read a chunk of the file
Expand Down Expand Up @@ -33,7 +34,7 @@ async function readFileChunks(file, token) {
try {
const data = await promiseChunkFileReader(file, part);
const body = {chunkSize: chunkSize, offset: part*chunkSize, data: data};
const res = await continue_upload(token)(body);
const res = await continueUpload(token)(body);
part++;
console.log(part);
} catch (e) {
Expand All @@ -45,7 +46,7 @@ async function readFileChunks(file, token) {
}


async function handle_upload(selectedFiles) {
async function handleUpload(selectedFiles) {
var fnametr = document.getElementById('filenameRow');
var tokentr = document.getElementById('tokenRow');
var slidetr = document.getElementById('slidenameRow');
Expand Down Expand Up @@ -76,8 +77,8 @@ async function handle_upload(selectedFiles) {

selectedFile = selectedFiles[i];
const filename = document.getElementById('filename'+currID).value;
const token = await start_upload(filename);
const callback = continue_upload(token);
const token = await startUpload(filename);
const callback = continueUpload(token);
document.getElementById('token'+currID).value = token;
readFileChunks(selectedFile, token);
// parseFile(selectedFile, callback, 0, x=>(changeStatus("UPLOAD", "Finished Reading File")))
Expand All @@ -87,9 +88,9 @@ async function handle_upload(selectedFiles) {
document.getElementById('controlButtons').colSpan = selectedFiles.length+1;
}

async function start_upload(filename) {
async function startUpload(filename) {
const body = {filename: filename};
const token = fetch(start_url, {method: 'POST', body: JSON.stringify(body), headers: {
const token = fetch(startUrl, {method: 'POST', body: JSON.stringify(body), headers: {
'Content-Type': 'application/json; charset=utf-8',
}}).then((x)=>x.json());
try {
Expand All @@ -101,29 +102,29 @@ async function start_upload(filename) {
}
}

function continue_upload(token) {
function continueUpload(token) {
return async function(body) {
changeStatus('UPLOAD', 'Uploading chunk at: '+ body.offset +' of size '+ body.chunkSize);
return await fetch(continue_url + token, {method: 'POST', body: JSON.stringify(body), headers: {
return await fetch(continueUrl + token, {method: 'POST', body: JSON.stringify(body), headers: {
'Content-Type': 'application/json; charset=utf-8',
}});
};
}
function finish_upload() {
function finishUpload() {
var reset = true;
for (var i=0; i<document.getElementById('fileIdRow').cells.length-1; i++) {
const token = document.getElementById('token'+i).value;
const filename = document.getElementById('filename'+i).value;
const body = {filename: filename};
changeStatus('UPLOAD', 'Finished Reading File, Posting');
const reg_req = fetch(finish_url + token, {method: 'POST', body: JSON.stringify(body), headers: {
const regReq = fetch(finishUrl + token, {method: 'POST', body: JSON.stringify(body), headers: {
'Content-Type': 'application/json; charset=utf-8',
}});
console.log(i);
reg_req.then((x)=>x.json()).then((a)=>{
regReq.then((x)=>x.json()).then((a)=>{
changeStatus('UPLOAD | Finished', a, reset); console.log(a); reset = false;
});
reg_req.then((e)=> {
regReq.then((e)=> {
if (e['ok']===false) {
changeStatus('UPLOAD | ERROR;', e);
reset = true;
Expand Down
14 changes: 7 additions & 7 deletions apps/loader/loader.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var upload_url = '../loader/upload/start/';
var check_url = '../loader/data/one/';
var thumb_url = '../loader/data/thumbnail/';
var uploadUrl = '../loader/upload/start/';
var checkUrl = '../loader/data/one/';
var thumbUrl = '../loader/data/thumbnail/';

var store = new Store('../data/');

Expand Down Expand Up @@ -54,7 +54,7 @@ function changeStatus(step, text, reset=true) {
if (step == 'CHECK') {
// During check, thumbnail needs to be fetched & added to the table
// In this case, text[col[col.length - 1]] is the filename
fetch(thumb_url + text[col[col.length - 1]], {credentials: 'same-origin'}).then(
fetch(thumbUrl + text[col[col.length - 1]], {credentials: 'same-origin'}).then(
(response) => response.json(), // if the response is a JSON object
).then((x)=>{
var tabCell = tr.cells[tr.cells.length-1];
Expand Down Expand Up @@ -84,7 +84,7 @@ function handleUpload(file, filename) {
data.append('file', file);
data.append('filename', filename);
changeStatus('UPLOAD', 'Begun upload');
fetch(upload_url, {
fetch(uploadUrl, {
credentials: 'same-origin',
method: 'POST',
body: data,
Expand All @@ -98,7 +98,7 @@ function handleUpload(file, filename) {
}

function handleCheck(filename, reset, id) {
fetch(check_url + filename, {credentials: 'same-origin'}).then(
fetch(checkUrl + filename, {credentials: 'same-origin'}).then(
(response) => response.json(), // if the response is a JSON object
).then(
(success) => {
Expand All @@ -113,7 +113,7 @@ function handleCheck(filename, reset, id) {
}

function handlePost(filename, slidename, filter, reset) {
fetch(check_url + filename, {credentials: 'same-origin'}).then(
fetch(checkUrl + filename, {credentials: 'same-origin'}).then(
(response) => response.json(), // if the response is a JSON object
).then(
(data) => {
Expand Down
Loading

0 comments on commit b0509cf

Please sign in to comment.