var marked = false; var markreadtimer = null; var currentsound = ''; function updatePosition( ) { //jQuery('#content').css( 'paddingTop', jQuery( '#header' ).height( ) ); } function LightenDarkenColor(col, amt) { var usePound = false; if (col[0] == "#") { col = col.slice(1); usePound = true; } var num = parseInt(col,16); var r = (num >> 16) + amt; if (r > 255) r = 255; else if (r < 0) r = 0; var b = ((num >> 8) & 0x00FF) + amt; if (b > 255) b = 255; else if (b < 0) b = 0; var g = (num & 0x0000FF) + amt; if (g > 255) g = 255; else if (g < 0) g = 0; return (usePound?"#":"") + (g | (b << 8) | (r << 16)).toString(16); } function copyToMine( id, link ) { getCopyDialog( id, false, link ); } function copyToClass( id, link ) { getCopyDialog( id, true, link ); } function getCopyDialog( id, isclass, link ) { jQuery.post( "/includes/getCopyDialog.php", { id : id, isclass : isclass, link : link }, function( result ) { if( result.length > 1 ) { jQuery( '#popup' ).html( result ).dialog( ); jQuery( '#closecopyarticle' ).on( 'click', function( ) { closeAndClearPopup( ); } ); jQuery( '#copyarticleandclose' ).on( 'click', function( ) { copyAndClearPopup( ); } ); } } ); } function copyAndClearPopup( ) { var categories = jQuery( '#categoryids' ).val( ); if( categories == null ) { alert( "V\u00E6lg venligst en/flere mappe(r)"); return; } jQuery.post( "/includes/copyArticle.php", { isclass : jQuery( '#copyarticleisclass' ).val( ), id : jQuery( '#copyarticleid' ).val( ), categoryids : jQuery( '#categoryids' ).val( ), link : jQuery( '#copyarticlelink' ).val( ) }, function( response ) { if( response.indexOf( 'result' ) != -1 ) { var result = JSON.parse( response ); if( result.result == 'success' ) { jQuery( '#popup' ).html( result.message ); setTimeout( closeAndClearPopup, 2000 ); } else { alert( result.message ); } } } ); } function closeAndClearPopup( ) { jQuery( '#popup' ).html( "" ).dialog( 'destroy' ); } function checkRead( url ) { jQuery.post( '/includes/modules/m_schoolbagtaskgenerator/includes/checkRead.php', { url : url }, function( response ) { if( response.indexOf( 'message' ) != -1 ) { var result = JSON.parse( response ); if( result.message == 'success' ) { switch( result.type ) { case 'Article': case 'ArticleRelation': jQuery(window).scroll(function(){ checkBottomArticle( url ); }); checkBottomArticle( url ); break; } } } } ); } function checkBottomArticle( url ) { if( marked == false ) { var offsetbottom = parseInt( jQuery( "#footer" ).css( "paddingTop" ) ) + jQuery( "#footer" ).height( ); if( jQuery( window ).scrollTop( ) + jQuery( window ).height( ) >= jQuery( document ).height( ) - offsetbottom ) { if( markreadtimer == null ) { markreadtimer = setTimeout( "markRead( '" + url + "' );", 10000 ); } } } } function markRead( url ) { if( marked == false ) { jQuery.post( '/includes/modules/m_schoolbagtaskgenerator/includes/markRead.php', { url : url }, function( result ) { marked = true; } ); } } function markPoints( url, points, answers ) { if( marked == false ) { jQuery.post( '/includes/modules/m_schoolbagtaskgenerator/includes/markPoints.php', { url : url, points : points, answers : answers }, function( result ) { marked = true; } ); } } function startLex( customclass ) { if( !customclass ) { customclass = 'lextooltip'; } jQuery( document ).tooltip( { items : '.' + customclass, tooltipClass : 'preview-tip', position : { my: "left+15 top", at: "right center" }, content : function( callback ) { id = jQuery( this ).prop( 'id' ).substring( 5 ); jQuery.post('/includes/getLemmaContent.php', { id : id }, function( data ) { callback( data ); } ); }, } ); } function prepareGroup( ) { jQuery( '.playgroupicon' ).each( function( ) { if( jQuery( this ).prop( 'class' ).indexOf( 'sounds' ) != -1 ) { addAudioElement( jQuery( this ).prop( 'id' ).substring( 5 ), true ); } } ); jQuery( '.playgroupicon' ).click( function () { jQuery( '#sound' + jQuery( this ).prop( 'id' ).substring( 5 )).trigger( 'play' ); } ); } function addAudioElement( id, addelement ) { jQuery.get( '/extern/getGroupSound.php', { id : id, }, function( filename ) { if( filename.length > 0 ) { if( addelement == true ) { jQuery( "body" ).append( '' ); } else { jQuery( '#sound' + id ).attr( 'src', filename ); } } } ); } function getPath( path ) { if( path != false ) { return path.split( '/' ).slice( 0, -1 ).join( '/' ) + '/'; } else { return path; } } function getFilename( path ) { if( path != false ) { var filename = path.substring(path.lastIndexOf("/") + 1); if(filename.indexOf('mp3')) { filename = filename.substring(0,filename.lastIndexOf(".")); } return filename; } else { return path; } }