You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
3.3 KiB
JavaScript

/* Add your Application JavaScript */
$(function() {
7 years ago
$("div[data-toggle=fieldset]").each(function() {
var $this = $(this);
//Add new entry
$this.find("button[data-toggle=fieldset-add-row]").click(function() {
var target = $($(this).data("target"))
console.log(target);
var oldrow = target.find("[data-toggle=fieldset-entry]:last");
var row = oldrow.clone(true, true);
console.log(row.find(":input")[0]);
var elem_id = row.find(":input")[0].id;
var elem_num = parseInt(elem_id.replace(/.*-(\d{1,4})-.*/m, '$1')) + 1;
row.attr('data-id', elem_num);
row.find(":input").each(function() {
console.log(this);
var id = $(this).attr('id').replace('-' + (elem_num - 1) + '-', '-' + (elem_num) + '-');
$(this).attr('name', id).attr('id', id).val('').removeAttr("checked");
});
oldrow.after(row);
}); //End add new entry
//Remove row
$this.find("button[data-toggle=fieldset-remove-row]").click(function() {
if ($this.find("[data-toggle=fieldset-entry]").length > 1) {
var thisRow = $(this).closest("[data-toggle=fieldset-entry]");
thisRow.remove();
}
}); //End remove row
});
});
7 years ago
$(function() {
$("#draggable").draggable();
$("#droppable").droppable({
drop: function(event, ui) {
$(this)
.addClass("ui-state-highlight")
.find("p")
.html("Dropped!");
}
});
7 years ago
});
7 years ago
$("#title_xppl").click(function() {
generateTitle(this);
});
7 years ago
$(document).ready(function() {
7 years ago
generateTitle("#title_xppl");
});
7 years ago
function generateTitle(elem) {
var x = ["XPERIMENTAL"]
var p1 = ["POTENTIAL", "PUBLIC", "POST", "PI", "PLATFORM FOR", "PRETENTIOUS"]
var p2 = ["PIRATE", "PERFORMATIVE", "PUBLIC", "PUBLISHING", "POTENTIAL"]
var l = ["LIBRARY", "LIAISON", "LAB", "LEGALITY", "LABOUR"]
7 years ago
$(elem).text(x[Math.floor(Math.random() * x.length)] + " " + p1[Math.floor(Math.random() * p1.length)] + " " + p2[Math.floor(Math.random() * p2.length)] + " " + l[Math.floor(Math.random() * l.length)]);
}
7 years ago
$(function() {
$("#tabs").tabs().addClass("ui-tabs-vertical ui-helper-clearfix");
$("#tabs li").removeClass("ui-corner-top").addClass("ui-corner-left");
});
7 years ago
$(".no_cover").each(function() {
var string = $(this).attr('id')
var randomColor = colorHash(string).rgb
$(this).css({
7 years ago
'background-color': randomColor,
});
7 years ago
})
7 years ago
function colorHash(inputString) {
var sum = 0;
7 years ago
for (var i in inputString) {
sum += inputString.charCodeAt(i);
}
7 years ago
r = ~~(('0.' + Math.sin(sum + 1).toString().substr(6)) * 256);
g = ~~(('0.' + Math.sin(sum + 2).toString().substr(6)) * 256);
b = ~~(('0.' + Math.sin(sum + 3).toString().substr(6)) * 256);
7 years ago
var rgb = "rgb(" + r + ", " + g + ", " + b + ")";
7 years ago
var hex = "#";
7 years ago
hex += ("00" + r.toString(16)).substr(-2, 2).toUpperCase();
hex += ("00" + g.toString(18)).substr(-2, 2).toUpperCase();
hex += ("00" + b.toString(20)).substr(-2, 2).toUpperCase();
7 years ago
return {
r: r,
g: g,
b: b,
rgb: rgb,
hex: hex
};
}
7 years ago
//newsticker
var marquee = $('div.marquee');
marquee.each(function() {
var mar = $(this),
indent = mar.width();
mar.marquee = function() {
indent--;
mar.css('text-indent', indent);
if (indent < -1 * mar.children('div.marquee-text').width()) {
indent = mar.width();
}
};
mar.data('interval', setInterval(mar.marquee, 10));
});