Forums / Cotonti / Extensions / new jQuery module

jPlayer

booka
#1 2010-03-25 03:10
Can anyone please tell how I can add some javascript which can be used as pluging without hacking the core?

I need to add nezt piece of code
<head>
part. Now it is fixed but I suppose to add possibility of changing some parameters with PHP.
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.jplayer.min.js"></script>
<script type="text/javascript" src="js/demos.common.js"></script>
<script>

$(document).ready(function(){

   $("#jquery_jplayer").jPlayer({
		ready: function () {
			//playTrack("http://localfest/audio/morcheeba_-_world_looking_in.mp3",$("#worldlookingin").text());
			//demoInstanceInfo(this.element, $("#demo_info")); // This displays information about jPlayer's configuration in the demo page
		},
		customCssIds: true
	})
	.jPlayer("onProgressChange", function(lp,ppr,ppa,pt,tt) {
 		$("#pcent").text(parseInt(ppa)+"%");
	});


	$("#pause").hide();

	function showPauseBtn()
	{
		$("#play").fadeOut(function(){
			$("#pause").fadeIn();
		});
	}

	function showPlayBtn()
	{
		$("#pause").fadeOut(function(){
			$("#play").fadeIn();
		});
	}

	function playTrack(t,n)
	{
		$("#jquery_jplayer").jPlayer("setFile", t).jPlayer("play");

		showPauseBtn();

		$("#trackname").fadeOut(function(){
			$("#trackname").text(n);
			$("#trackname").fadeIn();
		});

		$("#pcent").fadeOut(function(){
			$("#pcent").fadeIn();
		});

		return false;
	}

	$("#worldlookingin").click(function() {
 		return(playTrack("audio/morcheeba_-_world_looking_in.mp3",$("#worldlookingin").text()));
	});

	$("#thesea").click(function() {
		return(playTrack("audio/morcheeba_-_the_sea.mp3",$("#thesea").text()));
	});

	$("#blindfold").click(function() {
		return(playTrack("audio/morcheeba_-_blindfold.mp3",$("#blindfold").text()));
	});

	$("#play").click(function() {
		$("#jquery_jplayer").jPlayer("play");
		showPauseBtn();
		return false;
	});

	$("#pause").click(function() {
		$("#jquery_jplayer").jPlayer("pause");
		showPlayBtn();
		return false;
	});

	$("#stop").click(function() {
		$("#jquery_jplayer").jPlayer("stop");
		showPlayBtn();
		return false;
	});

	$("#vmax").click(function() {
		$("#jquery_jplayer").jPlayer("volume", 100);
		return false;
	});

	$("#vmute").click(function() {
		$("#jquery_jplayer").jPlayer("volume", 0);
		return false;
	});

	$("#vhalf").click(function() {
		$("#jquery_jplayer").jPlayer("volume", 50);
		return false;
	});

});

</script>
booka
ez
#2 2010-03-25 03:19
You could make an custom.js from your code.
Then add it manually to header.tpl
you can find header.tpl in the skins directory

<script type="text/javascript" src="js/custom.js"></script>
==- I say: Keep it EZ -==
booka
#3 2010-03-25 03:43
no I can't... I need change some variables, root to files somewhere... after that add it to javascript
booka
esclkm
#4 2010-03-25 03:59
человек! (так как ты русский) а что в шаблон хедера нельзя вставить??? headar.tpl
какие хаки, какие плагины....
littledev.ru - мой маленький зарождающийся блог о котонти.
снижение стоимости программирования и снижение стоимости производства разные вещи. Первое можно скорее сравнить с раздачей работникам дешевых инструментов, чем со снижением зарплаты
ez
#5 2010-03-25 04:21
Make a simple plugin and parse the JS parts to an TAG with a header hook...

Here is your main PHP code for the plugin


/* ====================
Cotonti - Website engine
http://www.cotonti.com

Plugin: example js (ez)

[BEGIN_SED_EXTPLUGIN]
Code=JSexample
Part=header
File=JSexample
Hooks=header.tags
Tags=header.tpl:{HEADER_JS_EXAMPLE}
Minlevel=0
Order=10
[END_SED_EXTPLUGIN]
==================== */

if (!defined('SED_CODE')) { die('Wrong URL.'); }

$ez_js = "<script type=\"text/javascript\">

// here comes your JS
// Do with it what you want in code

</script>";
	
$t-> assign(array( "HEADER_JS_EXAMPLE" => $ez_js ));
}

ADD {HEADER_JS_EXAMPLE} tag to your header.TPL
==- I say: Keep it EZ -==
booka
#6 2010-03-25 04:33
thanks, I'll try it...

but what about {HEADER_COMPOPUP} tag and variable $out['compopup'] - is it possible to use it?
booka
ez
#7 2010-03-25 04:39
I have looked at this Jplayer... COOL

SO I guess that you want a plugin that plays audio... (that is selected by users)
And the filename is the parameter you are talking about..

This CAN be a nice plugin indeed

Were do you want to use it ?
Page, index, forum posts etc.....

Am I Right ?

How are your programming skills in Cotonti.. This needs some more coding..
==- I say: Keep it EZ -==
booka
#8 2010-03-25 04:58
I had some experience with plugins modification, but...

Ill try to to it as a plugin, but...

I know how to do and multiply plugin for header, page or index hooks, but...

Добавлено 1 час 11 Минут спустя:

ok... I think I catch it now...

I will use SQL-table to store playlist, track codes and names (or generate codes from it's names and unique ID).

Plugin will have at least 2 files:

1) player.header.php with hooks header.main. This will help to add JS between <head> tags.
2) player.header.tags. This will be plugin body for header.tpl

And for begining - I need to add another file for admin to manage strings at SQL
booka

Dit bericht is bewerkt door booka (2010-03-25 06:09, 15 jaren ago)