//IF IPHONE SAFARI USER "tap" INSTEAD OF "click" var userAgent = navigator.userAgent.toLowerCase(); var isiPhone = (userAgent.indexOf('iphone') != -1 || userAgent.indexOf('ipod') != -1) ? true : false; clickEvent = isiPhone ? 'tap' : 'click'; //SCREENSIZE $(document).ready(function() { jQuery('#save_settings').click(function(e){ // WRITE USER SETTINGS var name = $("#piwigo_name").val(); localStorage.setItem("piwigo_name", name); var url = $("#piwigo_url").val(); localStorage.setItem("piwigo_url", url); var username = $("#piwigo_username").val(); localStorage.setItem("piwigo_username", username); var password = $("#piwigo_password").val(); localStorage.setItem("piwigo_password", password); // WRITE HIGH_RES var highres = $('#piwigo_highres:checked').val(); localStorage.setItem("piwigo_highres", highres); e.preventDefault(); // IMAGE SIZE var width = $("#piwigo_width").val(); localStorage.setItem("piwigo_width", width); var height = $("#piwigo_height").val(); localStorage.setItem("piwigo_height", height); var urlLogin = url + 'ws.php?format=json&method=pwg.session.login&username=' +username+ '&password=' +password; //alert(urlLogin); $.ajax({ type: "POST", url: "http://localhost:8888/piwigo/ws.php", data: "format=json&method=pwg.session.login&username=admin&password=admin", success: function(msg){ //$("#settings .bindSuccess").hide().prepend(''); $('').hide().prependTo('#settings .bindSuccess').fadeIn(200); $("#settings #success").delay(2000).fadeOut("slow"); } }); }); // LOAD USER SETTINGS var name = localStorage.getItem("piwigo_name"); $("#piwigo_name").val(name); var url = localStorage.getItem("piwigo_url"); $("#piwigo_url").val(url); var username = localStorage.getItem("piwigo_username"); $("#piwigo_username").val(username); var password = localStorage.getItem("piwigo_password"); $("#piwigo_password").val(password); // HIGH_RES - LOAD var highres = localStorage.getItem("piwigo_highres"); if(highres=='on'){ $('#piwigo_highres').attr("checked","checked"); } else{ } // IMAGE SIZE var width = localStorage.getItem("piwigo_width"); $("#piwigo_width").val(width); var height = localStorage.getItem("piwigo_height"); $("#piwigo_height").val(height); $("a.categoriesLink").tap(function(e){ var url = $(this).attr('url'); $('.images').empty(); $.getJSON(url, function(data) { for (var i=0; i
'+image.file+ '
'); } }); }); $("a.imagesLink").tap(function(e){ var url = $(this).attr('url'); $('ul.images li').removeClass('selected'); $(this).parent('li').addClass('selected'); $('.imageZoom').empty(); $('.imageZoom').append('
  • '); }); $("a.prev").tap(function(e){ var url = $('li.selected').prev().attr('url'); var prevLi = $('li.selected').prev(); var title = $('li.selected .file').html(); if (typeof url == 'undefined') { e.preventDefault(); } else { //alert(url); $('.imageZoom').empty(); $('.imageZoom').append('
  • '); $('#imageZoom h1').text(title); console.log('Big image loaded ' +url); $('ul.images li:not(:first)').removeClass('selected'); $(prevLi).addClass('selected'); } }); $("a.play").tap(function(e){ var interval = $(this).replaceWith('Pause'); var url = $('li.selected').next().attr('url'); var nextLi = $('li.selected').next(); if (typeof url == 'undefined') { e.preventDefault(); } else { window.setInterval(function(play){ $("a.next").click(); },2000); } }); $("a.pause").tap(function(e){ $(this).replaceWith('Play'); window.clearInterval(function(play){ $("a.next").click(); },2000); }); $("a.next").tap(function(e){ var url = $('li.selected').next().attr('url'); var nextLi = $('li.selected').next(); var title = $('li.selected .file').html(); if (typeof url == 'undefined') { e.preventDefault(); } else { //alert(url); $('.imageZoom').empty(); $('.imageZoom').append('
  • '); $('#imageZoom h1').text(title); console.log('Big image loaded ' +url); $('ul.images li:not(:last)').removeClass('selected'); $(nextLi).addClass('selected'); } }); $.getJSON( /* "http://piwigo.knallimall.org/ws.php?format=json&method=pwg.categories.getList", */ "http://localhost:8888/piwigo/ws.php?format=json&method=pwg.categories.getList", function(data) { /* alert(dump(data)); */ for (var i=0; i'+category.name+' '+category.total_nb_images+' '); } } ); /** * Function : dump() * Arguments: The data - array,hash(associative array),object * The level - OPTIONAL * Returns : The textual representation of the array. * This function was inspired by the print_r function of PHP. * This will accept some data as the argument and return a * text that will be a more readable version of the * array/hash/object that is given. */ function dump(arr,level) { var dumped_text = ""; if(!level) level = 0; //The padding given at the beginning of the line. var level_padding = ""; for(var j=0;j \"" + value + "\"\n"; } } } else { //Stings/Chars/Numbers etc. dumped_text = "===>"+arr+"<===("+typeof(arr)+")"; } return dumped_text; } }); // JQTOUCH var jQT = new $.jQTouch({ icon: 'jqtouch.png', addGlossToIcon: false, startupScreen: 'jqt_startup.png', statusBar: 'black', preloadImages: [ 'themes/piwigo/img/back_button.png', 'themes/piwigo/img/back_button_clicked.png', 'themes/piwigo/img/button_clicked.png', 'themes/piwigo/img/grayButton.png', 'themes/piwigo/img/whiteButton.png', 'themes/piwigo/img/loading.gif' ] }); // Some sample Javascript functions: $(function(){ // Orientation callback event $('body').bind('turn', function(e, data){ if (data.orientation == 'landscape') { $(this).addClass('wide'); $(this).removeClass('small'); var $winWidth = $(window).width(); var $winHeight = $(window).height(); $(".fullscreen img").attr({ width: $winWidth, height: $winHeight }); } else{ $(this).addClass('small'); $(this).removeClass('wide'); var $winWidth = $(window).width(); var $winHeight = $(window).height(); $(".fullscreen img").attr({ width: $winWidth, height: $winHeight }); } }); });