]>
Commit | Line | Data |
---|---|---|
aa44ed56 | 1 | $(document).ready(function () { |
1e5bc9c9 S |
2 | $(window).scroll(function () { |
3 | if ($(document).scrollTop() > 100) { | |
4 | $(".fixed-top").addClass("scrolled"); | |
ccd81281 | 5 | $(".menu-text").addClass("hidden"); |
1e5bc9c9 S |
6 | } else { |
7 | $(".fixed-top").removeClass("scrolled"); | |
ccd81281 | 8 | $(".menu-text").removeClass("hidden"); |
1e5bc9c9 S |
9 | } |
10 | }); | |
55edf6f3 S |
11 | //* Menu *// |
12 | $('.navbar-toggler-left').click(function() { | |
13 | $('#navbarSupportedContent, #mask').addClass('open'); | |
49baba87 | 14 | $('.scrolled').addClass('fadeout'); |
55edf6f3 S |
15 | }); |
16 | $('#mask').click(function() { | |
17 | $('#navbarSupportedContent, #mask').removeClass('open'); | |
49baba87 | 18 | $('.scrolled').removeClass('fadeout'); |
55edf6f3 | 19 | }); |
1e5bc9c9 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 | ||
31 | window.location = "http://downloads.ipfire.org/download-splash?file="+linkLocation; | |
32 | }); | |
33 | ||
34 | if (/.*download-splash.*/i.test(window.location.href)) { | |
35 | $("p.download-path").ready(function(){ | |
36 | var valid = false; | |
37 | var allowed_prefixes = [ | |
38 | "http://downloads.ipfire.org/", | |
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 |
71 | function getCookie(name) { |
72 | var r = document.cookie.match("\\b" + name + "=([^;]*)\\b"); | |
73 | return r ? r[1] : undefined; | |
74 | } | |
75 | ||
76 | jQuery.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 | }); | |
b6eb5162 | 83 | }; |