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