diff options
author | marvin-borner@live.com | 2018-04-10 21:50:16 +0200 |
---|---|---|
committer | marvin-borner@live.com | 2018-04-10 21:54:48 +0200 |
commit | fc9401f04a3aca5abb22f87ebc210de8afe11d32 (patch) | |
tree | b0b310f3581764ec3955f4e496a05137a32951c3 /assets/js | |
parent | 286d643180672f20526f3dc3bd19d7b751e2fa97 (diff) |
Initial Commit
Diffstat (limited to 'assets/js')
-rw-r--r-- | assets/js/chat.js | 33 | ||||
-rw-r--r-- | assets/js/main.js | 93 |
2 files changed, 126 insertions, 0 deletions
diff --git a/assets/js/chat.js b/assets/js/chat.js new file mode 100644 index 0000000..1ea3471 --- /dev/null +++ b/assets/js/chat.js @@ -0,0 +1,33 @@ +var conn = new WebSocket('wss://marvinborner.ddnss.de:1337');
+conn.onopen = function () {
+ console.log("Chat connection established!");
+};
+
+conn.onmessage = function (e) {
+ document.getElementById("ChatResponses").innerHTML += e.data + "<br>";
+};
+
+$('#ChatTextInput').keyup(function (e) {
+ if (e.keyCode === 13) {
+ sendMessage($('#ChatTextInput').val());
+ $('#ChatTextInput').val("");
+ }
+});
+
+$('#SubscribeTextInput').keyup(function (e) {
+ if (e.keyCode === 13) {
+ subscribe($('#SubscribeTextInput').val());
+ }
+});
+
+function subscribe(channel) {
+ conn.send(JSON.stringify({command: "subscribe", channel: channel}));
+ $("#SubscribeTextInput").hide();
+ $("#ChatTextInput").show();
+ $("#ChatResponses").empty();
+}
+
+function sendMessage(msg) {
+ conn.send(JSON.stringify({command: "message", message: msg}));
+ $("#ChatTextInput").val("");
+}
diff --git a/assets/js/main.js b/assets/js/main.js new file mode 100644 index 0000000..b9cfe34 --- /dev/null +++ b/assets/js/main.js @@ -0,0 +1,93 @@ +/******
+ GENERAL
+ ******/
+
+/*****
+ NAVBAR
+ *****/
+var $el, leftPos, newWidth,
+ $mainNav = $(".Navbar");
+$mainNav.append("<span class='NavbarLine'></span>");
+var $magicLine = $(".NavbarLine");
+$magicLine
+ .css("left", $(".ActiveTab").position().left)
+ .data("origLeft", $magicLine.position().left)
+ .data("origWidth", $magicLine.width());
+$(".NavbarIconWrap").on("click", function () {
+ $(".NavbarIconWrap").removeClass("ActiveTab");
+ $(this).addClass("ActiveTab");
+ var index = $(this).attr('id');
+ $('.MainTabWindows').slick('slickGoTo',index);
+ //$('.MainTabWindows').flickity().flickity('select', index);
+
+ $el = $(this);
+ leftPos = $el.position().left;
+ $magicLine.stop().animate({
+ left: leftPos,
+ width: newWidth,
+ }, 300);
+});
+
+/*******
+FLICKITY
+*******/
+$('.MainTabWindows').slick({
+ initialSlide: 2,
+ mobileFirst: true,
+ nextArrow: "",
+ prevArrow: "",
+ infinite: false,
+ zIndex: 500
+});
+
+$('.MainTabWindows').on('beforeChange', function(event, slick, currentSlide, nextSlide){
+ //console.log(nextSlide);
+ $(".NavbarIconWrap").removeClass("ActiveTab");
+ $el = $("#" + nextSlide);
+ $el.addClass("ActiveTab");
+ leftPos = $el.position().left;
+ $magicLine.stop().animate({
+ left: leftPos,
+ width: newWidth
+ }, 300);
+});
+
+/*
+$('.MainTabWindows').flickity({
+ cellAlign: 'left',
+ prevNextButtons: false,
+ pageDots: false,
+ friction: 0.3,
+ dragThreshold: ($("body").width() * 0.5),
+ initialIndex: 2,
+ wrapAround: true,
+ maxSwipeWidth: 0,
+ on: {
+ change: function (index) {
+ $(".NavbarIconWrap").removeClass("ActiveTab");
+ $el = $("#" + index);
+ $el.addClass("ActiveTab");
+ leftPos = $el.position().left;
+ $magicLine.stop().animate({
+ left: leftPos,
+ width: newWidth
+ }, 300);
+ },
+ dragStart: function () {
+ $(".ActiveTab").css({ transform: 'scale(1.05)' });
+ },
+ dragEnd: function () {
+ $(".NavbarIconWrap").css({ transform: 'scale(1.0)' });
+ }/*,
+ scroll: function (event, progress) {
+ var TotalWidth = $("body").width();
+ console.log(progress / 10);
+ leftPos = ((progress / 1000) * TotalWidth + 'px');
+ $magicLine.stop().animate({
+ left: leftPos,
+ width: newWidth
+ });
+ }*
+ }
+});
+*/
\ No newline at end of file |