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