]> git.ipfire.org Git - ipfire.org.git/blame - static/js/site.js
edit font weight in buttons
[ipfire.org.git] / static / js / site.js
CommitLineData
c2cbe16d
S
1$("#scrollto").click(function() {
2 $('html, body').animate({
3 scrollTop: $("#features").offset().top -72
4 }, 1500, 'easeInOutExpo');
5});
6
4b4334da
S
7$(document).ready(function () {
8 $(window).scroll(function () {
9 if ($(document).scrollTop() > 100) {
10 $(".fixed-top").addClass("scrolled");
d8c9a4d4 11 $(".menu-text").addClass("hidden");
4b4334da
S
12 } else {
13 $(".fixed-top").removeClass("scrolled");
d8c9a4d4 14 $(".menu-text").removeClass("hidden");
4b4334da
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
73493ea6 28 window.location = "https://downloads.ipfire.org/download-splash?file="+linkLocation;
60024cc8
MT
29});
30
31if (/.*download-splash.*/i.test(window.location.href)) {
32 $("p.download-path").ready(function(){
33 var valid = false;
34 var allowed_prefixes = [
73493ea6 35 "https://downloads.ipfire.org/",
60024cc8
MT
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 });
ac7f3ec6 80};