From 286c93ef56652f59b79766b9298b434c07616982 Mon Sep 17 00:00:00 2001 From: 6543 <6543@obermui.de> Date: Wed, 18 Sep 2019 20:40:05 +0200 Subject: [PATCH] first declare functions then use --- sortt.js | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/sortt.js b/sortt.js index 1943758..d85013d 100644 --- a/sortt.js +++ b/sortt.js @@ -8,21 +8,7 @@ */ - -// test if jQuery is available -if(!window.jQuery) { - console.log("sortt.js: ERROR no jQuery found!"); -} else { - - //use JQuery to bind event on each with a "data-sortt" attribute - $('th').each(function() { - if ($(this)[0].dataset.sortt) $(this).on('click', function(e) { - var data = $(this)[0].dataset.sortt; - data = data.split(","); - sortt(data[0],data[1],data[2]); - }); - }); -} +//Declare Functions //create global function with main routine window.sortt=function(normsort,revsort,isdefault){ @@ -58,3 +44,21 @@ window.sortt=function(normsort,revsort,isdefault){ //open url window.location.replace(url.href); }; + + +//USE Functions + +// test if jQuery is available +if(!window.jQuery) { + console.log("sortt.js: ERROR no jQuery found!"); +} else { + + //use JQuery to bind event on each with a "data-sortt" attribute + $('th').each(function() { + if ($(this)[0].dataset.sortt) $(this).on('click', function(e) { + var data = $(this)[0].dataset.sortt; + data = data.split(","); + sortt(data[0],data[1],data[2]); + }); + }); +}