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