1 // Handle .hide-if-no-js and .hide-if-js styles
2 $(document).ready(function(){
3 $('.hide-if-no-js').removeClass('hide-if-no-js');
4 $('.hide-if-js').hide();
7 // Change an element text an revert in a smooth pulse. el is an element id like '#copybox h2'
8 function html_pulse( el, newtext ){
9 var oldtext = $(el).html();
10 // Fast pulse to "Copied" and revert
19 "slow", 1, // this fades from 1 to 1: just a 'sleep(1)' actually
21 $(el).fadeTo("normal", 0.01, function(){$(el).html( oldtext ).css('opacity', 1)});
30 // Update feedback message
31 function feedback(msg, type, delay) {
32 closeme = ( type == 'fail' || type == 'error' ) ? true : false;
33 delay = delay || ( closeme == true ? 10000 : 3500 );
35 html: '<span>'+msg+'</span>',
37 animationSpeed: "normal",
49 data: {action:'logout'},
51 window.parent.location.href = window.parent.location.href;
56 // Begin the spinning animation & disable a button
57 function add_loading(el) {
58 $(el).attr("disabled", "disabled").addClass('disabled').addClass('loading');
61 // End spinning animation
62 function end_loading(el) {
63 $(el).removeClass('loading');
66 // Un-disable an element
67 function end_disable(el) {
68 $(el).removeAttr("disabled").removeClass('disabled');
72 function trim_long_string( string, length) {
73 var newstring = string;
74 length = length || 60;
75 if ( newstring.length > length ) {
76 newstring = newstring.substr(0, (length - 5) ) + '[...]';
81 // Get the var=xxx from a query string
82 function get_var_from_query( url, varname, default_val ) {
83 if( varname == undefined ) {
86 if( default_val == undefined ) {
90 // Split the url on '?' and get only the params (which is element 1)
91 url = url.split('?')[1];
92 // Now split those params on '&' so we can get each one individually (Ex. param_var=param_value)
94 // Now we have to find the varname in that array using methods that IE likes (Curse you IE!!!)
96 for( i=0; i<url.length; i++ ){
97 // So split the first param elemment on '=' and check the param_var to see if it matches varname (element 0)
98 if( url[i].split('=')[0] == varname ){
99 // If it matches we want to return the param_value
100 return url[i].split('=')[1];
104 // If we didn't find anything then we just return the default_val
109 * Jquery Cookie plugin
110 * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
111 * Dual licensed under the MIT and GPL licenses:
112 * http://www.opensource.org/licenses/mit-license.php
113 * http://www.gnu.org/licenses/gpl.html
114 * Available at http://plugins.jquery.com/files/jquery.cookie.js.txt
116 jQuery.cookie = function(name, value, options) {
117 if (typeof value != 'undefined') { // name and value given, set cookie
118 options = options || {};
119 if (value === null) {
121 options.expires = -1;
124 if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
126 if (typeof options.expires == 'number') {
128 date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
130 date = options.expires;
132 expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
134 // CAUTION: Needed to parenthesize options.path and options.domain
135 // in the following expressions, otherwise they evaluate to undefined
136 // in the packed version for some reason...
137 var path = options.path ? '; path=' + (options.path) : '';
138 var domain = options.domain ? '; domain=' + (options.domain) : '';
139 var secure = options.secure ? '; secure' : '';
140 document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
141 } else { // only name given, get cookie
142 var cookieValue = null;
143 if (document.cookie && document.cookie != '') {
144 var cookies = document.cookie.split(';');
145 for (var i = 0; i < cookies.length; i++) {
146 var cookie = jQuery.trim(cookies[i]);
147 // Does this cookie string begin with the name we want?
148 if (cookie.substring(0, name.length + 1) == (name + '=')) {
149 cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
158 // Split a URL into protocol, slashes and the rest
159 function get_protocol_slashes_and_rest( url ) {
160 if( ups=url.match( /^[a-zA-Z0-9\+\.-]+:(\/\/)?/ ) ) {
162 var ur=url.split(new RegExp(ups))[1];
163 var ups=ups.split(/\:/);
164 return { protocol: ups[0]+':', slashes: ups[1], rest: ur };
166 return { protocol: '', slashes: '', rest: url };;