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