]>
git.ipfire.org Git - people/shoehn/ipfire.org.git/blob - static/js/site.js
1 $(document
).ready(function () {
2 $("#scrollto").click(function(e
) {
5 scrollTop
: $("#features").offset().top
-72
8 $(window
).scroll(function () {
9 if ($(document
).scrollTop() > 100) {
10 $(".fixed-top").addClass("scrolled");
11 $(".menu-text").addClass("hidden");
13 $(".fixed-top").removeClass("scrolled");
14 $(".menu-text").removeClass("hidden");
18 $('.navbar-toggler-left').click(function() {
19 $('#navbarSupportedContent, #mask').addClass('open');
20 $('.scrolled').addClass('fadeout');
22 $('#mask').click(function() {
23 $('#navbarSupportedContent, #mask').removeClass('open');
24 $('.scrolled').removeClass('fadeout');
28 $.query = function(name
){
29 var results
= new RegExp('[\\?&]' + name
+ '=([^&#]*)').exec(window
.location
.href
);
30 return results
[1] || 0;
33 $("a.download-splash").click(function(event
) {
34 event
.preventDefault();
35 linkLocation
= this.href
;
37 window
.location
= "http://downloads.ipfire.org/download-splash?file="+linkLocation
;
40 if (/.*download-splash.*/i.test(window
.location
.href
)) {
41 $("p.download-path").ready(function(){
43 var allowed_prefixes
= [
44 "http://downloads.ipfire.org/",
47 var file_url
= $.query("file");
49 // Only accept URLs beginning with our known prefix.
50 for (i
in allowed_prefixes
) {
51 prefix
= allowed_prefixes
[i
];
52 if (file_url
.substring(0, prefix
.length
) == prefix
) {
58 $("p.download-path").prepend($("<a>", {
59 href
: encodeURI(file_url
),
62 setTimeout(function() { window
.location
= file_url
}, "2000");
67 /* $(".planet-search-autocomplete").typeahead({
68 source: function(query, process) {
69 $.get("/api/planet/search/autocomplete", { q: query }, function(data) {
70 if (data.query == query) {
71 process(data.results);
77 function getCookie(name
) {
78 var r
= document
.cookie
.match("\\b" + name
+ "=([^;]*)\\b");
79 return r
? r
[1] : undefined;
82 jQuery
.postJSON = function(url
, args
, callback
) {
83 args
._xsrf
= getCookie("_xsrf");
84 $.ajax({url
: url
, data
: $.param(args
), dataType
: "text", type
: "POST",
85 success: function(response
) {
86 callback(eval("(" + response
+ ")"));