update jquery and some functions

This commit is contained in:
Felix Schulze 2019-09-25 19:12:15 +02:00
parent a934e14f66
commit d8e81c07b6
4 changed files with 22 additions and 21 deletions

View File

@ -25,11 +25,11 @@ $(document).ready(function() {
$('form').change(function() { $('form').change(function() {
raknaUtMeritvarde(); raknaUtMeritvarde();
}); });
$('.add_row').live('click', function() { $('.add_row').on('click', function() {
$('div.sample_row > div').clone().appendTo('form.courses'); $('div.sample_row > div').clone().appendTo('form.courses');
raknaUtMeritvarde(); raknaUtMeritvarde();
}); });
$('.delete_row').live('click', function() { $('.delete_row').on('click', function() {
$(this).parent().slideUp(function() { $(this).parent().slideUp(function() {
$(this).remove(); $(this).remove();
raknaUtMeritvarde(); raknaUtMeritvarde();
@ -65,17 +65,17 @@ function raknaUtMeritvarde() {
} }
$('.score_span').html(''); $('.score_span').html('');
if (totalPoints > 2400) { if (totalPoints > 2400) {
$('.score_span').append('<div class="demo-card-square mdl-card mdl-shadow--16dp" style="text-align:left;width:260px; height:auto;margin:50px auto 0;"><div class="mdl-card__title"><h2 class="mdl-card__title-text" style="font-size:28px;">Ditt meritvärde är ' + totalScore + '</h2></div><div class="mdl-card__supporting-text">Ditt Snittbetyg av ' + totalPoints + ' Poäng (+100 poäng för Gymnasiearbete) ger meritvärdet: ' + totalScore + '<p style="color:#d50000;text-align:unset;font-weight:unset;">Du har över 2400 poäng och måste därför välja bort ' + (totalPoints - 2400) + ' poäng</p></div><div class="mdl-card__actions mdl-card--border"><a class="sparaBetyg mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--primary">Spara</a><a class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--accent" href="/">Till Startsidan</a></div></div>'); $('.score_span').append('<div class="demo-card-square mdl-card mdl-shadow--16dp" style="text-align:left;width:260px; height:auto;margin:50px auto 0;"><div class="mdl-card__title"><h2 class="mdl-card__title-text" style="font-size:28px;">Ditt meritvärde är ' + totalScore + '</h2></div><div class="mdl-card__supporting-text">Ditt Snittbetyg av ' + totalPoints + ' Poäng (+100 poäng för Gymnasiearbete) ger meritvärdet: ' + totalScore + '<p style="color:#d50000;text-align:unset;font-weight:unset;">Du har över 2400 poäng och måste därför välja bort ' + (totalPoints - 2400) + ' poäng</p></div><div class="mdl-card__actions mdl-card--border"><a onClick="sparaBetyg()" class="sparaBetyg mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--primary">Spara</a><a class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--accent" href="/">Till Startsidan</a></div></div>');
} else { } else {
$('.score_span').append('<div class="demo-card-square mdl-card mdl-shadow--16dp" style="text-align:left;width:260px; height:auto;margin:50px auto 0;"><div class="mdl-card__title"><h2 class="mdl-card__title-text" style="font-size:28px;">Ditt meritvärde är ' + totalScore + '</h2></div><div class="mdl-card__supporting-text">Ditt Snittbetyg av ' + totalPoints + ' Poäng (+100 poäng för Gymnasiearbete) ger meritvärdet: ' + totalScore + '</div><div class="mdl-card__actions mdl-card--border"><a class="sparaBetyg mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--primary">Spara</a><a class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--accent" href="/">Till Startsidan</a></div></div>'); $('.score_span').append('<div class="demo-card-square mdl-card mdl-shadow--16dp" style="text-align:left;width:260px; height:auto;margin:50px auto 0;"><div class="mdl-card__title"><h2 class="mdl-card__title-text" style="font-size:28px;">Ditt meritvärde är ' + totalScore + '</h2></div><div class="mdl-card__supporting-text">Ditt Snittbetyg av ' + totalPoints + ' Poäng (+100 poäng för Gymnasiearbete) ger meritvärdet: ' + totalScore + '</div><div class="mdl-card__actions mdl-card--border"><a onClick="sparaBetyg()" class="sparaBetyg mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--primary">Spara</a><a class="mdl-button mdl-js-button mdl-js-ripple-effect mdl-button--accent" href="/">Till Startsidan</a></div></div>');
} }
//title set //title set
if (courseTitle === false) { if (courseTitle === false) {
courseTitle = document.title; courseTitle = document.title;
} }
var newDocTitle = courseTitle + ' - ' + totalScore; var newDocTitle = courseTitle + ' - ' + totalScore;
document.title = newDocTitle; document.title = newDocTitle;
var urlLink = "?"; var urlLink = "?";
$('form.kurser').find('div').each(function(){ $('form.kurser').find('div').each(function(){
subjectScores = parseFloat($(this).find("select").val()); subjectScores = parseFloat($(this).find("select").val());
@ -87,4 +87,4 @@ function raknaUtMeritvarde() {
urlLink = urlLink + "mp=" + $('form').find('input.meritpoint').val(); urlLink = urlLink + "mp=" + $('form').find('input.meritpoint').val();
urlLink = "https://" + window.location.hostname + window.location.pathname + urlLink; urlLink = "https://" + window.location.hostname + window.location.pathname + urlLink;
window.history.pushState("", newDocTitle, urlLink); window.history.pushState("", newDocTitle, urlLink);
} }

View File

@ -1,4 +1,4 @@
$('.changeall').live('click', function(){ $('.changeall').on('click', function(){
var grade; var grade;
var val; var val;
if (document.getElementById('option-1').checked) { if (document.getElementById('option-1').checked) {
@ -20,10 +20,10 @@ $('.changeall').live('click', function(){
grade = "F"; grade = "F";
val = 0; val = 0;
} }
$('form.kurser').find('div').each(function(){ $('form.kurser').find('div').each(function(){
$('.select-dropdown').val(grade); $('.select-dropdown').val(grade);
$('.grade').val(val); $('.grade').val(val);
}); });
raknaUtMeritvarde(); raknaUtMeritvarde();
}); });

View File

@ -1,6 +1,7 @@
// JavaScript Document // JavaScript Document
$('.sparaBetyg').live('click', function(){ $('.sparaBetyg').on('click', function() {
sparaBetyg(); sparaBetyg();
console.log("lol")
}); });
function sparaBetyg() { function sparaBetyg() {
var urlLink = "?"; var urlLink = "?";
@ -14,7 +15,7 @@ function sparaBetyg() {
urlLink = urlLink + "mp=" + $('form').find('input.meritpoint').val(); urlLink = urlLink + "mp=" + $('form').find('input.meritpoint').val();
urlLink = "https://" + window.location.hostname + window.location.pathname + urlLink; urlLink = "https://" + window.location.hostname + window.location.pathname + urlLink;
$('.link_span').remove(); $('.link_span').remove();
$('.score_span').append('<span class="link_span"><div class="demo-card-square mdl-card mdl-shadow--16dp" style="text-align:left;width:260px; height:auto;margin:50px auto 0;"><div class="mdl-card__title"><h2 class="mdl-card__title-text" style="font-size:28px;">Spara</h2></div><div class="mdl-card__supporting-text">Spara Länken som bokmärke för att kunna återvända till dina betyg</div><div class="mdl-card__actions mdl-card--border" style="padding: 4px 16px 8px;"><div style="padding:0; width:125px;" class="mdl-textfield mdl-js-textfield"><input readonly style="margin: 0 0 8px 0; border-bottom: 1px solid #26a69a; box-shadow: 0 1px 0 0 #26a69a;" class="mdl-textfield__input betygLink" id="betygLink" type="text" value="'+ urlLink +'" onClick="betygSelect()"><label class="mdl-textfield__label" for="betygLink"></label></div><i class="material-icons mdl-button--primary" onClick="copyLink()" style="margin:12px 16px; cursor: pointer; position: absolute; right:0;">content_copy</i></div></div></span>'); $('.score_span').append('<span class="link_span"><div class="demo-card-square mdl-card mdl-shadow--16dp" style="text-align:left;width:260px; height:auto;margin:50px auto 0;"><div class="mdl-card__title"><h2 class="mdl-card__title-text" style="font-size:28px;">Spara</h2></div><div class="mdl-card__supporting-text">Spara Länken som bokmärke för att kunna återvända till dina betyg</div><div class="mdl-card__actions mdl-card--border" style="padding: 4px 16px 8px;"><div style="padding:0; width:125px;" class="mdl-textfield mdl-js-textfield"><input readonly style="margin: 0 0 8px 0; border-bottom: 1px solid #26a69a; box-shadow: 0 1px 0 0 #26a69a;" class="mdl-textfield__input betygLink" id="betygLink" type="text" value="'+ urlLink +'" onClick="betygSelect()"><label class="mdl-textfield__label" for="betygLink"></label></div><i class="material-icons mdl-button--primary" onClick="copyLink()" style="margin:12px 16px; cursor: pointer; position: absolute; right:0;">content_copy</i></div></div></span>');
betygSelect(); betygSelect();
} }
@ -24,7 +25,7 @@ function betygSelect() {
function copyLink() { function copyLink() {
betygSelect(); betygSelect();
document.execCommand("Copy"); document.execCommand("Copy");
var snackbarContainer = document.querySelector('#linkCopyToast'); var snackbarContainer = document.querySelector('#linkCopyToast');
var data = {message: 'Länk kopierad till urklipp'}; var data = {message: 'Länk kopierad till urklipp'};
snackbarContainer.MaterialSnackbar.showSnackbar(data); snackbarContainer.MaterialSnackbar.showSnackbar(data);
@ -39,11 +40,11 @@ function laddaBetyg() {
var grade; var grade;
var val; var val;
subjectName = $(this).find("input.subjectName").val(); subjectName = $(this).find("input.subjectName").val();
if (typeof subjectName !== 'undefined') { if (typeof subjectName !== 'undefined') {
subjectName = encodeURI(subjectName); subjectName = encodeURI(subjectName);
if (getQueryVariable(subjectName) == 20) { if (getQueryVariable(subjectName) == 20) {
grade = "A"; grade = "A";
val = 20; val = 20;
@ -81,4 +82,4 @@ function getQueryVariable(variable)
if(pair[0] == variable){return pair[1];} if(pair[0] == variable){return pair[1];}
} }
return(false); return(false);
} }

View File

@ -1,12 +1,12 @@
<?php <?php
echo " echo "
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js'></script> <script src='https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js'></script>
<script src='https://code.getmdl.io/1.3.0/material.min.js'></script> <script src='https://code.getmdl.io/1.3.0/material.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.2/js/materialize.min.js'></script> <script src='https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.2/js/materialize.min.js'></script>
<script src='assets/js/loader.min.js?v=1.6'></script> <script src='assets/js/loader.min.js?v=1.6'></script>
<script src='assets/js/calcscript.js?v=1.6'></script> <script src='assets/js/calcscript.js?v=1.8'></script>
<script src='assets/js/changeall.js?v=1.6'></script> <script src='assets/js/changeall.js?v=1.8'></script>
<script src='assets/js/sparabetyg.js?v=1.6'></script> <script src='assets/js/sparabetyg.js?v=1.10'></script>
<script> <script>
$(document).ready(function() { $(document).ready(function() {