2018-05-23 14:12:24 +02:00
|
|
|
/* Add your Application JavaScript */
|
|
|
|
$(function() {
|
2018-06-01 23:27:26 +02:00
|
|
|
$("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
|
|
|
|
});
|
2018-05-23 14:12:24 +02:00
|
|
|
});
|
2018-06-01 21:37:45 +02:00
|
|
|
|
|
|
|
|
2018-06-01 23:27:26 +02:00
|
|
|
$(function() {
|
|
|
|
$("#draggable").draggable();
|
|
|
|
$("#droppable").droppable({
|
|
|
|
drop: function(event, ui) {
|
|
|
|
$(this)
|
|
|
|
.addClass("ui-state-highlight")
|
|
|
|
.find("p")
|
|
|
|
.html("Dropped!");
|
2018-06-01 21:37:45 +02:00
|
|
|
}
|
|
|
|
});
|
2018-06-01 23:27:26 +02:00
|
|
|
});
|
2018-06-01 21:37:45 +02:00
|
|
|
|
2018-06-01 23:53:25 +02:00
|
|
|
$("#title_xppl").click(function() {
|
2018-06-01 21:37:45 +02:00
|
|
|
generateTitle(this);
|
|
|
|
});
|
|
|
|
|
2018-06-01 23:27:26 +02:00
|
|
|
$(document).ready(function() {
|
2018-06-01 23:53:25 +02:00
|
|
|
generateTitle("#title_xppl");
|
2018-06-01 21:37:45 +02:00
|
|
|
});
|
|
|
|
|
2018-06-01 23:27:26 +02:00
|
|
|
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"]
|
2018-06-01 21:37:45 +02:00
|
|
|
|
2018-06-01 23:27:26 +02:00
|
|
|
$(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)]);
|
2018-06-01 21:37:45 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-06-01 23:27:26 +02:00
|
|
|
$(function() {
|
2018-06-11 17:57:22 +02:00
|
|
|
var index = 'ui-tabs-active';
|
|
|
|
// Define friendly data store name
|
|
|
|
var dataStore = window.sessionStorage;
|
|
|
|
var oldIndex = 0;
|
|
|
|
// Start magic!
|
|
|
|
try {
|
|
|
|
// getter: Fetch previous value
|
|
|
|
oldIndex = dataStore.getItem(index);
|
|
|
|
} catch(e) {}
|
|
|
|
|
|
|
|
$("#tabs").tabs({
|
|
|
|
active: oldIndex,
|
|
|
|
activate: function(event, ui) {
|
|
|
|
// Get future value
|
|
|
|
var newIndex = ui.newTab.parent().children().index(ui.newTab);
|
|
|
|
// Set future value
|
|
|
|
try {
|
|
|
|
dataStore.setItem( index, newIndex );
|
|
|
|
} catch(e) {}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#tabs").addClass("ui-tabs-vertical ui-helper-clearfix");
|
2018-06-01 23:27:26 +02:00
|
|
|
$("#tabs li").removeClass("ui-corner-top").addClass("ui-corner-left");
|
|
|
|
});
|
2018-06-01 21:37:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-06-01 23:27:26 +02:00
|
|
|
$(".no_cover").each(function() {
|
2018-06-01 21:37:45 +02:00
|
|
|
var string = $(this).attr('id')
|
|
|
|
var randomColor = colorHash(string).rgb
|
|
|
|
|
|
|
|
$(this).css({
|
2018-06-01 23:27:26 +02:00
|
|
|
'background-color': randomColor,
|
2018-06-01 21:37:45 +02:00
|
|
|
});
|
|
|
|
|
2018-06-01 23:27:26 +02:00
|
|
|
})
|
2018-06-01 21:37:45 +02:00
|
|
|
|
2018-06-01 23:27:26 +02:00
|
|
|
function colorHash(inputString) {
|
|
|
|
var sum = 0;
|
2018-06-01 21:37:45 +02:00
|
|
|
|
2018-06-01 23:27:26 +02:00
|
|
|
for (var i in inputString) {
|
|
|
|
sum += inputString.charCodeAt(i);
|
|
|
|
}
|
2018-06-01 21:37:45 +02:00
|
|
|
|
2018-06-01 23:27:26 +02:00
|
|
|
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);
|
2018-06-01 21:37:45 +02:00
|
|
|
|
2018-06-01 23:27:26 +02:00
|
|
|
var rgb = "rgb(" + r + ", " + g + ", " + b + ")";
|
2018-06-01 21:37:45 +02:00
|
|
|
|
2018-06-01 23:27:26 +02:00
|
|
|
var hex = "#";
|
2018-06-01 21:37:45 +02:00
|
|
|
|
2018-06-01 23:27:26 +02:00
|
|
|
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();
|
2018-06-01 21:37:45 +02:00
|
|
|
|
2018-06-01 23:27:26 +02:00
|
|
|
return {
|
|
|
|
r: r,
|
|
|
|
g: g,
|
|
|
|
b: b,
|
|
|
|
rgb: rgb,
|
|
|
|
hex: hex
|
|
|
|
};
|
2018-06-01 21:37:45 +02:00
|
|
|
}
|
2018-06-01 23:27:26 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//newsticker
|
2018-06-03 12:29:08 +02:00
|
|
|
|
|
|
|
$('.marquee').marquee({
|
|
|
|
duplicated: true,
|
|
|
|
pauseOnHover: true
|
2018-06-01 23:27:26 +02:00
|
|
|
});
|
2018-06-02 00:20:54 +02:00
|
|
|
|
2018-06-03 12:29:08 +02:00
|
|
|
$( document ).ready(function() {
|
|
|
|
|
|
|
|
update();
|
|
|
|
function update() {
|
|
|
|
$.ajax({
|
|
|
|
url: "/updates",
|
|
|
|
type: 'GET',
|
|
|
|
async: false,
|
|
|
|
success : function(text)
|
|
|
|
{
|
|
|
|
response = text;
|
|
|
|
$('.marquee').marquee('destroy')
|
|
|
|
$('.marquee-text').text(response)
|
|
|
|
$('.marquee').marquee({
|
|
|
|
duplicated: true,
|
|
|
|
pauseOnHover: true,
|
|
|
|
duration: 7000,
|
2018-06-03 15:23:10 +02:00
|
|
|
speed: 30,
|
|
|
|
gap: 200,
|
2018-06-03 12:29:08 +02:00
|
|
|
startVisible:true
|
|
|
|
});
|
|
|
|
console.log(response)
|
|
|
|
},
|
|
|
|
cache: false,
|
|
|
|
contentType: false,
|
|
|
|
processData: false
|
|
|
|
});
|
|
|
|
}
|
2018-06-02 00:20:54 +02:00
|
|
|
|
2018-06-03 12:29:08 +02:00
|
|
|
});
|
2018-06-02 00:20:54 +02:00
|
|
|
|
|
|
|
$(document).ready(function()
|
|
|
|
{
|
2018-06-03 12:29:08 +02:00
|
|
|
$('.messages').scrollTop($('.messages')[0].scrollHeight)
|
|
|
|
|
2018-06-02 00:20:54 +02:00
|
|
|
$("#table").tablesorter();
|
2018-06-03 12:29:08 +02:00
|
|
|
|
2018-06-02 00:20:54 +02:00
|
|
|
}
|
2018-06-03 12:29:08 +02:00
|
|
|
|
2018-06-02 00:20:54 +02:00
|
|
|
);
|
2018-06-03 16:36:43 +02:00
|
|
|
|
|
|
|
// Autocomplete for search - Contact Joca in case of trouble
|
2018-06-11 12:01:51 +02:00
|
|
|
// Check: Code doesn't work inside document.ready function
|
|
|
|
// Are the other functions correctly closed?
|
2018-06-11 14:44:11 +02:00
|
|
|
function split( val ) {
|
|
|
|
return val.split( /,\s*/ );
|
|
|
|
}
|
|
|
|
function extractLast( term ) {
|
|
|
|
return split( term ).pop();
|
|
|
|
}
|
2018-06-03 16:36:43 +02:00
|
|
|
|
2018-06-11 14:44:11 +02:00
|
|
|
$( "#search" )
|
|
|
|
// don't navigate away from the field on tab when selecting an item
|
|
|
|
.on( "keydown", function( event ) {
|
|
|
|
if ( event.keyCode === $.ui.keyCode.TAB &&
|
|
|
|
$( this ).autocomplete( "instance" ).menu.active ) {
|
|
|
|
event.preventDefault();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.autocomplete({
|
|
|
|
source:function(request, response) {
|
|
|
|
$.getJSON("/autocomplete_suggestions",{
|
|
|
|
q: request.term, // in flask, "q" will be the argument to look for using request.args
|
|
|
|
}, function(data) {
|
|
|
|
response(data); // matching_results from jsonify
|
|
|
|
});
|
|
|
|
},
|
|
|
|
search: function() {
|
|
|
|
// custom minLength
|
|
|
|
var term = extractLast( this.value );
|
|
|
|
if ( term.length < 2 ) {
|
|
|
|
return false;
|
2018-06-11 12:01:51 +02:00
|
|
|
}
|
2018-06-11 14:44:11 +02:00
|
|
|
},
|
|
|
|
focus: function() {
|
|
|
|
// prevent value inserted on focus
|
|
|
|
return false;
|
|
|
|
},
|
|
|
|
select: function( event, ui ) {
|
|
|
|
console.log(this.value);
|
|
|
|
str = this.value;
|
|
|
|
var terms = str.split(" ");
|
|
|
|
console.log(terms);
|
|
|
|
// remove the current input
|
|
|
|
terms.pop();
|
|
|
|
// add the selected item
|
|
|
|
terms.push( ui.item.value );
|
|
|
|
// add placeholder to get the comma-and-space at the end
|
|
|
|
terms.push( "" );
|
|
|
|
this.value = terms.join( " " );
|
|
|
|
return false;
|
|
|
|
}
|
2018-06-03 16:36:43 +02:00
|
|
|
});
|
2018-06-09 22:05:47 +02:00
|
|
|
|
|
|
|
// Get the modal
|
|
|
|
var modal = document.getElementById('myModal');
|
|
|
|
|
|
|
|
// Get the button that opens the modal
|
|
|
|
var btn = document.getElementById("myBtn");
|
|
|
|
|
|
|
|
// Get the <span> element that closes the modal
|
|
|
|
var span = document.getElementsByClassName("close")[0];
|
|
|
|
|
2018-06-13 13:17:34 +02:00
|
|
|
// When the user clicks on the button, open the modal
|
2018-06-09 22:05:47 +02:00
|
|
|
btn.onclick = function() {
|
|
|
|
modal.style.display = "block";
|
|
|
|
}
|
|
|
|
|
|
|
|
// When the user clicks on <span> (x), close the modal
|
|
|
|
span.onclick = function() {
|
|
|
|
modal.style.display = "none";
|
|
|
|
}
|
|
|
|
|
|
|
|
// When the user clicks anywhere outside of the modal, close it
|
|
|
|
window.onclick = function(event) {
|
|
|
|
if (event.target == modal) {
|
|
|
|
modal.style.display = "none";
|
|
|
|
}
|
|
|
|
}
|