]>
git.ipfire.org Git - people/shoehn/ipfire.org.git/blob - static/js/site.js
1 $(document
).ready(function () {
2 $(window
).scroll(function () {
3 if ($(document
).scrollTop() > 100) {
4 $(".fixed-top").addClass("scrolled");
5 $(".menu-text").addClass("hidden");
7 $(".fixed-top").removeClass("scrolled");
8 $(".menu-text").removeClass("hidden");
12 $('.navbar-toggler-left').click(function() {
13 $('#navbarSupportedContent, #mask').addClass('open');
14 $('.scrolled').addClass('fadeout');
16 $('#mask').click(function() {
17 $('#navbarSupportedContent, #mask').removeClass('open');
18 $('.scrolled').removeClass('fadeout');
22 $.query = function(name
){
23 var results
= new RegExp('[\\?&]' + name
+ '=([^&#]*)').exec(window
.location
.href
);
24 return results
[1] || 0;
27 $("a.download-splash").click(function(event
) {
28 event
.preventDefault();
29 linkLocation
= this.href
;
31 window
.location
= "http://downloads.ipfire.org/download-splash?file="+linkLocation
;
34 if (/.*download-splash.*/i.test(window
.location
.href
)) {
35 $("p.download-path").ready(function(){
37 var allowed_prefixes
= [
38 "http://downloads.ipfire.org/",
41 var file_url
= $.query("file");
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
) {
52 $("p.download-path").prepend($("<a>", {
53 href
: encodeURI(file_url
),
56 setTimeout(function() { window
.location
= file_url
}, "2000");
61 /* $(".planet-search-autocomplete").typeahead({
62 source: function(query, process) {
63 $.get("/api/planet/search/autocomplete", { q: query }, function(data) {
64 if (data.query == query) {
65 process(data.results);
71 function getCookie(name
) {
72 var r
= document
.cookie
.match("\\b" + name
+ "=([^;]*)\\b");
73 return r
? r
[1] : undefined;
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
+ ")"));