// JavaScript Document $('.sparaBetyg').on('click', function() { sparaBetyg(); console.log("lol") }); function sparaBetyg() { var urlLink = "?"; $('form.kurser').find('div').each(function(){ subjectScores = parseFloat($(this).find("select").val()); subjectName = $(this).find("input.subjectName").val(); if (typeof subjectName !== 'undefined') { urlLink = urlLink + subjectName + "=" + subjectScores + "&"; } }); urlLink = urlLink + "mp=" + $('form').find('input.meritpoint').val(); urlLink = "https://" + window.location.hostname + window.location.pathname + urlLink; $('.link_span').remove(); $('.score_span').append('SparaSpara Länken som bokmärke för att kunna återvända till dina betygcontent_copy'); betygSelect(); } function betygSelect() { $('.betygLink').select(); } function copyLink() { betygSelect(); document.execCommand("Copy"); var snackbarContainer = document.querySelector('#linkCopyToast'); var data = {message: 'Länk kopierad till urklipp'}; snackbarContainer.MaterialSnackbar.showSnackbar(data); } function laddaBetyg() { var mp = getQueryVariable('mp'); if (!(isNaN(mp)) && mp) { $('form').find('input.meritpoint').val(mp); } $('form.kurser').find('div').each(function(){ var grade; var val; subjectName = $(this).find("input.subjectName").val(); if (typeof subjectName !== 'undefined') { subjectName = encodeURI(subjectName); if (getQueryVariable(subjectName) == 20) { grade = "A"; val = 20; } else if (getQueryVariable(subjectName) == '17.5') { grade = "B"; val = 17.5; } else if (getQueryVariable(subjectName) == "15") { grade = "C"; val = 15; } else if (getQueryVariable(subjectName) == '12.5') { grade = "D"; val = 12.5; } else if (getQueryVariable(subjectName) == '10') { grade = "E"; val = 10; } else if (getQueryVariable(subjectName) == '0') { grade = "F"; val = 0; } if (getQueryVariable(subjectName) !== false) { $(this).find('.select-dropdown').val(grade); $(this).find('.grade').val(val); } } }); raknaUtMeritvarde(); } function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i=0;i