Skip to content

Commit

Permalink
refact: clean code
Browse files Browse the repository at this point in the history
  • Loading branch information
heliomarpm committed Jul 2, 2024
1 parent cf2db9f commit 53a0870
Show file tree
Hide file tree
Showing 29 changed files with 383 additions and 302 deletions.
494 changes: 246 additions & 248 deletions app/app.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ <h5>

$("body").prepend(template);

if (Settings.language == "Arabic") {
if (Gettings.language == "Arabic") {
$(".ui.dashboard .content")
.css("margin-left", "10px")
.css("width", "80%");
Expand Down
70 changes: 60 additions & 10 deletions app/js/settings.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,51 @@
/**
* @typedef {Enumerator} DownloadTypeSetting
* @property {number} Both
* @property {number} OnlyLectures
* @property {number} OnlyAttachments
*/

/**
* @typedef {Object} DownloadSetting
* @property {boolean} checkNewVersion
* @property {string} defaultSubtitle
* @property {string} path
* @property {boolean} autoStartDownload
* @property {boolean} continueDonwloadingEncrypted
* @property {boolean} enableDownloadStartEnd
* @property {number} downloadStart
* @property {boolean} downloadEnd
* @property {string} videoQuality
* @property {DownloadTypeSetting} type
* @property {boolean} skipSubtitles
* @property {boolean} seqZeroLeft
* @property {boolean} autoRetry
*/

/**
* @typedef {Object} DownloadHistory
* @property {number} id
* @property {boolean} completed
* @property {string} date
* @property {number} encryptedVideos
* @property {string} selectedSubtitle
* @property {string} pathDownloaded
*/

/**
* @typedef {Object} DownloadedCourses
* @property {number} id
* @property {string} url
* @property {string} title
* @property {string} image
* @property {number} individualProgress
* @property {number} combinedProgress
* @property {boolean} completed
* @property {string} progressStatus
* @property {number} encryptedVideos
* @property {string} selectedSubtitle
* @property {string} pathDownloaded
*/

const Settings = (() => {
"use strict"
Expand All @@ -6,25 +54,27 @@ const Settings = (() => {
const path = require("path");
const { homedir } = require("os");

/** @type {DownloadTypeSetting} */
const DownloadType = Object.freeze({
Both: 0,
OnlyLectures: 1,
OnlyAttachments: 2
});

/** @type {DownloadSetting} */
const DownloadDefaultOptions = Object.freeze({
checkNewVersion: true,
defaultSubtitle: undefined,
path: path.join(homedir(), "Downloads", "Udeler"),
autoStartDownload: false,
continueDonwloadingEncrypted: false,
enableDownloadStartEnd: false,
downloadStart: 0,
downloadEnd: 0,
type: DownloadType.Both,
skipSubtitles: false,
autoRetry: false,
downloadStart: 0,
downloadEnd: 0,
videoQuality: "Auto",
path: path.join(homedir(), "Downloads", "Udeler"),
defaultSubtitle: undefined,
seqZeroLeft: false,
});

Expand Down Expand Up @@ -139,27 +189,27 @@ const Settings = (() => {
set subscriber(value) {
this.set("subscriber", value);
},
/** @type {Object} */
/** @type {DownloadSetting} */
get download() {
return this.get("download");
},
/** @type {Object} */
/** @type {DownloadSetting} */
set download(value) {
this.set("download", value);
},
/** @type {Object} */
/** @type {DownloadHistory} */
get downloadHistory() {
return this.get("downloadedHistory");
},
/** @type {Object} */
/** @type {DownloadHistory} */
set downloadHistory(value) {
this.set("downloadedHistory", value);
},
/** @type {Object} */
/** @type {DownloadedCourses} */
get downloadedCourses() {
return this.get("downloadedCourses");
},
/** @type {Object} */
/** @type {DownloadedCourses} */
set downloadedCourses(value) {
this.set("downloadedCourses", value);
},
Expand Down
21 changes: 15 additions & 6 deletions app/js/ui.js
Original file line number Diff line number Diff line change
@@ -1,47 +1,56 @@
"use strict"

const ui = {
dimmerLogin: (isActive) => {
navSidebar(tab, tabName) {
$(".content .ui.section").hide();
$(`.content .ui.${tabName}.section`).show();
$(tab).parent(".sidebar").find(".active").removeClass("active purple");
$(tab).addClass("active purple");
},
busyOff: () => {
$(".ui.dimmer").removeClass("active");
},
busyLogin: (isActive) => {
const $busyDimmer = $(".ui.login.dimmer");
if (isActive) {
$busyDimmer.addClass("active");
} else {
$busyDimmer.removeClass("active");
}
},
dimmerLogout: (isActive) => {
busyLogout: (isActive) => {
const $busyDimmer = $(".ui.logout.dimmer");
if (isActive) {
$busyDimmer.addClass("active");
} else {
$busyDimmer.removeClass("active");
}
},
dimmerCheckUpdate: (isActive) => {
busyCheckUpdate: (isActive) => {
const $busyDimmer = $(".ui.dashboard .about.dimmer");
if (isActive) {
$busyDimmer.addClass("active");
} else {
$busyDimmer.removeClass("active");
}
},
dimmerLoadCourses: (isActive) => {
busyLoadCourses: (isActive) => {
const $busyDimmer = $(".ui.dashboard .courses.dimmer");
if (isActive) {
$busyDimmer.addClass("active");
} else {
$busyDimmer.removeClass("active");
}
},
dimmerPrepareDownload: (isActive) => {
busyPrepareDownload: (isActive) => {
const $busyDimmer = $(".ui.dashboard .course.dimmer");
if (isActive) {
$busyDimmer.addClass("active");
} else {
$busyDimmer.removeClass("active");
}
},
dimmerDownloads: (isActive) => {
busyLoadDownloads: (isActive) => {
const $busyDimmer = $(".ui.dashboard .downloads.dimmer");
if (isActive) {
$busyDimmer.addClass("active");
Expand Down
1 change: 1 addition & 0 deletions app/locale/am.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"You do not have permission to access this course": "ይህን ኮርስ ለማግኘት ፍቃድ የለዎትም።",
"Load More": "ተጨማሪ",
"No Courses Found": "ምንም ኮርሶች አልተገኙም።",
"There are no Downloads to display": "ምንም ኮርስ አልተመዘገቡም።",
"Remember, you will only be able to see the courses you are enrolled in": "ያስታውሱ፣ እርስዎ የተመዘገቡባቸውን ኮርሶች ብቻ ነው ማየት የሚችሉት።",
"This account has been identified with a subscription plan": "",
"This account was identified without a subscription plan": "",
Expand Down
1 change: 1 addition & 0 deletions app/locale/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"You do not have permission to access this course": "ليس لديك إذن للوصول إلى هذه الدورة",
"Load More": "تحميل المزيد",
"No Courses Found": "لم يتم العثور على دورات",
"There are no Downloads to display": "لا توجد تحميلات لأي عرض",
"Remember, you will only be able to see the courses you are enrolled in": "",
"This account has been identified with a subscription plan": "",
"This account was identified without a subscription plan": "",
Expand Down
5 changes: 3 additions & 2 deletions app/locale/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"Loading Courses": "Kurse werden geladen",
"You have not enrolled in any course": "Du hast dich noch für keine Kurse eingeschrieben",
"You do not have permission to access this course": "",
"Load More": "",
"No Courses Found": "",
"Load More": "Mehr Laden",
"No Courses Found": "Keine Kurse gefunden",
"There are no Downloads to display": "Keine Downloads zum Anzeigen",
"Remember, you will only be able to see the courses you are enrolled in": "",
"This account has been identified with a subscription plan": "",
"This account was identified without a subscription plan": "",
Expand Down
5 changes: 3 additions & 2 deletions app/locale/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"Loading Courses": "Cargando cursos",
"You have not enrolled in any course": "No estás suscripto en ningún curso",
"You do not have permission to access this course": "",
"Load More": "",
"No Courses Found": "",
"Load More": "Cargar más",
"No Courses Found": "No se encontraron cursos",
"There are no Downloads to display": "No hay descargas para mostrar",
"Remember, you will only be able to see the courses you are enrolled in": "",
"This account has been identified with a subscription plan": "",
"This account was identified without a subscription plan": "",
Expand Down
5 changes: 3 additions & 2 deletions app/locale/fa.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"Loading Courses": "در حال لود کردن دوره",
"You have not enrolled in any course": "در هیچ دوره ای ثبت نام نکرده اید",
"You do not have permission to access this course": "",
"Load More": "",
"No Courses Found": "",
"Load More": "بارگذاری بیشتر",
"No Courses Found": "هیچ دوره ای یافت نشد",
"There are no Downloads to display": "هیچ دانلودی برای نمایش وجود ندارد",
"Remember, you will only be able to see the courses you are enrolled in": "",
"This account has been identified with a subscription plan": "",
"This account was identified without a subscription plan": "",
Expand Down
5 changes: 3 additions & 2 deletions app/locale/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"Loading Courses": "Chargement des cours",
"You have not enrolled in any course": "Vous n'êtes inscrit à aucun cours",
"You do not have permission to access this course": "",
"Load More": "",
"No Courses Found": "",
"Load More": "Charger plus",
"No Courses Found": "Aucun cours n'a été trouvé",
"There are no Downloads to display": "Il n'y a pas de telechargement à afficher",
"Remember, you will only be able to see the courses you are enrolled in": "",
"This account has been identified with a subscription plan": "",
"This account was identified without a subscription plan": "",
Expand Down
5 changes: 3 additions & 2 deletions app/locale/gr.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"Loading Courses": "Φόρτωση Μαθημάτων",
"You have not enrolled in any course": "Δεν έχετε εγγραφεί σε κάποιο μάθημα",
"You do not have permission to access this course": "",
"Load More": "",
"No Courses Found": "",
"Load More": "Φόρτωση Περισσότερων",
"No Courses Found": "Δεν βρέθηκαν μαθηματα",
"There are no Downloads to display": "Δεν χρένουν λήψεις για να εμφανίζονται",
"Remember, you will only be able to see the courses you are enrolled in": "",
"This account has been identified with a subscription plan": "",
"This account was identified without a subscription plan": "",
Expand Down
7 changes: 4 additions & 3 deletions app/locale/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
"Loading Courses": "पाठ्यक्रम लोड हो रहे हैं",
"You have not enrolled in any course": "आप किसी भी पाठ्यक्रम में नामांकित नहीं हैं",
"You do not have permission to access this course": "",
"Load More": "",
"No Courses Found": "",
"Load More": "अधिक लोड करें",
"No Courses Found": "कोई पाठ्यक्रम नहीं मिला",
"There are no Downloads to display": "डाउनलोड नहीं हैं",
"Remember, you will only be able to see the courses you are enrolled in": "",
"This account has been identified with a subscription plan": "",
"This account was identified without a subscription plan": "",
"If it's wrong, change the search mode and try again": "",
"Change search mode": "",
"Change search mode": "खोज मोड बदलें",
"Getting Info": "जानकारी एकत्रित की जा रही है",
"Courses": "मेरे पाठ्यक्रम",
"Building Course Data": "पाठ्यक्रम डेटा लोड हो रहा है",
Expand Down
5 changes: 3 additions & 2 deletions app/locale/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"Loading Courses": "Kuruzsok betöltése",
"You have not enrolled in any course": "Nem iratkoztál még fel egyetlen egy kurzusra sem",
"You do not have permission to access this course": "",
"Load More": "",
"No Courses Found": "",
"Load More": "Kuruzsok betöltése",
"No Courses Found": "Nincs találat",
"There are no Downloads to display": "Nincs letöltés a megjelenítésehez",
"Remember, you will only be able to see the courses you are enrolled in": "",
"This account has been identified with a subscription plan": "",
"This account was identified without a subscription plan": "",
Expand Down
5 changes: 3 additions & 2 deletions app/locale/id.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"Loading Courses": "Kursus sedang dimuat",
"You have not enrolled in any course": "Anda belum mendaftar untuk kursus apa pun",
"You do not have permission to access this course": "",
"Load More": "",
"No Courses Found": "",
"Load More": "Muat Lagi",
"No Courses Found": "Tidak ada kursus yang ditemukan",
"There are no Downloads to display": "Tidak ada unduhan yang ditampilkan untuk ditampilkan",
"Remember, you will only be able to see the courses you are enrolled in": "",
"This account has been identified with a subscription plan": "",
"This account was identified without a subscription plan": "",
Expand Down
5 changes: 3 additions & 2 deletions app/locale/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"Loading Courses": "Caricamento Corsi",
"You have not enrolled in any course": "Non sei iscritto a nessun corso",
"You do not have permission to access this course": "",
"Load More": "",
"No Courses Found": "",
"Load More": "Carica Piu'",
"No Courses Found": "Nessun Corso Trovato",
"There are no Downloads to display": "Non ci sono download da visualizzare",
"Remember, you will only be able to see the courses you are enrolled in": "",
"This account has been identified with a subscription plan": "",
"This account was identified without a subscription plan": "",
Expand Down
5 changes: 3 additions & 2 deletions app/locale/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"Loading Courses": "コースをロードしています",
"You have not enrolled in any course": "何もコースを登録していません",
"You do not have permission to access this course": "",
"Load More": "",
"No Courses Found": "",
"Load More": "もっと表示",
"No Courses Found": "コースが見つかりません",
"There are no Downloads to display": "ダウンロードが表示されません",
"Remember, you will only be able to see the courses you are enrolled in": "",
"This account has been identified with a subscription plan": "",
"This account was identified without a subscription plan": "",
Expand Down
1 change: 1 addition & 0 deletions app/locale/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"You do not have permission to access this course": "해당 강의에 접근할 수 있는 권한이 없습니다",
"Load More": "더 불러오기",
"No Courses Found": "강의를 찾을 수 없습니다",
"There are no Downloads to display": "다운로드 중",
"Remember, you will only be able to see the courses you are enrolled in": "기억하세요, 수강하고 있는 강의만 다운로드 할 수 있습니다.",
"This account has been identified with a subscription plan": "이 계정은 구독 플랜이 있는 계정입니다",
"This account was identified without a subscription plan": "이 계정은 구독 플랜이 없는 계정입니다",
Expand Down
5 changes: 3 additions & 2 deletions app/locale/ms.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"Loading Courses": "Memuatkan Kursus",
"You have not enrolled in any course": "Anda tidak mendaftar dalam mana-mana kursus",
"You do not have permission to access this course": "",
"Load More": "",
"No Courses Found": "",
"Load More": "Muat Lagi",
"No Courses Found": "Tidak ada kursus yang ditemukan",
"There are no Downloads to display": "Tiada fail untuk ditampilkan",
"Remember, you will only be able to see the courses you are enrolled in": "",
"This account has been identified with a subscription plan": "",
"This account was identified without a subscription plan": "",
Expand Down
5 changes: 3 additions & 2 deletions app/locale/my.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"Loading Courses": "သင်ခန်းစာများကို ဖွင့်နေသည်",
"You have not enrolled in any course": "မည်သည့်သင်တန်းတွင်မှ စာရင်းဝင်မထားပါ",
"You do not have permission to access this course": "",
"Load More": "",
"No Courses Found": "",
"Load More": "ပြန်လည်ရန်",
"No Courses Found": "မည်သည့်သင်တန်းများ ရှာမတွေ့ပါ",
"There are no Downloads to display": "ရှာဖွေ့ပါသည် ဒေါင်းလုပ်နေသည်",
"Remember, you will only be able to see the courses you are enrolled in": "",
"This account has been identified with a subscription plan": "",
"This account was identified without a subscription plan": "",
Expand Down
5 changes: 3 additions & 2 deletions app/locale/pa.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"Loading Courses": "ਪਾਠਕ੍ਰਮ ਲੋਭ ਕਿਤੇ ਜਾ ਰਹੇ ਹਨ ",
"You have not enrolled in any course": "ਤੁਸੀਂ ਕਿਸੇ ਵੀ ਕੋਰਸ ਵਿੱਚ ਨਹੀਂ ਹੋ ",
"You do not have permission to access this course": "",
"Load More": "",
"No Courses Found": "",
"Load More": "ਹੋਰ ਲੋਡ ਕਰੋ ",
"No Courses Found": "ਕੋਈ ਪਾਠਕ੍ਰਮ ਨਹੀਂ ਹੈ ",
"There are no Downloads to display": "ਡਾਉਨਲੋਡ ਦਿਖਾਈ ਨਹੀਂ ਹੈ ",
"Remember, you will only be able to see the courses you are enrolled in": "",
"This account has been identified with a subscription plan": "",
"This account was identified without a subscription plan": "",
Expand Down
5 changes: 3 additions & 2 deletions app/locale/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@
"Loading Courses": "Wczytywanie kursów",
"You have not enrolled in any course": "Nie zapisałeś/aś się na żadne kursy",
"You do not have permission to access this course": "",
"Load More": "",
"No Courses Found": "",
"Load More": "Załaduj wiecej",
"No Courses Found": "Nie znaleziono kursów",
"There are no Downloads to display": "Nie ma pobranych plików do wyswietlenia",
"Remember, you will only be able to see the courses you are enrolled in": "",
"This account has been identified with a subscription plan": "",
"This account was identified without a subscription plan": "",
Expand Down
1 change: 1 addition & 0 deletions app/locale/pt_BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"You do not have permission to access this course": "Você não tem permissão para acessar este curso",
"Load More": "Carregar mais",
"No Courses Found": "Não foi encontrado nenhum curso",
"There are no Downloads to display": "Não foi encontrado nenhum Download para exibir",
"Remember, you will only be able to see the courses you are enrolled in": "Lembre-se, você só poderá ver os cursos em que está matriculado",
"This account has been identified with a subscription plan": "Esta conta foi identificada com um plano de assinatura",
"This account was identified without a subscription plan": "Esta conta foi identificada sem um plano de assinatura",
Expand Down
Loading

0 comments on commit 53a0870

Please sign in to comment.