]>
git.ipfire.org Git - ipfire.org.git/blob - static/js/site.js
1 $.query = function(name
){
2 var results
= new RegExp('[\\?&]' + name
+ '=([^&#]*)').exec(window
.location
.href
);
3 return results
[1] || 0;
6 $("a.download-splash").click(function(event
) {
7 event
.preventDefault();
8 linkLocation
= this.href
;
10 window
.location
= "http://downloads.ipfire.org/download-splash?file="+linkLocation
;
13 var $window
= $(window
);
17 top: function () { return $window
.width() <= 980 ? 290 : 210 }
22 if (/.*download-splash.*/i.test(window
.location
.href
)) {
23 $("p.download-path").ready(function(){
25 var allowed_prefixes
= [
26 "http://downloads.ipfire.org/",
29 var file_url
= $.query("file");
31 // Only accept URLs beginning with our known prefix.
32 for (i
in allowed_prefixes
) {
33 prefix
= allowed_prefixes
[i
];
34 if (file_url
.substring(0, prefix
.length
) == prefix
) {
40 $("p.download-path").prepend($("<a>", {
41 href
: encodeURI(file_url
),
44 setTimeout(function() { window
.location
= file_url
}, "2000");
49 $(".planet-search-autocomplete").typeahead({
50 source: function(query
, process
) {
51 $.get("http://planet.ipfire.org/api/search/autocomplete", { q
: query
}, function(data
) {
52 if (data
.query
== query
) {
53 process(data
.results
);
60 function getCookie(name
) {
61 var r
= document
.cookie
.match("\\b" + name
+ "=([^;]*)\\b");
62 return r
? r
[1] : undefined;
65 jQuery
.postJSON = function(url
, args
, callback
) {
66 args
._xsrf
= getCookie("_xsrf");
67 $.ajax({url
: url
, data
: $.param(args
), dataType
: "text", type
: "POST",
68 success: function(response
) {
69 callback(eval("(" + response
+ ")"));