Skip to content

Commit

Permalink
further fix bugs and recommend correct category
Browse files Browse the repository at this point in the history
  • Loading branch information
longshuicy committed Aug 29, 2024
1 parent d13b508 commit b64b811
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
2 changes: 1 addition & 1 deletion www/public/bootstrap/js/customized/analyses/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ $.getScript("bootstrap/js/customized/view_helperFunc.js", function(){

// add preview and column
$previewContent.append(arrayToTable(text_data.slice(0, 11), '#selectFileTable'));
$columnContent.append(extractHeader(text_data));
$columnContent.append(extractHeaderRadio(text_data));
$preview.show();
$column.show();

Expand Down
43 changes: 33 additions & 10 deletions www/public/bootstrap/js/customized/view_helperFunc.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,19 +102,38 @@ function escapeHtml(str) {
.replace(/'/g, ''');
}

function extractHeader(array) {

function extractHeaderRadio(array) {
var headerContent = '';
var column_header = array[0];
$.each(column_header, function (i, val) {
// Check the first item
if (i === 0) {
headerContent += `<label class="radio-inline">
<input type="radio" class="customized-radio" name="selectFileColumn" id="` + val
+ `" value="` + val + `" checked>` + val + `</label>`;
} else {
headerContent += `<label class="radio-inline">
<input type="radio" class="customized-radio" name="selectFileColumn" id="` + val
+ `" value="` + val + `">` + val + `</label>`;
}
});
return headerContent;
}

function extractHeaderCheckBox(array) {
var headerContent = '';
column_header = array[0];
var column_header = array[0];
$.each(column_header, function (i, val) {
//check the first item
// Check the first item
if (i === 0) {
headerContent += `<label class=radio-inline>
<input type="radio" class="customized-radio" name="selectFileColumn",id=`
+ val + ` value=` + val + ` checked></div>` + val + ` </label>`;
headerContent += `<label class="checkbox-inline">
<input type="checkbox" class="customized-checkbox" name="selectFileColumn" id="` + val
+ `" value="` + val + `" checked>` + val + `</label>`;
} else {
headerContent += `<label class=radio-inline>
<input type="radio" class="customized-radio" name="selectFileColumn",id=`
+ val + ` value=` + val + `></div>` + val + ` </label>`;
headerContent += `<label class="checkbox-inline">
<input type="checkbox" class="customized-checkbox" name="selectFileColumn" id="` + val
+ `" value="` + val + `">` + val + `</label>`;
}
});
return headerContent;
Expand Down Expand Up @@ -174,6 +193,10 @@ function processData(csv) {
$("#datasrc-criteria-hint").html("<p>Based on the column of your imported file, it is likely that you uploaded a " +
"<u>Reddit Comment</u> dataset.</p>")
}
else if (previewLinesWords[0].indexOf('snippet.title') > 0 || previewLinesWords[0].indexOf('snippet.description') > 0){
$("#datasrc-criteria-hint").html("<p>Based on the column of your imported file, it is likely that you uploaded a " +
"<u>YouTube video/channel/playlist search collection</u> dataset.</p>")
}
else{
$("#datasrc-criteria-hint").html("<p>We cannot detect the file category, make sure you choose <u>Others</u> in the category.</p>")
}
Expand All @@ -183,7 +206,7 @@ function processData(csv) {

// set column headers for userspec-Others-metadata
$("#column-header-selection").empty();
$("#column-header-selection").append(extractHeader(previewLinesWords));
$("#column-header-selection").append(extractHeaderCheckBox(previewLinesWords));

}

Expand Down

0 comments on commit b64b811

Please sign in to comment.