Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
62eee76
Fixed repo clone
SAMMOLOI Aug 19, 2021
fd00445
update
SAMMOLOI Aug 20, 2021
4731cd9
update
SAMMOLOI Aug 20, 2021
c7cac80
update
SAMMOLOI Aug 23, 2021
eeb8e54
update
SAMMOLOI Aug 23, 2021
c652401
update
SAMMOLOI Aug 23, 2021
031b614
update
SAMMOLOI Aug 23, 2021
027b329
update
SAMMOLOI Aug 23, 2021
909ce8f
update
SAMMOLOI Aug 23, 2021
1de2f8d
update
SAMMOLOI Aug 23, 2021
fa95818
update
SAMMOLOI Aug 23, 2021
0e43a23
update
SAMMOLOI Aug 24, 2021
b2e0238
update
SAMMOLOI Aug 24, 2021
32a64cc
update
SAMMOLOI Aug 24, 2021
4f10567
update
SAMMOLOI Aug 24, 2021
97d4868
update
SAMMOLOI Aug 24, 2021
98cbe57
update
SAMMOLOI Aug 24, 2021
2672789
update
SAMMOLOI Aug 24, 2021
5aaf23d
update
SAMMOLOI Aug 24, 2021
89e549c
update
SAMMOLOI Aug 24, 2021
ea585f3
update
SAMMOLOI Aug 24, 2021
879f4ae
update
SAMMOLOI Aug 24, 2021
e8f6188
update
SAMMOLOI Aug 24, 2021
1baa7d2
update
SAMMOLOI Aug 24, 2021
b50d91d
update
SAMMOLOI Aug 24, 2021
a1a101a
update
SAMMOLOI Aug 24, 2021
17a729f
update
SAMMOLOI Aug 24, 2021
980ab3f
update
SAMMOLOI Aug 24, 2021
aa08fe6
update
SAMMOLOI Aug 24, 2021
07be5f0
update
SAMMOLOI Aug 24, 2021
f02c455
update
SAMMOLOI Aug 24, 2021
53b603d
update
SAMMOLOI Aug 24, 2021
39faae7
update
SAMMOLOI Aug 25, 2021
6082bc3
update
SAMMOLOI Aug 25, 2021
88d921b
update
SAMMOLOI Aug 25, 2021
a329804
update
SAMMOLOI Aug 25, 2021
7939c12
update
SAMMOLOI Aug 25, 2021
7591502
update
SAMMOLOI Aug 25, 2021
bcc9696
update
SAMMOLOI Aug 25, 2021
f7fe9a7
update
SAMMOLOI Aug 25, 2021
44aad0a
update
SAMMOLOI Aug 25, 2021
5ee895e
update
SAMMOLOI Aug 25, 2021
14fbe67
update
SAMMOLOI Aug 25, 2021
6b25495
update
SAMMOLOI Aug 25, 2021
ae33eae
update
SAMMOLOI Aug 25, 2021
19d0292
update
SAMMOLOI Aug 25, 2021
6aa32a9
update
SAMMOLOI Aug 25, 2021
5efc63c
update
SAMMOLOI Aug 25, 2021
8aab829
update
SAMMOLOI Aug 25, 2021
b25c082
update
SAMMOLOI Aug 25, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/node_modules
app.js
app.js.map
dist.min.js
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "pwa-chrome",
"request": "launch",
"name": "Launch Chrome against localhost",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}"
}
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"compile-hero.disable-compile-files-on-did-save-code": false
}
194 changes: 194 additions & 0 deletions app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
import { data } from "jquery";

namespace onboardproject {

module onboardprojects {

// Load Variable declarations
let Load = 50;

// Previous Variable declarations
let previous: number;

// Previous Process Variable declarations
let previousprocess: number;

// Trigger async function
async function getRecordCountCall(): Promise<void> {
const response = await fetch('http://localhost:2050/recordCount');
if (!response.ok) {
const message = `An error has occured: ${response.status}`;
throw new Error(message);
}
}

// Trigger async function
async function getColumnNamesCall(): Promise<void> {
const response = await fetch('http://localhost:2050/columns');
if (!response.ok) {
const message = `An error has occured: ${response.status}`;
throw new Error(message);
}
}

// Trigger async function
async function getRecordsCall(fromID: number, toID: number): Promise<number[]> {
const response = await fetch(`http://localhost:2050/records?from=${(fromID)}&to=${(toID)}`);
if (!response.ok) {
const message = `An error has occured: ${response.status}`;
throw new Error(message);
}
return response.json();
}

// Region Data Loading methods
async function LoadRecordsData(fromID: number, toID: number): Promise<void> {
const recordsvalue = await getRecordsCall(fromID, toID);
let DisplayContent = '';
for (const records of recordsvalue) {
DisplayContent += `<tr id="table-row-${records}">`;
for (const column of record) {
DisplayContent += `<td align="center">${column}</td>`;
}
DisplayContent += '</tr>';
$("#wrapper-table-content-body").empty();
$("#wrapper-table-content-body").append(DisplayContent);
}
}

// Load Records Function
function RecordsFromCursor(cursor: number[]): Promise<void> {
cursor = cursor.sort((a, b) => { return a - b });
}

// Handlers
async function LoadPageContent(fromID: number, toID: number): Promise<void> {
let DisplayContent = "";
const columns = await getColumnNamesCall();
for (const column of columns) {
DisplayContent += `<th align="center">${column}</th>`;
$("#wrapper-table-header-row").empty();
$("#wrapper-table-header-row").append(DisplayContent);
}
}

// Conversion Function
function ConvertNumber(input: string | number, parseAsInt: boolean = true): number {
switch (typeof input) {
case ('string'):
if (parseAsInt == true) {
return parseInt(input as string);
}
return parseFloat(input as string);
case ("number"):
return input as number;
}
return 0;
}

// Height Diplay Function
function calculateToId(fromId: number): number {
const possibleRecordsData = Math.max((window.innerHeight - ($("#form-content").innerHeight() as number)) / 37);
let recordDisplayset = 0;
return recordDisplayset;
}

// Next_Page_Resize Function
function nextPageResize(previous: number[]): number {
const fromID = ConvertNumber(previous.sort((a, b) => { return a - b })[0]);
const toID = ConvertNumber(previous.sort((a, b) => { return a - b })[1]);
const documentHeight = Math.max((window.innerHeight - ($(`#table-row-${fromID}`).height() as number)));
for (let i = fromID; i <= toID; i++) {
const elementHeightOffset = ($(`#table-row-${i}`).offset() as JQueryCoordinates).top;
if (elementHeightOffset < documentHeight) continue;
return i;
}
return toID;
}

// Onload Function
window.onload = async () => {

// Previous_Page_Resize Function
function previousPageResize(previous: number[]): number[] {
let nextPage = nextPageResize([]);
const toId = calculateToId(previous[0] - nextPage);
return [previous[0] - (nextPage - previous[0]), toId];
}

// On Resize_Function
window.onresize = () => {

try {
const nextToId = calculateToId(previous);
clearTimeout(Load);
Load = setTimeout(async () => {
const recordCount = await getRecordCountCall();
if (nextToId >= recordCount - 1) {
const fromId = recordCount - 1 - (calculateToId(previous) - previous);
const toId = recordCount - 1;
//previous = await LoadRecordsData(fromId, toId);
} else {
//previous = await LoadRecordsData(previous[0], nextToId);
}
}, 250);
} catch (error) {
// throw new Error("Error" + error);
}
}

//Loading Content Function
//previous = await LoadPageContent(0, calculateToId(0));

// Click function for previewing page
$("#previous").click(async () => {
const CountData = await getRecordCountCall();
previous = previousPageResize(previous);
let fromId = previous >= 0 ? previous : 0;
const possibleStep = calculateToId(fromId) - fromId;
let toId = (previous >= 0 ? previous : possibleStep);
fromId = fromId == CountData - 1 ? fromId - possibleStep : fromId;
toId = toId <= CountData - 1 ? toId : CountData - 1;
//previous = await LoadRecordsData(fromId, toId);
});

// Click function for Skipping to next page
$("#next").click(async () => {
try {
const recordCount = await getRecordCountCall();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are allowed to skip this step. For this project the record count will not change after the initial call.

const fromId = nextPageResize(previous);
const possibleStep = calculateToId(fromId) - fromId;
if (fromId <= recordCount - possibleStep - 1) {
const toId = fromId + possibleStep <= recordCount - 1 ? fromId + possibleStep : recordCount - 1;
// previous = await LoadRecordsData(fromId, toId);
} else if (fromId <= recordCount - 1) {
//previous = await LoadRecordsData(recordCount - 1 - (calculateToId(fromId) - fromId), recordCount - 1);
} else {
throw new Error("Error 404");
}
} catch (error) {
}
});

$("#go-button").click(async () => {
const recordCount = await getRecordCountCall();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are allowed to skip this step. For this project the record count will not change after the initial call.

const fromId = ConvertNumber($("#index").val() as string, false);
const possibleStep = calculateToId(fromId) - fromId;
if (fromId < 0) {
alert('only insert Id greater than or equal to 0');

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a return here so we can remove the next "else" below. This is more readable and reduces excessive indentation in cases where larger nested "if else" statements exist.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment on this line is still relevant.

}
else {
if (Math.floor(fromId).toString() == fromId.toString() === true) {
if (fromId > recordCount - possibleStep) {
alert(`You may not insert a desired Id greater than ${recordCount - possibleStep}`);
} else {
let toId = (fromId) + possibleStep < recordCount ? (fromId) + possibleStep : recordCount - 1;

// previous = await LoadRecordsData(fromId, toId);
}
}
}
});
}
}
}
1 change: 1 addition & 0 deletions dist/app.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 17 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,13 +1,27 @@
<!DOCTYPE html>
<html>

<head>
<title>JS Onboard Project</title>
<script type="text/javascript" charset="utf-8" src="third_party/jquery-2.0.3.min.js"></script>
<script src="app.js"> </script>
<link rel="stylesheet" type="text/css" href="/style.css">
</head>

<body>
<p>Hello</p>
<body id="body">
<div id="form-content">
Go To Start Index:<input type="number" id="index" value="0" min="0">
<button id="go-button" type="button">GOT TO INDEX PAGE </button>
<button id="previous" type="button">Go to Previous </button>
<button id="next" type="button">Go to Next </button>
</div>
<table id='wrapper-table'>
<thead id="wrapper-table-header-row">
</thead>
<tbody id="wrapper-table-content-body">
</tbody>
</table>
<div id="table-arbitrary-footer"></div>
</body>

</html>

124 changes: 124 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading