Last active
December 10, 2020 08:42
-
-
Save i64/15541e717ccc25576d5f57dcc1e3116b to your computer and use it in GitHub Desktop.
dersKayit2table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let gen = NaN; | |
const saatDict = { | |
'08:10': '08:50', | |
'09:00': '09:40', | |
'09:50': '10:30', | |
'10:40': '11:20', | |
'11:30': '12:10', | |
'13:00': '13:40', | |
'13:50': '14:30', | |
'14:40': '15:20', | |
'15:30': '16:10', | |
'16:20': '17:00' | |
}; | |
const dersProgrami = { | |
'08:10': { | |
'Pazartesi': '', | |
'Salı': '', | |
'Çarşamba': '', | |
'Perşembe': '', | |
'Cuma': '' | |
}, | |
'09:00': { | |
'Pazartesi': '', | |
'Salı': '', | |
'Çarşamba': '', | |
'Perşembe': '', | |
'Cuma': '' | |
}, | |
'09:50': { | |
'Pazartesi': '', | |
'Salı': '', | |
'Çarşamba': '', | |
'Perşembe': '', | |
'Cuma': '' | |
}, | |
'10:40': { | |
'Pazartesi': '', | |
'Salı': '', | |
'Çarşamba': '', | |
'Perşembe': '', | |
'Cuma': '' | |
}, | |
'11:30': { | |
'Pazartesi': '', | |
'Salı': '', | |
'Çarşamba': '', | |
'Perşembe': '', | |
'Cuma': '' | |
}, | |
'13:00': { | |
'Pazartesi': '', | |
'Salı': '', | |
'Çarşamba': '', | |
'Perşembe': '', | |
'Cuma': '' | |
}, | |
'13:50': { | |
'Pazartesi': '', | |
'Salı': '', | |
'Çarşamba': '', | |
'Perşembe': '', | |
'Cuma': '' | |
}, | |
'14:40': { | |
'Pazartesi': '', | |
'Salı': '', | |
'Çarşamba': '', | |
'Perşembe': '', | |
'Cuma': '' | |
}, | |
'15:30': { | |
'Pazartesi': '', | |
'Salı': '', | |
'Çarşamba': '', | |
'Perşembe': '', | |
'Cuma': '' | |
}, | |
'16:20': { | |
'Pazartesi': '', | |
'Salı': '', | |
'Çarşamba': '', | |
'Perşembe': '', | |
'Cuma': '' | |
} | |
} | |
const dictDurum = { | |
1: { | |
notf: '(Alttan)', | |
yazi: 'kirmiziYazi' | |
}, | |
2: { | |
notf: '(Alttan, Zorunlu)', | |
yazi: 'turuncuYazi' | |
}, | |
3: { | |
notf: '', | |
yazi: 'yesilYazi' | |
}, | |
6: { | |
notf: '(ÜSTTEN)', | |
yazi: 'kirmiziYazi' | |
}, | |
7: { | |
notf: '(Not Yukseltme)', | |
yazi: 'griYazi' | |
} | |
}; | |
function getGen() { | |
let dom = document.querySelectorAll('div'); | |
for (let index = 0; index < dom.length; index++) { | |
const element = dom[index]; | |
if (element.id.includes('-gp-durum')) { | |
gen = element.id.split('-')[1].slice(3); | |
break; | |
} | |
} | |
} | |
function funk(durum) { | |
let lock = true; | |
let notf = dictDurum[durum]['notf']; | |
let yazi = dictDurum[durum]['yazi']; | |
let genDurum = `#ext-gen${gen}-gp-durum-${durum}-bd`; | |
if ($(genDurum) != null) { | |
for (let index = 1; index <= $(genDurum).children.length; index++) { | |
let prefix = `${genDurum} > div:nth-child(${index}) > table > tbody`; | |
if ($(`${prefix} > tr.x-grid3-row-body-tr > td > div > div > span > span > span.kucukYazi.griYazi > span.maviYazi`)) { | |
dersIsmi = $(`${prefix} > tr:nth-child(1) > td.x-grid3-col.x-grid3-cell.x-grid3-td-1.undefined.${yazi} > div`).textContent; | |
raw = $(`${prefix} > tr.x-grid3-row-body-tr > td > div > div > span > span > span.kucukYazi.griYazi > span.maviYazi`).textContent; | |
zorunluluk = ''; | |
if ($(`${prefix} > tr:nth-child(1) > td.x-grid3-col.x-grid3-cell.x-grid3-td-2.undefined.kirmiziYazi > div`)) { | |
zorunluluk = $(`${prefix} > tr:nth-child(1) > td.x-grid3-col.x-grid3-cell.x-grid3-td-2.undefined.kirmiziYazi > div`).textContent; | |
} | |
gunler = raw.split(';'); | |
let oncekiGun = new Object(); | |
for (gun of gunler) { | |
icerik = gun.split(' '); | |
num = 0; | |
if (icerik[0] == '') { | |
num = 1; | |
} | |
if (icerik[0] == '' && icerik.length == 2) { | |
num = 0; | |
haftaGunu = oncekiGun['gun']; | |
zorunluluk = oncekiGun['zorunluluk'] | |
} else { | |
haftaGunu = icerik[num]; | |
} | |
oncekiGun['gun'] = haftaGunu; | |
oncekiGun['zorunluluk'] = zorunluluk; | |
saatler = icerik[num + 1].split('-'); | |
baslangic = saatler[0]; | |
bitis = saatler[1]; | |
feed = `${dersIsmi} ${zorunluluk=='Yok'?'D.Yok':''} ${notf}\n`; | |
if (saatDict[baslangic] != bitis) { | |
bitisStart = Object.keys(saatDict).find(key => saatDict[key] === saatler[1]); | |
for (key in saatDict) { | |
if ((key == baslangic) || (!lock) || (key == bitisStart)) { | |
dersProgrami[key][haftaGunu] += feed; | |
} | |
if (key == bitisStart) { | |
lock = true; | |
} | |
else if (key == baslangic) { | |
lock = false; | |
} | |
} | |
} else { | |
dersProgrami[baslangic][haftaGunu] += feed; | |
} | |
} | |
} | |
} | |
} | |
} | |
(function () { | |
getGen(); | |
Object.keys(dictDurum).find(key => funk(key)); | |
console.table(dersProgrami) | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment