]> git.ipfire.org Git - people/shoehn/ipfire.org.git/blob - static/js/site.js
added tux on mobile menu
[people/shoehn/ipfire.org.git] / static / js / site.js
1 $(document).ready(function () {
2 $("#scrollto").click(function(e) {
3 e.preventDefault();
4 $('body').animate({
5 scrollTop: $("#features").offset().top -72
6 }, 1000);
7 });
8 $(window).scroll(function () {
9 if ($(document).scrollTop() > 100) {
10 $(".fixed-top").addClass("scrolled");
11 $(".menu-text").addClass("hidden");
12 } else {
13 $(".fixed-top").removeClass("scrolled");
14 $(".menu-text").removeClass("hidden");
15 }
16 });
17 //* Menu *//
18 $('.navbar-toggler-left').click(function() {
19 $('#navbarSupportedContent, #mask').addClass('open');
20 $('.scrolled').addClass('fadeout');
21 });
22 $('#mask').click(function() {
23 $('#navbarSupportedContent, #mask').removeClass('open');
24 $('.scrolled').removeClass('fadeout');
25 });
26 });
27
28 $.query = function(name){
29 var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
30 return results[1] || 0;
31 }
32
33 $("a.download-splash").click(function(event) {
34 event.preventDefault();
35 linkLocation = this.href;
36
37 window.location = "http://downloads.ipfire.org/download-splash?file="+linkLocation;
38 });
39
40 if (/.*download-splash.*/i.test(window.location.href)) {
41 $("p.download-path").ready(function(){
42 var valid = false;
43 var allowed_prefixes = [
44 "http://downloads.ipfire.org/",
45 ]
46
47 var file_url = $.query("file");
48
49 // Only accept URLs beginning with our known prefix.
50 for (i in allowed_prefixes) {
51 prefix = allowed_prefixes[i];
52 if (file_url.substring(0, prefix.length) == prefix) {
53 valid = true;
54 }
55 }
56
57 if (valid) {
58 $("p.download-path").prepend($("<a>", {
59 href: encodeURI(file_url),
60 text: file_url
61 }))
62 setTimeout(function() { window.location = file_url }, "2000");
63 }
64 });
65 }
66
67 /* $(".planet-search-autocomplete").typeahead({
68 source: function(query, process) {
69 $.get("/api/planet/search/autocomplete", { q: query }, function(data) {
70 if (data.query == query) {
71 process(data.results);
72 }
73 });
74 },
75 }); */
76
77 function getCookie(name) {
78 var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
79 return r ? r[1] : undefined;
80 }
81
82 jQuery.postJSON = function(url, args, callback) {
83 args._xsrf = getCookie("_xsrf");
84 $.ajax({url: url, data: $.param(args), dataType: "text", type: "POST",
85 success: function(response) {
86 callback(eval("(" + response + ")"));
87 }
88 });
89 };