]> git.ipfire.org Git - ipfire.org.git/blame - static/js/site.js
Bug 11327 try again to fix flickering on scroll
[ipfire.org.git] / static / js / site.js
CommitLineData
1e5bc9c9 1$(document).ready(function () {
df9d01f3
S
2 $("#scrollto").click(function(e) {
3 e.preventDefault();
4 $('body').animate({
5 scrollTop: $("#features").offset().top -72
6 }, 1500);
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 });
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
31if (/.*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
68function getCookie(name) {
69 var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
70 return r ? r[1] : undefined;
71}
72
73jQuery.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};