.burger-icon { width: 200px; height: 200px; /* taille du SVG */ border: 2px dotted #ddd; /* bordure = simple repère */ } Le tracé de notre premier rectangle est un jeu d’enfant aussi : l’élément SVG rect est fait pour ça, attribuons-lui des coordonnées (x=0 et y=0) ainsi qu’une largeur de "100" et une hauteur de "20". Vous aurez compris qu’à partir d’un premier rectangle, il n’est pas difficile de produire les deux suivants. Et voilà ! Pour ce qui est des coins arrondis, là aussi SVG a tout prévu sous la forme de l’attribut rx, à qui une valeur de "5" semble tout à fait parfaite. Le résultat est bluffant et on se rend compte de la puissance insoupçonnée d’un éditeur de code. Plus sérieusement, ce n’était vraiment pas compliqué, non ? Par contre, ce qui est vraiment dommage c’est de répéter les mêmes choses plusieurs fois… Mais justement, il se trouve que… la plupart des attributs SVG existent également sous forme de propriétés CSS ! Voici par conséquent comment nous allons pouvoir améliorer notre code actuel : rect { x: 0; rx: 5px; width: 100px; height: 20px; } .rect-1 { y: 0; } .rect-2 { y: 40px; } .rect-3 { y: 80px; } Autre avantage loin d’être anodin, ces propriétés CSS-SVG ont la bonne idée d’être animables : on peut par exemple effectuer une transition sur la propriété… y ! rect { ... transition: y 1s; } .rect-1:hover { y: 15px; } 2. Préparer le SVG et le rendre accessible Nous allons à présent nous atteler à transformer notre icône SVG en un véritable "bouton Burger", fonctionnel et accessible. Pour ce faire, on commence par placer le SVG dans un Notre icône SVG est considérée comme purement décorative, car c’est le bouton qui portera l’information. Nous veillons à lui appliquer les attributs suivants : Un attribut aria-hidden="true" Un attribut focusable="false" pour éviter de naviguer au sein du SVG. Aucun élément ni <desc> ni d’attribut title, aria-label, aria-labelledby, ni role="img" ... <svg class="burger-icon" aria-hidden="true" focusable="false" viewBox="0 0 100 100"> </svg> ... Le bouton, quant à lui, nécessite les éléments suivants : Un nom accessible (via aria-label ou un texte masqué à la ".sr-only") En option, et selon les cas de figure, un attribut aria-controls pour lier à la cible et un attribut aria-expanded pour signaler l’état du bouton. Dans notre cas, ce n’est pas néessaire. <button class="burger-button" aria-label="Menu" data-expanded="false"> ... </button> Voici le script JavaScript destiné à gérer l’interaction et la mise à jour des attributs data-, et déclencher l’animation de l’icône : (function () { function toggleNav() { // Define targets const button = document.querySelector(’.burger-button’); const target = document.querySelector(’#navigation’); button.addEventListener(’click’, () => { const currentState = target.getAttribute("data-state"); if (!currentState || currentState === "closed") { target.setAttribute("data-state", "opened"); button.setAttribute("data-expanded", "true"); } else { target.setAttribute("data-state", "closed"); button.setAttribute("data-expanded", "false"); } }); } // end toggleNav() toggleNav(); }()); Pouquoi JavaScript ? Très sincèrement parce que c’est son job de déclencher des actions au clic et de modifier des classes ou des attibuts en conséquence. Cette mission aurait été réalisable en CSS au moyen de cases à cocher mais, ne nous mentons pas, c’est un peu de la bidouille. 3. Les étapes de l’animation Pour être très précis, nous n’allons pas employer une "animation" pour nos effets, mais une combinaison de trois "transitions", qui se révèleront amplement suffisantes pour notre besoin. Voici le scénario étape par étape qui doit se réaliser : L’action de clic ou de touch sur l’élément button doit déclencher une série de trois transitions; La transition 1 consiste en un déplacement vertical de .rect-1 et .rect-3 qui se rejoignent au centre du SVG; La transition 2 consiste à faire disparaître .rect-2 qui traîne dans nos pattes. En terme de timing, cette transition doit se dérouler en même temps que la transition 1; La transition 3 se compose d’une rotation de 45 degrés de .rect-1 et .rect-3 et doit de déclencher juste après les transitions précédentes). Transition 1 et 2 : "translate" et "opacity" La propriété transitionest appliquée sur l’élément à l’état initial (hors événement) afin d’assurer une transition au retour lorsque l’événement est quitté. /* transition sur la propriété y et opacity, durée 0.3s */ rect { transition: y 0.3s, opacity 0.3s; } /* coordonnées y initiales */ .rect-1 { y: 0; } .rect-2 { y: 40px; } .rect-3 { y: 80px; } Au clic, le bouton passe en data-expanded "true" et on déplace verticalement deux rectangles au centre et on masque le 3e rectangle central. [data-expanded="true"] .rect-1 { y: 40px; } [data-expanded="true"] .rect-2 { opacity: 0; } [data-expanded="true"] .rect-3 { y: 40px; } Transition 3 : "rotate" Aux deux transitions précédentes, on ajoute une transition sur la propriété rotate sans oublier de la faire débuter après un léger délai. /* on attend un delai de 0.3s avant de commencer rotate */ rect { transition: y 0.3s, opacity 0.3s, rotate 0.3s 0.3s; } Au clic, les trois transitions se déclenchent. [data-expanded="true"] .rect-1 { y: 40px; rotate: 45deg; } [data-expanded="true"] .rect-2 { opacity: 0; } [data-expanded="true"] .rect-3 { y: 40px; rotate: -45deg; } ⚠️ J’imagine que cela ne vous a pas échappé : tout se passe très bien à l’aller, mais malheureusement pas au retour. L’explication provient du fait que la transition se déroule dans le sens inverse au retour et que la rotation se déclenche trop tôt. Il va nous falloir une transition différente à l’aller et au retour et gérer des délais différents entre la transition et la rotation. /* transition au retour (quand on perd le clic) */ /* on attend un delai de 0.3s avant de commencer y */ rect { transition: y 0.3s 0.3s, opacity 0.3s, rotate 0.3s; } /* transition à l’aller (quand on clique) */ /* on attend un delai de 0.3s avant de commencer rotate */ [data-expanded="true"] rect { transition: y 0.3s, opacity 0.3s, rotate 0.3s 0.3s; } Grâce à cette adaptation subtile, notre effet fonctionne parfaitement à l’aller et au retour lors de l’interaction. Pour finir en beauté, le truc en plus consiste en une petite accélération sous forme de cubic-bezier pour un effet de "rebond". [data-expanded="true"] rect { transition: y 0.3s, opacity 0.3s, rotate 0.3s 0.3s cubic-bezier(.55,-0.65,0,2.32); } CSS final Voici les styles CSS complets de ce tutoriel. Notez qu’ils prennent en compte les préférences utilisateur grâce au media query prefers-reduced-motion : si la personne a choisi dans ses réglages système de réduire les animations, celles-ci ne seront tout simplement pas déclenchées. Pour voir le résultat et aller plus loin, une petite collection CodePen de boutons burger animés a été rassemblée à cette adresse : https://codepen.io/collection/VYqwJK .rect-1 { y: 0; } .rect-2 { y: 40px; } .rect-3 { y: 80px; } [data-expanded="true"] .rect-1 { y: 40px; rotate: 45deg; } [data-expanded="true"] .rect-2 { opacity: 0; } [data-expanded="true"] .rect-3 { y: 40px; rotate: -45deg; } /* transitions si acceptées */ @media (prefers-reduced-motion: no-preference) { rect { transition: y 0.3s 0.3s, opacity 0.3s, rotate 0.3s; } [data-expanded="true"] rect { transition: y 0.3s, opacity 0.3s, rotate 0.3s 0.3s cubic-bezier(.55,-0.65,0,2.32); } } Retrouvez l’intégralité de ce tutoriel en ligne sur Alsacreations.com"> <meta property="og:image" content="https://feedbot.net/storage/thumbnails/2023_12/1b9392230da6166d97e929c0d06e3cd4-2bb58e10e10418b365be670dfe51b0f8.jpg"> <meta name="twitter:card" content="summary_large_image"> <meta name="twitter:site" content="@feedbotnet"> <meta name="twitter:title" content="Animer un bouton burger simple avec SVG et CSS"> <meta property="twitter:description" content="Le format SVG peut paraître parfois un peu intimidant, et l’associer à des transitions ou des animations CSS semble encore plus audacieux pour bon nombre de personnes. Cependant, dans certains cas, l’alchimie entre SVG et CSS est aussi bénéfique qu’extrêmement simple à mettre en oeuvre. Dans ce tutoriel, nous allons suivre étape par étape comment animer un bouton burger simple avec SVG et CSS. Quels outils ? La liste des outils nécessaires pour atteindre nos objectifs est particulièrement réduite puisqu’un simple éditeur de code fait le job (n’importe lequel fait l’affaire, Visual Studio Code étant mon choix personnel). Pour aller plus loin, et en guise de bonus, on peut également piocher : Un éditeur SVG en ligne (parce que ça peut toujours servir) Des recommendations concernant l’accessibilité des SVG (au hasard les Guidelines Alsacréations) Un éditeur de courbes de Bezier (pour des animations originales) SVG c’est quoi ? En trois mots, voici comment résumer SVG : SVG est un format graphique vectoriel (composé de tracés et de courbes) Il est développé et maintenu depuis 1999 par le W3C (standard officiel, open source) Il est conçu en XML (compatible HTML) (on peut le créer et le lire avec un simple éditeur de texte) 1. Produire le burger bouton en SVG Si l’on y regarde de plus près, une "icône Burger" c’est bêtement trois rectangles horizontaux espacés et avec des coins arrondis. Notre éditeur de code préféré est amplement suffisant pour s’aquitter de la tâche de dessiner des rectangles : on va tout d’abord dessiner un élément SVG vide avec une fenêtre de "100 x 100". C’est une dimension purement indicative car tout est proportionnel et adaptable en SVG. <svg class="burger-icon" viewBox="0 0 100 100"> </svg> .burger-icon { width: 200px; height: 200px; /* taille du SVG */ border: 2px dotted #ddd; /* bordure = simple repère */ } Le tracé de notre premier rectangle est un jeu d’enfant aussi : l’élément SVG rect est fait pour ça, attribuons-lui des coordonnées (x=0 et y=0) ainsi qu’une largeur de "100" et une hauteur de "20". <svg class="burger-icon" viewBox="0 0 100 100"> <rect x="0" y="0" width="100" height="20" /> </svg> Vous aurez compris qu’à partir d’un premier rectangle, il n’est pas difficile de produire les deux suivants. Et voilà ! <svg class="burger-icon" viewBox="0 0 100 100"> <rect x="0" y="0" width="100" height="20" /> <rect x="0" y="40" width="100" height="20" /> <rect x="0" y="80" width="100" height="20" /> </svg> Pour ce qui est des coins arrondis, là aussi SVG a tout prévu sous la forme de l’attribut rx, à qui une valeur de "5" semble tout à fait parfaite. <svg class="burger-icon" viewBox="0 0 100 100"> <rect x="0" y="0" width="100" height="20" rx="5" /> <rect x="0" y="40" width="100" height="20" rx="5" /> <rect x="0" y="80" width="100" height="20" rx="5" /> </svg> Le résultat est bluffant et on se rend compte de la puissance insoupçonnée d’un éditeur de code. Plus sérieusement, ce n’était vraiment pas compliqué, non ? Par contre, ce qui est vraiment dommage c’est de répéter les mêmes choses plusieurs fois… Mais justement, il se trouve que… la plupart des attributs SVG existent également sous forme de propriétés CSS ! Voici par conséquent comment nous allons pouvoir améliorer notre code actuel : <svg class="burger-icon" viewBox="0 0 100 100"> <rect class="rect-1" /> <rect class="rect-2" /> <rect class="rect-3" /> </svg> rect { x: 0; rx: 5px; width: 100px; height: 20px; } .rect-1 { y: 0; } .rect-2 { y: 40px; } .rect-3 { y: 80px; } Autre avantage loin d’être anodin, ces propriétés CSS-SVG ont la bonne idée d’être animables : on peut par exemple effectuer une transition sur la propriété… y ! rect { ... transition: y 1s; } .rect-1:hover { y: 15px; } 2. Préparer le SVG et le rendre accessible Nous allons à présent nous atteler à transformer notre icône SVG en un véritable "bouton Burger", fonctionnel et accessible. Pour ce faire, on commence par placer le SVG dans un <button> qui sera l’élément interactif au clic / touch et qui déclenchera l’animation. <button class="burger-button"> <svg class="burger-icon" viewBox="0 0 100 100"> <rect class="rect-1" /> <rect class="rect-2" /> <rect class="rect-3" /> </svg> </button> Notre icône SVG est considérée comme purement décorative, car c’est le bouton qui portera l’information. Nous veillons à lui appliquer les attributs suivants : Un attribut aria-hidden="true" Un attribut focusable="false" pour éviter de naviguer au sein du SVG. Aucun élément <title> ni <desc> ni d’attribut title, aria-label, aria-labelledby, ni role="img" ... <svg class="burger-icon" aria-hidden="true" focusable="false" viewBox="0 0 100 100"> </svg> ... Le bouton, quant à lui, nécessite les éléments suivants : Un nom accessible (via aria-label ou un texte masqué à la ".sr-only") En option, et selon les cas de figure, un attribut aria-controls pour lier à la cible et un attribut aria-expanded pour signaler l’état du bouton. Dans notre cas, ce n’est pas néessaire. <button class="burger-button" aria-label="Menu" data-expanded="false"> ... </button> Voici le script JavaScript destiné à gérer l’interaction et la mise à jour des attributs data-, et déclencher l’animation de l’icône : (function () { function toggleNav() { // Define targets const button = document.querySelector(’.burger-button’); const target = document.querySelector(’#navigation’); button.addEventListener(’click’, () => { const currentState = target.getAttribute("data-state"); if (!currentState || currentState === "closed") { target.setAttribute("data-state", "opened"); button.setAttribute("data-expanded", "true"); } else { target.setAttribute("data-state", "closed"); button.setAttribute("data-expanded", "false"); } }); } // end toggleNav() toggleNav(); }()); Pouquoi JavaScript ? Très sincèrement parce que c’est son job de déclencher des actions au clic et de modifier des classes ou des attibuts en conséquence. Cette mission aurait été réalisable en CSS au moyen de cases à cocher mais, ne nous mentons pas, c’est un peu de la bidouille. 3. Les étapes de l’animation Pour être très précis, nous n’allons pas employer une "animation" pour nos effets, mais une combinaison de trois "transitions", qui se révèleront amplement suffisantes pour notre besoin. Voici le scénario étape par étape qui doit se réaliser : L’action de clic ou de touch sur l’élément button doit déclencher une série de trois transitions; La transition 1 consiste en un déplacement vertical de .rect-1 et .rect-3 qui se rejoignent au centre du SVG; La transition 2 consiste à faire disparaître .rect-2 qui traîne dans nos pattes. En terme de timing, cette transition doit se dérouler en même temps que la transition 1; La transition 3 se compose d’une rotation de 45 degrés de .rect-1 et .rect-3 et doit de déclencher juste après les transitions précédentes). Transition 1 et 2 : "translate" et "opacity" La propriété transitionest appliquée sur l’élément à l’état initial (hors événement) afin d’assurer une transition au retour lorsque l’événement est quitté. /* transition sur la propriété y et opacity, durée 0.3s */ rect { transition: y 0.3s, opacity 0.3s; } /* coordonnées y initiales */ .rect-1 { y: 0; } .rect-2 { y: 40px; } .rect-3 { y: 80px; } Au clic, le bouton passe en data-expanded "true" et on déplace verticalement deux rectangles au centre et on masque le 3e rectangle central. [data-expanded="true"] .rect-1 { y: 40px; } [data-expanded="true"] .rect-2 { opacity: 0; } [data-expanded="true"] .rect-3 { y: 40px; } Transition 3 : "rotate" Aux deux transitions précédentes, on ajoute une transition sur la propriété rotate sans oublier de la faire débuter après un léger délai. /* on attend un delai de 0.3s avant de commencer rotate */ rect { transition: y 0.3s, opacity 0.3s, rotate 0.3s 0.3s; } Au clic, les trois transitions se déclenchent. [data-expanded="true"] .rect-1 { y: 40px; rotate: 45deg; } [data-expanded="true"] .rect-2 { opacity: 0; } [data-expanded="true"] .rect-3 { y: 40px; rotate: -45deg; } ⚠️ J’imagine que cela ne vous a pas échappé : tout se passe très bien à l’aller, mais malheureusement pas au retour. L’explication provient du fait que la transition se déroule dans le sens inverse au retour et que la rotation se déclenche trop tôt. Il va nous falloir une transition différente à l’aller et au retour et gérer des délais différents entre la transition et la rotation. /* transition au retour (quand on perd le clic) */ /* on attend un delai de 0.3s avant de commencer y */ rect { transition: y 0.3s 0.3s, opacity 0.3s, rotate 0.3s; } /* transition à l’aller (quand on clique) */ /* on attend un delai de 0.3s avant de commencer rotate */ [data-expanded="true"] rect { transition: y 0.3s, opacity 0.3s, rotate 0.3s 0.3s; } Grâce à cette adaptation subtile, notre effet fonctionne parfaitement à l’aller et au retour lors de l’interaction. Pour finir en beauté, le truc en plus consiste en une petite accélération sous forme de cubic-bezier pour un effet de "rebond". [data-expanded="true"] rect { transition: y 0.3s, opacity 0.3s, rotate 0.3s 0.3s cubic-bezier(.55,-0.65,0,2.32); } CSS final Voici les styles CSS complets de ce tutoriel. Notez qu’ils prennent en compte les préférences utilisateur grâce au media query prefers-reduced-motion : si la personne a choisi dans ses réglages système de réduire les animations, celles-ci ne seront tout simplement pas déclenchées. Pour voir le résultat et aller plus loin, une petite collection CodePen de boutons burger animés a été rassemblée à cette adresse : https://codepen.io/collection/VYqwJK .rect-1 { y: 0; } .rect-2 { y: 40px; } .rect-3 { y: 80px; } [data-expanded="true"] .rect-1 { y: 40px; rotate: 45deg; } [data-expanded="true"] .rect-2 { opacity: 0; } [data-expanded="true"] .rect-3 { y: 40px; rotate: -45deg; } /* transitions si acceptées */ @media (prefers-reduced-motion: no-preference) { rect { transition: y 0.3s 0.3s, opacity 0.3s, rotate 0.3s; } [data-expanded="true"] rect { transition: y 0.3s, opacity 0.3s, rotate 0.3s 0.3s cubic-bezier(.55,-0.65,0,2.32); } } Retrouvez l’intégralité de ce tutoriel en ligne sur Alsacreations.com"> <meta name="twitter:image" content="https://feedbot.net/storage/thumbnails/2023_12/1b9392230da6166d97e929c0d06e3cd4-2bb58e10e10418b365be670dfe51b0f8.jpg"> <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/amplitudejs@v5.3.2/dist/amplitude.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <link rel="stylesheet" href="https://feedbot.net/assets/colors-dark.css?version=1749666361" id="theme"> <link rel="stylesheet" href="https://feedbot.net/assets/style.css?version=1749666361"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/fork-awesome@1.2.0/css/fork-awesome.min.css" integrity="sha256-XoaMnoYC5TH6/+ihMEnospgm0J1PM/nioxbOUdnM8HY=" crossorigin="anonymous"> <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0,user-scalable=no, shrink-to-fit=yes" /> <meta name="apple-mobile-web-app-title" content="Feedbot" /> <meta name="apple-mobile-web-app-capable" content="yes"> <meta name="theme-color" content="#11101D" /> <meta name="apple-mobile-web-app-status-bar-style" content="black"> <link rel="apple-touch-startup-image" media="screen and (device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)" href="assets/icons/iPhone_14__iPhone_13_Pro__iPhone_13__iPhone_12_Pro__iPhone_12_landscape.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)" href="assets/icons/iPhone_11__iPhone_XR_landscape.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)" href="assets/icons/iPhone_13_mini__iPhone_12_mini__iPhone_11_Pro__iPhone_XS__iPhone_X_portrait.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 430px) and (device-height: 932px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)" href="assets/icons/iPhone_14_Pro_Max_landscape.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 834px) and (device-height: 1112px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="assets/icons/10.5__iPad_Air_portrait.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 834px) and (device-height: 1194px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="assets/icons/11__iPad_Pro__10.5__iPad_Pro_portrait.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 428px) and (device-height: 926px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)" href="assets/icons/iPhone_14_Plus__iPhone_13_Pro_Max__iPhone_12_Pro_Max_landscape.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="assets/icons/12.9__iPad_Pro_portrait.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)" href="assets/icons/iPhone_11_Pro_Max__iPhone_XS_Max_portrait.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)" href="assets/icons/iPhone_8_Plus__iPhone_7_Plus__iPhone_6s_Plus__iPhone_6_Plus_portrait.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)" href="assets/icons/4__iPhone_SE__iPod_touch_5th_generation_and_later_landscape.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 834px) and (device-height: 1194px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)" href="assets/icons/11__iPad_Pro__10.5__iPad_Pro_landscape.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)" href="assets/icons/iPhone_8__iPhone_7__iPhone_6s__iPhone_6__4.7__iPhone_SE_landscape.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="assets/icons/4__iPhone_SE__iPod_touch_5th_generation_and_later_portrait.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="assets/icons/9.7__iPad_Pro__7.9__iPad_mini__9.7__iPad_Air__9.7__iPad_portrait.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 393px) and (device-height: 852px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)" href="assets/icons/iPhone_14_Pro_landscape.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 820px) and (device-height: 1180px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="assets/icons/10.9__iPad_Air_portrait.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 810px) and (device-height: 1080px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="assets/icons/10.2__iPad_portrait.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 834px) and (device-height: 1112px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)" href="assets/icons/10.5__iPad_Air_landscape.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 768px) and (device-height: 1024px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)" href="assets/icons/9.7__iPad_Pro__7.9__iPad_mini__9.7__iPad_Air__9.7__iPad_landscape.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 1024px) and (device-height: 1366px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)" href="assets/icons/12.9__iPad_Pro_landscape.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 820px) and (device-height: 1180px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)" href="assets/icons/10.9__iPad_Air_landscape.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 393px) and (device-height: 852px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)" href="assets/icons/iPhone_14_Pro_portrait.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 390px) and (device-height: 844px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)" href="assets/icons/iPhone_14__iPhone_13_Pro__iPhone_13__iPhone_12_Pro__iPhone_12_portrait.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 744px) and (device-height: 1133px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="assets/icons/8.3__iPad_Mini_portrait.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)" href="assets/icons/iPhone_8_Plus__iPhone_7_Plus__iPhone_6s_Plus__iPhone_6_Plus_landscape.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)" href="assets/icons/iPhone_13_mini__iPhone_12_mini__iPhone_11_Pro__iPhone_XS__iPhone_X_landscape.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)" href="assets/icons/iPhone_11_Pro_Max__iPhone_XS_Max_landscape.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="assets/icons/iPhone_8__iPhone_7__iPhone_6s__iPhone_6__4.7__iPhone_SE_portrait.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 430px) and (device-height: 932px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)" href="assets/icons/iPhone_14_Pro_Max_portrait.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 428px) and (device-height: 926px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)" href="assets/icons/iPhone_14_Plus__iPhone_13_Pro_Max__iPhone_12_Pro_Max_portrait.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 810px) and (device-height: 1080px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)" href="assets/icons/10.2__iPad_landscape.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 744px) and (device-height: 1133px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)" href="assets/icons/8.3__iPad_Mini_landscape.png"> <link rel="apple-touch-startup-image" media="screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)" href="assets/icons/iPhone_11__iPhone_XR_portrait.png"> <link rel="manifest" href="./manifest.json"> <link rel="icon" type="image/png" href="https://feedbot.net/assets/icons/icon.png" /> <link rel="apple-touch-icon" href="https://feedbot.net/assets/icons/icon.png" /> <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/amplitudejs@{{version-number}}/dist/amplitude.js"></script> <script src="https://feedbot.net/assets/jquery-3.6.3.min.js"></script> <script type="text/javascript"> var website = 'https://feedbot.net'; $(document).ready(function () { $(".article_menu_dots").on("click", function(e){ e.stopPropagation(); var menu_id = $(this).attr("data-id"); $(".article_menu").not("[data-id=" + menu_id + "]").hide(); $(".article_menu[data-id=" + menu_id + "]").toggle(); }); $(document).on("click", function(){ $(".article_menu").hide(); }); $(".article_menu").on("click", function(e){ e.stopPropagation(); }); }); function hideelement($param) { $(".feed_" + $param).hide(); $(".share_" + $param).hide(); } function bookmark($param) { // Variable to hold request var request; // Bind to the submit event of our form $(".bookmark_" + $param).submit(function(event){ // Prevent default posting of form - put here to work in case of errors event.preventDefault(); // Abort any pending request if(request){ request.abort(); } // setup some local variables var $form = $(this); // Let's select and cache all the fields var $inputs = $form.find("input, select, button, textarea"); // Serialize the data in the form var serializedData = $form.serialize(); // Let's disable the inputs for the duration of the Ajax request. // Note: we disable elements AFTER the form data has been serialized. // Disabled form elements will not be serialized. $inputs.prop("disabled", true); // Fire off the request to /form.php request = $.ajax({ url: website + "/includes/action.php", type: "post", data: serializedData }); // Callback handler that will be called on success request.done(function (response, textStatus, jqXHR){ // Log a message to the console $(".bookmark_" + $param).hide(); $(".unbookmark_" + $param).show(); }); // Callback handler that will be called on failure request.fail(function (jqXHR, textStatus, errorThrown){ // Log the error to the console console.error( "The following error occurred: "+ textStatus, errorThrown ); }); // Callback handler that will be called regardless // if the request failed or succeeded request.always(function (){ // Reenable the inputs $inputs.prop("disabled", false); }); }); } function unbookmark($param) { // Variable to hold request var request; // Bind to the submit event of our form $(".unbookmark_" + $param).submit(function(event){ // Prevent default posting of form - put here to work in case of errors event.preventDefault(); // Abort any pending request if (request) { request.abort(); } // setup some local variables var $form = $(this); // Let's select and cache all the fields var $inputs = $form.find("input, select, button, textarea"); // Serialize the data in the form var serializedData = $form.serialize(); // Let's disable the inputs for the duration of the Ajax request. // Note: we disable elements AFTER the form data has been serialized. // Disabled form elements will not be serialized. $inputs.prop("disabled", true); // Fire off the request to /form.php request = $.ajax({ url: website + "/includes/action.php", type: "post", data: serializedData }); // Callback handler that will be called on success request.done(function (response, textStatus, jqXHR){ // Log a message to the console $(".unbookmark_" + $param).hide(); $(".bookmark_" + + $param).show(); }); // Callback handler that will be called on failure request.fail(function (jqXHR, textStatus, errorThrown){ // Log the error to the console console.error( "The following error occurred: "+ textStatus, errorThrown ); }); // Callback handler that will be called regardless // if the request failed or succeeded request.always(function (){ // Reenable the inputs $inputs.prop("disabled", false); }); }); } function subscribe($param) { // Variable to hold request var request; // Bind to the submit event of our form $(".subscribe_" + $param).submit(function(event){ // Prevent default posting of form - put here to work in case of errors event.preventDefault(); // Abort any pending request if (request) { request.abort(); } // setup some local variables var $form = $(this); // Let's select and cache all the fields var $inputs = $form.find("input, select, button, textarea"); // Serialize the data in the form var serializedData = $form.serialize(); // Let's disable the inputs for the duration of the Ajax request. // Note: we disable elements AFTER the form data has been serialized. // Disabled form elements will not be serialized. $inputs.prop("disabled", true); // Fire off the request to /form.php request = $.ajax({ url: website + "/includes/action.php", type: "post", data: serializedData }); // Callback handler that will be called on success request.done(function (response, textStatus, jqXHR){ // Log a message to the console $(".subscribe_" + $param).hide(); $(".suggestion_" + $param).hide(); $(".unsubscribe_" + $param).show(); $(".unsubscribe_" + $param).children("input[name='sub_id']").val(''+response+''); }); // Callback handler that will be called on failure request.fail(function (jqXHR, textStatus, errorThrown){ // Log the error to the console console.error( "The following error occurred: "+ textStatus, errorThrown ); }); // Callback handler that will be called regardless // if the request failed or succeeded request.always(function (){ // Reenable the inputs $inputs.prop("disabled", false); }); }); } function unsubscribe($param) { // Variable to hold request var request; // Bind to the submit event of our form $(".unsubscribe_" + $param).submit(function(event){ // Prevent default posting of form - put here to work in case of errors event.preventDefault(); // Abort any pending request if (request) { request.abort(); } // setup some local variables var $form = $(this); // Let's select and cache all the fields var $inputs = $form.find("input, select, button, textarea"); // Serialize the data in the form var serializedData = $form.serialize(); // Let's disable the inputs for the duration of the Ajax request. // Note: we disable elements AFTER the form data has been serialized. // Disabled form elements will not be serialized. $inputs.prop("disabled", true); // Fire off the request to /form.php request = $.ajax({ url: website + "/includes/action.php", type: "post", data: serializedData }); // Callback handler that will be called on success request.done(function (response, textStatus, jqXHR){ // Log a message to the console $(".unsubscribe_" + $param).hide(); $(".subscribe_" + $param).show(); }); // Callback handler that will be called on failure request.fail(function (jqXHR, textStatus, errorThrown){ // Log the error to the console console.error( "The following error occurred: "+ textStatus, errorThrown ); }); // Callback handler that will be called regardless // if the request failed or succeeded request.always(function (){ // Reenable the inputs $inputs.prop("disabled", false); }); }); } function unshare($param) { // Variable to hold request var request; // Bind to the submit event of our form $(".unshare_" + $param).submit(function(event){ // Prevent default posting of form - put here to work in case of errors event.preventDefault(); // Abort any pending request if (request) { request.abort(); } // setup some local variables var $form = $(this); // Let's select and cache all the fields var $inputs = $form.find("input, select, button, textarea"); // Serialize the data in the form var serializedData = $form.serialize(); // Let's disable the inputs for the duration of the Ajax request. // Note: we disable elements AFTER the form data has been serialized. // Disabled form elements will not be serialized. $inputs.prop("disabled", true); // Fire off the request to /form.php request = $.ajax({ url: website + "/includes/action.php", type: "post", data: serializedData }); // Callback handler that will be called on success request.done(function (response, textStatus, jqXHR){ // Log a message to the console $(".unshare_" + $param).hide(); $(".share_" + $param).show(); }); // Callback handler that will be called on failure request.fail(function (jqXHR, textStatus, errorThrown){ // Log the error to the console console.error( "The following error occurred: "+ textStatus, errorThrown ); }); // Callback handler that will be called regardless // if the request failed or succeeded request.always(function (){ // Reenable the inputs $inputs.prop("disabled", false); }); }); } function autoshare_on($param) { // Variable to hold request var request; // Bind to the submit event of our form $(".autoshare_on_" + $param).submit(function(event){ // Prevent default posting of form - put here to work in case of errors event.preventDefault(); // Abort any pending request if (request) { request.abort(); } // setup some local variables var $form = $(this); // Let's select and cache all the fields var $inputs = $form.find("input, select, button, textarea"); // Serialize the data in the form var serializedData = $form.serialize(); // Let's disable the inputs for the duration of the Ajax request. // Note: we disable elements AFTER the form data has been serialized. // Disabled form elements will not be serialized. $inputs.prop("disabled", true); // Fire off the request to /form.php request = $.ajax({ url: website + "/includes/action.php", type: "post", data: serializedData }); // Callback handler that will be called on success request.done(function (response, textStatus, jqXHR){ // Log a message to the console $(".autoshare_on_" + $param).hide(); $(".autoshare_off_" + $param).show(); $(".sharing_options_" + $param).show(); }); // Callback handler that will be called on failure request.fail(function (jqXHR, textStatus, errorThrown){ // Log the error to the console console.error( "The following error occurred: "+ textStatus, errorThrown ); }); // Callback handler that will be called regardless // if the request failed or succeeded request.always(function (){ // Reenable the inputs $inputs.prop("disabled", false); }); }); } function autoshare_off($param) { // Variable to hold request var request; // Bind to the submit event of our form $(".autoshare_off_" + $param).submit(function(event){ // Prevent default posting of form - put here to work in case of errors event.preventDefault(); // Abort any pending request if (request) { request.abort(); } // setup some local variables var $form = $(this); // Let's select and cache all the fields var $inputs = $form.find("input, select, button, textarea"); // Serialize the data in the form var serializedData = $form.serialize(); // Let's disable the inputs for the duration of the Ajax request. // Note: we disable elements AFTER the form data has been serialized. // Disabled form elements will not be serialized. $inputs.prop("disabled", true); // Fire off the request to /form.php request = $.ajax({ url: website + "/includes/action.php", type: "post", data: serializedData }); // Callback handler that will be called on success request.done(function (response, textStatus, jqXHR){ // Log a message to the console $(".autoshare_off_" + $param).hide(); $(".sharing_options_" + $param).hide(); $(".autoshare_on_" + $param).show(); }); // Callback handler that will be called on failure request.fail(function (jqXHR, textStatus, errorThrown){ // Log the error to the console console.error( "The following error occurred: "+ textStatus, errorThrown ); }); // Callback handler that will be called regardless // if the request failed or succeeded request.always(function (){ // Reenable the inputs $inputs.prop("disabled", false); }); }); } function sharetitle_on($param) { // Variable to hold request var request; // Bind to the submit event of our form $(".sharetitle_on_" + $param).submit(function(event){ // Prevent default posting of form - put here to work in case of errors event.preventDefault(); // Abort any pending request if (request) { request.abort(); } // setup some local variables var $form = $(this); // Let's select and cache all the fields var $inputs = $form.find("input, select, button, textarea"); // Serialize the data in the form var serializedData = $form.serialize(); // Let's disable the inputs for the duration of the Ajax request. // Note: we disable elements AFTER the form data has been serialized. // Disabled form elements will not be serialized. $inputs.prop("disabled", true); // Fire off the request to /form.php request = $.ajax({ url: website + "/includes/action.php", type: "post", data: serializedData }); // Callback handler that will be called on success request.done(function (response, textStatus, jqXHR){ // Log a message to the console $(".sharetitle_on_" + $param).hide(); $(".sharetitle_off_" + $param).show(); }); // Callback handler that will be called on failure request.fail(function (jqXHR, textStatus, errorThrown){ // Log the error to the console console.error( "The following error occurred: "+ textStatus, errorThrown ); }); // Callback handler that will be called regardless // if the request failed or succeeded request.always(function (){ // Reenable the inputs $inputs.prop("disabled", false); }); }); } function sharetitle_off($param) { // Variable to hold request var request; // Bind to the submit event of our form $(".sharetitle_off_" + $param).submit(function(event){ // Prevent default posting of form - put here to work in case of errors event.preventDefault(); // Abort any pending request if (request) { request.abort(); } // setup some local variables var $form = $(this); // Let's select and cache all the fields var $inputs = $form.find("input, select, button, textarea"); // Serialize the data in the form var serializedData = $form.serialize(); // Let's disable the inputs for the duration of the Ajax request. // Note: we disable elements AFTER the form data has been serialized. // Disabled form elements will not be serialized. $inputs.prop("disabled", true); // Fire off the request to /form.php request = $.ajax({ url: website + "/includes/action.php", type: "post", data: serializedData }); // Callback handler that will be called on success request.done(function (response, textStatus, jqXHR){ // Log a message to the console $(".sharetitle_off_" + $param).hide(); $(".sharetitle_on_" + $param).show(); }); // Callback handler that will be called on failure request.fail(function (jqXHR, textStatus, errorThrown){ // Log the error to the console console.error( "The following error occurred: "+ textStatus, errorThrown ); }); // Callback handler that will be called regardless // if the request failed or succeeded request.always(function (){ // Reenable the inputs $inputs.prop("disabled", false); }); }); } function sharedescription_on($param) { // Variable to hold request var request; // Bind to the submit event of our form $(".sharedescription_on_" + $param).submit(function(event){ // Prevent default posting of form - put here to work in case of errors event.preventDefault(); // Abort any pending request if (request) { request.abort(); } // setup some local variables var $form = $(this); // Let's select and cache all the fields var $inputs = $form.find("input, select, button, textarea"); // Serialize the data in the form var serializedData = $form.serialize(); // Let's disable the inputs for the duration of the Ajax request. // Note: we disable elements AFTER the form data has been serialized. // Disabled form elements will not be serialized. $inputs.prop("disabled", true); // Fire off the request to /form.php request = $.ajax({ url: website + "/includes/action.php", type: "post", data: serializedData }); // Callback handler that will be called on success request.done(function (response, textStatus, jqXHR){ // Log a message to the console $(".sharedescription_on_" + $param).hide(); $(".sharedescription_off_" + $param).show(); }); // Callback handler that will be called on failure request.fail(function (jqXHR, textStatus, errorThrown){ // Log the error to the console console.error( "The following error occurred: "+ textStatus, errorThrown ); }); // Callback handler that will be called regardless // if the request failed or succeeded request.always(function (){ // Reenable the inputs $inputs.prop("disabled", false); }); }); } function sharedescription_off($param) { // Variable to hold request var request; // Bind to the submit event of our form $(".sharedescription_off_" + $param).submit(function(event){ // Prevent default posting of form - put here to work in case of errors event.preventDefault(); // Abort any pending request if (request) { request.abort(); } // setup some local variables var $form = $(this); // Let's select and cache all the fields var $inputs = $form.find("input, select, button, textarea"); // Serialize the data in the form var serializedData = $form.serialize(); // Let's disable the inputs for the duration of the Ajax request. // Note: we disable elements AFTER the form data has been serialized. // Disabled form elements will not be serialized. $inputs.prop("disabled", true); // Fire off the request to /form.php request = $.ajax({ url: website + "/includes/action.php", type: "post", data: serializedData }); // Callback handler that will be called on success request.done(function (response, textStatus, jqXHR){ // Log a message to the console $(".sharedescription_off_" + $param).hide(); $(".sharedescription_on_" + $param).show(); }); // Callback handler that will be called on failure request.fail(function (jqXHR, textStatus, errorThrown){ // Log the error to the console console.error( "The following error occurred: "+ textStatus, errorThrown ); }); // Callback handler that will be called regardless // if the request failed or succeeded request.always(function (){ // Reenable the inputs $inputs.prop("disabled", false); }); }); } function shareimage_on($param) { // Variable to hold request var request; // Bind to the submit event of our form $(".shareimage_on_" + $param).submit(function(event){ // Prevent default posting of form - put here to work in case of errors event.preventDefault(); // Abort any pending request if (request) { request.abort(); } // setup some local variables var $form = $(this); // Let's select and cache all the fields var $inputs = $form.find("input, select, button, textarea"); // Serialize the data in the form var serializedData = $form.serialize(); // Let's disable the inputs for the duration of the Ajax request. // Note: we disable elements AFTER the form data has been serialized. // Disabled form elements will not be serialized. $inputs.prop("disabled", true); // Fire off the request to /form.php request = $.ajax({ url: website + "/includes/action.php", type: "post", data: serializedData }); // Callback handler that will be called on success request.done(function (response, textStatus, jqXHR){ // Log a message to the console $(".shareimage_on_" + $param).hide(); $(".shareimage_off_" + $param).show(); }); // Callback handler that will be called on failure request.fail(function (jqXHR, textStatus, errorThrown){ // Log the error to the console console.error( "The following error occurred: "+ textStatus, errorThrown ); }); // Callback handler that will be called regardless // if the request failed or succeeded request.always(function (){ // Reenable the inputs $inputs.prop("disabled", false); }); }); } function shareimage_off($param) { // Variable to hold request var request; // Bind to the submit event of our form $(".shareimage_off_" + $param).submit(function(event){ // Prevent default posting of form - put here to work in case of errors event.preventDefault(); // Abort any pending request if (request) { request.abort(); } // setup some local variables var $form = $(this); // Let's select and cache all the fields var $inputs = $form.find("input, select, button, textarea"); // Serialize the data in the form var serializedData = $form.serialize(); // Let's disable the inputs for the duration of the Ajax request. // Note: we disable elements AFTER the form data has been serialized. // Disabled form elements will not be serialized. $inputs.prop("disabled", true); // Fire off the request to /form.php request = $.ajax({ url: website + "/includes/action.php", type: "post", data: serializedData }); // Callback handler that will be called on success request.done(function (response, textStatus, jqXHR){ // Log a message to the console $(".shareimage_off_" + $param).hide(); $(".shareimage_on_" + $param).show(); }); // Callback handler that will be called on failure request.fail(function (jqXHR, textStatus, errorThrown){ // Log the error to the console console.error( "The following error occurred: "+ textStatus, errorThrown ); }); // Callback handler that will be called regardless // if the request failed or succeeded request.always(function (){ // Reenable the inputs $inputs.prop("disabled", false); }); }); } function is_sensitive_on($param) { // Variable to hold request var request; // Bind to the submit event of our form $(".is_sensitive_on_" + $param).submit(function(event){ // Prevent default posting of form - put here to work in case of errors event.preventDefault(); // Abort any pending request if (request) { request.abort(); } // setup some local variables var $form = $(this); // Let's select and cache all the fields var $inputs = $form.find("input, select, button, textarea"); // Serialize the data in the form var serializedData = $form.serialize(); // Let's disable the inputs for the duration of the Ajax request. // Note: we disable elements AFTER the form data has been serialized. // Disabled form elements will not be serialized. $inputs.prop("disabled", true); // Fire off the request to /form.php request = $.ajax({ url: website + "/includes/action.php", type: "post", data: serializedData }); // Callback handler that will be called on success request.done(function (response, textStatus, jqXHR){ // Log a message to the console $(".is_sensitive_on_" + $param).hide(); $(".is_sensitive_off_" + $param).show(); }); // Callback handler that will be called on failure request.fail(function (jqXHR, textStatus, errorThrown){ // Log the error to the console console.error( "The following error occurred: "+ textStatus, errorThrown ); }); // Callback handler that will be called regardless // if the request failed or succeeded request.always(function (){ // Reenable the inputs $inputs.prop("disabled", false); }); }); } function is_sensitive_off($param) { // Variable to hold request var request; // Bind to the submit event of our form $(".is_sensitive_off_" + $param).submit(function(event){ // Prevent default posting of form - put here to work in case of errors event.preventDefault(); // Abort any pending request if (request) { request.abort(); } // setup some local variables var $form = $(this); // Let's select and cache all the fields var $inputs = $form.find("input, select, button, textarea"); // Serialize the data in the form var serializedData = $form.serialize(); // Let's disable the inputs for the duration of the Ajax request. // Note: we disable elements AFTER the form data has been serialized. // Disabled form elements will not be serialized. $inputs.prop("disabled", true); // Fire off the request to /form.php request = $.ajax({ url: website + "/includes/action.php", type: "post", data: serializedData }); // Callback handler that will be called on success request.done(function (response, textStatus, jqXHR){ // Log a message to the console $(".is_sensitive_off_" + $param).hide(); $(".is_sensitive_on_" + $param).show(); }); // Callback handler that will be called on failure request.fail(function (jqXHR, textStatus, errorThrown){ // Log the error to the console console.error( "The following error occurred: "+ textStatus, errorThrown ); }); // Callback handler that will be called regardless // if the request failed or succeeded request.always(function (){ // Reenable the inputs $inputs.prop("disabled", false); }); }); } function sensitive_text($param) { // Variable to hold request var request; // Bind to the submit event of our form $(".sensitive_text_" + $param).submit(function(event){ // Prevent default posting of form - put here to work in case of errors event.preventDefault(); // Abort any pending request if (request) { request.abort(); } // setup some local variables var $form = $(this); // Let's select and cache all the fields var $inputs = $form.find("input, select, button, textarea"); // Serialize the data in the form var serializedData = $form.serialize(); // Let's disable the inputs for the duration of the Ajax request. // Note: we disable elements AFTER the form data has been serialized. // Disabled form elements will not be serialized. $inputs.prop("disabled", true); // Fire off the request to /form.php request = $.ajax({ url: website + "/includes/action.php", type: "post", data: serializedData }); // Callback handler that will be called on success request.done(function (response, textStatus, jqXHR){ // Log a message to the console $(".sensitive_button_on_" + $param).hide(); $(".sensitive_button_off_" + $param).show(); }); // Callback handler that will be called on failure request.fail(function (jqXHR, textStatus, errorThrown){ // Log the error to the console console.error( "The following error occurred: "+ textStatus, errorThrown ); }); // Callback handler that will be called regardless // if the request failed or succeeded request.always(function (){ // Reenable the inputs $inputs.prop("disabled", false); }); }); } function set_visibility($param) { // Variable to hold request var request; // Bind to the submit event of our form $(".visibility_" + $param).change(function (event){ // Prevent default posting of form - put here to work in case of errors event.preventDefault(); // Abort any pending request if (request) { request.abort(); } // setup some local variables var $form = $(this); // Let's select and cache all the fields var $inputs = $form.find("input, select, button, textarea"); // Serialize the data in the form var serializedData = $form.serialize(); // Let's disable the inputs for the duration of the Ajax request. // Note: we disable elements AFTER the form data has been serialized. // Disabled form elements will not be serialized. $inputs.prop("disabled", true); // Fire off the request to /form.php request = $.ajax({ url: website + "/includes/action.php", type: "post", data: serializedData }); // Callback handler that will be called on success request.done(function (response, textStatus, jqXHR){ // Log a message to the console }); // Callback handler that will be called on failure request.fail(function (jqXHR, textStatus, errorThrown){ // Log the error to the console console.error( "The following error occurred: "+ textStatus, errorThrown ); }); // Callback handler that will be called regardless // if the request failed or succeeded request.always(function (){ // Reenable the inputs $inputs.prop("disabled", false); }); }); } function telegram_on($param) { // Variable to hold request var request; // Bind to the submit event of our form $(".telegram_on_" + $param).submit(function(event){ // Prevent default posting of form - put here to work in case of errors event.preventDefault(); // Abort any pending request if (request) { request.abort(); } // setup some local variables var $form = $(this); // Let's select and cache all the fields var $inputs = $form.find("input, select, button, textarea"); // Serialize the data in the form var serializedData = $form.serialize(); // Let's disable the inputs for the duration of the Ajax request. // Note: we disable elements AFTER the form data has been serialized. // Disabled form elements will not be serialized. $inputs.prop("disabled", true); // Fire off the request to /form.php request = $.ajax({ url: website + "/includes/action.php", type: "post", data: serializedData }); // Callback handler that will be called on success request.done(function (response, textStatus, jqXHR){ // Log a message to the console $(".telegram_on_" + $param).hide(); $(".telegram_off_" + $param).show(); }); // Callback handler that will be called on failure request.fail(function (jqXHR, textStatus, errorThrown){ // Log the error to the console console.error( "The following error occurred: "+ textStatus, errorThrown ); }); // Callback handler that will be called regardless // if the request failed or succeeded request.always(function (){ // Reenable the inputs $inputs.prop("disabled", false); }); }); } function telegram_off($param) { // Variable to hold request var request; // Bind to the submit event of our form $(".telegram_off_" + $param).submit(function(event){ // Prevent default posting of form - put here to work in case of errors event.preventDefault(); // Abort any pending request if (request) { request.abort(); } // setup some local variables var $form = $(this); // Let's select and cache all the fields var $inputs = $form.find("input, select, button, textarea"); // Serialize the data in the form var serializedData = $form.serialize(); // Let's disable the inputs for the duration of the Ajax request. // Note: we disable elements AFTER the form data has been serialized. // Disabled form elements will not be serialized. $inputs.prop("disabled", true); // Fire off the request to /form.php request = $.ajax({ url: website + "/includes/action.php", type: "post", data: serializedData }); // Callback handler that will be called on success request.done(function (response, textStatus, jqXHR){ // Log a message to the console $(".telegram_off_" + $param).hide(); $(".telegram_on_" + $param).show(); }); // Callback handler that will be called on failure request.fail(function (jqXHR, textStatus, errorThrown){ // Log the error to the console console.error( "The following error occurred: "+ textStatus, errorThrown ); }); // Callback handler that will be called regardless // if the request failed or succeeded request.always(function (){ // Reenable the inputs $inputs.prop("disabled", false); }); }); } function publish() { // Variable to hold request var request; // Bind to the submit event of our form $(".publish").submit(function(event){ // Prevent default posting of form - put here to work in case of errors event.preventDefault(); // Abort any pending request if (request) { request.abort(); } // setup some local variables var $form = $(this); // Let's select and cache all the fields var $inputs = $form.find("input, select, button, textarea"); // Serialize the data in the form var serializedData = $form.serialize(); // Let's disable the inputs for the duration of the Ajax request. // Note: we disable elements AFTER the form data has been serialized. // Disabled form elements will not be serialized. $inputs.prop("disabled", true); // Fire off the request to /form.php request = $.ajax({ url: website + "/includes/action.php", type: "post", data: serializedData }); // Callback handler that will be called on success request.done(function (response, textStatus, jqXHR){ // Log a message to the console $(".publish_button").hide(); $(".publish_area").val(""); $(".publish_button_sent").show(); setTimeout(function(){ $(".publish_button").show(); $(".publish_button_sent").hide(); }, 3000); }); // Callback handler that will be called on failure request.fail(function (jqXHR, textStatus, errorThrown){ // Log the error to the console console.error( "The following error occurred: "+ textStatus, errorThrown ); }); // Callback handler that will be called regardless // if the request failed or succeeded request.always(function (){ // Reenable the inputs $inputs.prop("disabled", false); }); }); } function counter(val) { var len = val.value.length; if(len >= 500){ val.value = val.value.substring(0, 500); } else{ $('.counter').text(500 - len); } } function counter_share(val) { var len = val.value.length; if(len >= 460){ val.value = val.value.substring(0, 460); } else{ $('.counter').text(460 - len); } } function share($param) { // Variable to hold request var request; // Bind to the submit event of our form $(".share_" + $param).submit(function(event){ // Prevent default posting of form - put here to work in case of errors event.preventDefault(); // Abort any pending request if (request) { request.abort(); } // setup some local variables var $form = $(this); // Let's select and cache all the fields var $inputs = $form.find("input, select, button, textarea"); // Serialize the data in the form var serializedData = $form.serialize(); // Fire off the request to /form.php request = $.ajax({ url: website + "/includes/share.php", type: "POST", data: serializedData }); // Callback handler that will be called on success request.done(function (data, response, textStatus, jqXHR){ // Log a message to the console $(".publish_popup").empty(); $(".publish_popup").append(data); $(".publish_popup").show(); $('html, body').css({overflow: 'hidden'}); }); // Callback handler that will be called on failure request.fail(function (jqXHR, textStatus, errorThrown){ // Log the error to the console console.error( "The following error occurred: "+ textStatus, errorThrown ); }); }); } function share2($param) { // Variable to hold request var request; // Bind to the submit event of our form $(".share_button").hide(); $(".shared_button").show(); $(".share_content_" + $param).submit(function(event){ // Prevent default posting of form - put here to work in case of errors event.preventDefault(); // Abort any pending request if (request) { request.abort(); } // setup some local variables var $form = $(this); // Let's select and cache all the fields var $inputs = $form.find("input, select, button, textarea"); // Serialize the data in the form var serializedData = $form.serialize(); // Fire off the request to /form.php request = $.ajax({ url: website + "/includes/action.php", type: "POST", data: serializedData }); // Callback handler that will be called on success request.done(function (response, textStatus, jqXHR){ // Log a message to the console $(".share_" + $param).hide(); $(".unshare_" + $param).show(); $(".unshare_" + $param).children("input[name='status_id']").val(''+response+''); $(".publish_popup").hide(); $(".publish_popup").empty(); $('html, body').css({overflow: ''}); }); // Callback handler that will be called on failure request.fail(function (jqXHR, textStatus, errorThrown){ // Log the error to the console console.error( "The following error occurred: "+ textStatus, errorThrown ); }); }); } function hide_publish(back_url) { var back = back_url; $(".publish_popup").hide(); $(".publish_popup").empty(); $('html, body').css({overflow: ''}); window.history.pushState("data", "Title", back); Amplitude.stop(); } function story(media_id){ var new_url = website + "/story/" + media_id; $.ajax({ url: website + '/includes/stories.php?media=' + media_id, type: "GET", beforeSend: function(){ $('.ajax-load').show(); $(".publish_popup").empty(); } }).done(function(data){ $('.ajax-load').hide(); $(".publish_popup").append(data); window.history.pushState("data", "Title", new_url); $(".publish_popup").show(); $('html, body').css({overflow: 'hidden'}); }).fail(function(jqXHR, ajaxOptions, thrownError){ }); } function podcast(id){ var new_url = website + "/podcast/" + id; $.ajax({ url: website + '/includes/podcast.php?id=' + id, type: "GET", beforeSend: function(){ $('.ajax-load').show(); $(".publish_popup").empty(); } }).done(function(data){ $('.ajax-load').hide(); $(".publish_popup").append(data); window.history.pushState("data", "Title", new_url); $(".publish_popup").show(); $('html, body').css({overflow: 'hidden'}); }).fail(function(jqXHR, ajaxOptions, thrownError){ }); } function dark_mode() { $('#theme').attr('href', 'https://feedbot.net/assets/colors-dark.css'); $('.light_mode').show(); $('.dark_mode').hide(); document.cookie = "theme=dark; path=/; max-age=" + 30*24*60*60; } function light_mode() { $('#theme').attr('href', 'https://feedbot.net/assets/colors-light.css'); $('.light_mode').hide(); $('.dark_mode').show(); document.cookie = "theme=light; path=/; max-age=" + 30*24*60*60; $(".video_cinema").hide(); } function constructFeed(json, getJSON = true){ return new Promise((resolve, reject) => { var constructFeed; var num_content = json_content.length - 1; $.each(json, function(index, value){ if(json_content[index]){ var feed_id = json_content[index]["feed_id"]; if(json_content[index]["youtube_id"]){ var youtube_id = json_content[index]["youtube_id"]; } else{ var youtube_id = ""; } if(json_content[index]["peertube_id"]){ var peertube_id = json_content[index]["peertube_id"]; } else{ var peertube_id = ""; } if(json_content[index]["description"]){ var description = json_content[index]["description"]; description = description.replace(/\\n/g, '<br>'); } constructFeed += ` <div class="content-home" style="padding-top: 15px; padding-bottom: 0px;" id="` + json_content[index]["date"] + `"> <div style="height:75px;">`; if(json_feeds[feed_id]["is_subscribed"] == 1){ constructFeed += ` <form class="follow-button subscribe_` + json_content[index]["feed_id"] + `" style="display:none;" title="