From f029789e1106d120bfd233e6ce8058c5512e279a Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Wed, 18 Sep 2019 02:24:52 +0200
Subject: [PATCH 1/3] use jQuery to bind event
-> use JQuery to bind event on each
with a "data-sortt" attribute
---
sortt.js | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/sortt.js b/sortt.js
index 2510120..2dda20c 100644
--- a/sortt.js
+++ b/sortt.js
@@ -8,6 +8,22 @@
*/
+/////////////////////////////////////////////////
+// Be sure you already have loaded jQuery !!! //
+/////////////////////////////////////////////////
+
+
+//use JQuery to bind event on each | with a "data-sortt" attribute
+$('th').each(function() {
+ //console.log($(this));
+ 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]);
+ });
+});
+
+
//create global function with main routine
window.sortt=function(normsort,revsort,isdefault){
//sortTable [normsort] (revsort) (isdefault)
From 4e683380824543e055dffd072cbcf72f2b8302b9 Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Wed, 18 Sep 2019 02:29:57 +0200
Subject: [PATCH 2/3] JS check if jQuery is available
and dont trust the user ;)
---
sortt.js | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/sortt.js b/sortt.js
index 2dda20c..5487e6f 100644
--- a/sortt.js
+++ b/sortt.js
@@ -8,10 +8,12 @@
*/
-/////////////////////////////////////////////////
-// Be sure you already have loaded jQuery !!! //
-/////////////////////////////////////////////////
+// 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() {
@@ -23,6 +25,7 @@ $('th').each(function() {
});
});
+}
//create global function with main routine
window.sortt=function(normsort,revsort,isdefault){
From ff002275caf7840d1b5276236a99ff4dea096911 Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Wed, 18 Sep 2019 02:32:50 +0200
Subject: [PATCH 3/3] code format
---
sortt.js | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/sortt.js b/sortt.js
index 5487e6f..0c6c0bf 100644
--- a/sortt.js
+++ b/sortt.js
@@ -4,27 +4,24 @@
@License MIT
@Author 6543
@Repository https://gitea.com/6543/gitea_sortt
- @Version 1.1
+ @Version 1.2
*/
// test if jQuery is available
-if(!window.jQuery)
-{
+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() {
- //console.log($(this));
- 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]);
- });
-});
-
+ //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]);
+ });
+ });
}
//create global function with main routine
|