]>
git.ipfire.org Git - 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");
19 $.query = function(name
){
20 var results
= new RegExp('[\\?&]' + name
+ '=([^&#]*)').exec(window
.location
.href
);
21 return results
[1] || 0;
24 $("a.download-splash").click(function(event
) {
25 event
.preventDefault();
26 linkLocation
= this.href
;
28 window
.location
= "http://downloads.ipfire.org/download-splash?file="+linkLocation
;
31 if (/.*download-splash.*/i.test(window
.location
.href
)) {
32 $("p.download-path").ready(function(){
34 var allowed_prefixes
= [
35 "http://downloads.ipfire.org/",
38 var file_url
= $.query("file");
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
) {
49 $("p.download-path").prepend($("<a>", {
50 href
: encodeURI(file_url
),
53 setTimeout(function() { window
.location
= file_url
}, "2000");
58 /* $(".planet-search-autocomplete").typeahead({
59 source: function(query, process) {
60 $.get("/api/planet/search/autocomplete", { q: query }, function(data) {
61 if (data.query == query) {
62 process(data.results);
68 function getCookie(name
) {
69 var r
= document
.cookie
.match("\\b" + name
+ "=([^;]*)\\b");
70 return r
? r
[1] : undefined;
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
+ ")"));