style(legacy): format (#2039)

This commit is contained in:
Jonas L 2022-08-10 13:38:19 +02:00 committed by GitHub
parent 7082c9693d
commit 1550d44ac5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
122 changed files with 18369 additions and 15819 deletions

View File

@ -32,7 +32,7 @@ repos:
hooks: hooks:
- id: prettier - id: prettier
files: \.(md|mdx|yml|yaml|js|jsx|ts|tsx|json|css)$ files: \.(md|mdx|yml|yaml|js|jsx|ts|tsx|json|css)$
exclude: ^legacy/public exclude: ^legacy/public(?!/js/airtime)
- repo: https://github.com/asottile/pyupgrade - repo: https://github.com/asottile/pyupgrade
rev: v2.34.0 rev: v2.34.0

View File

@ -21,7 +21,10 @@
$scs = $this->SourceConnectionStatus(); $scs = $this->SourceConnectionStatus();
?> ?>
<?php echo $this->partial('partialviews/header.phtml', array( <?php echo $this->partial('partialviews/header.phtml', array(
"live_dj_switch" => $sss['live_dj'], "live_dj_connection" => $scs['live_dj'], "master_dj_switch" => $sss['master_dj'], "master_dj_connection" => $scs['master_dj'], "live_dj_switch" => $sss['live_dj'],
"live_dj_connection" => $scs['live_dj'],
"master_dj_switch" => $sss['master_dj'],
"master_dj_connection" => $scs['master_dj'],
"scheduled_play_switch" => $sss['scheduled_play'] "scheduled_play_switch" => $sss['scheduled_play']
)) ?> )) ?>
<?php $partial = array('menu.phtml', 'default'); <?php $partial = array('menu.phtml', 'default');

View File

@ -77,9 +77,11 @@
</div> </div>
<div class="jp-no-solution"> <div class="jp-no-solution">
<span><?php echo _("Update Required") ?></span> <span><?php echo _("Update Required") ?></span>
<?php sprintf(_("To play the media you will need to either update your browser to a recent version or update your %sFlash plugin%s."), <?php sprintf(
_("To play the media you will need to either update your browser to a recent version or update your %sFlash plugin%s."),
"<a href='http://get.adobe.com/flashplayer/' target='_blank'>", "<a href='http://get.adobe.com/flashplayer/' target='_blank'>",
"</a>") ?> "</a>"
) ?>
</div> </div>
</div> </div>
</div> </div>

View File

@ -6,9 +6,11 @@
$productSiteAnchor = "<a href='" . PRODUCT_SITE_URL . "' target='_blank'>" $productSiteAnchor = "<a href='" . PRODUCT_SITE_URL . "' target='_blank'>"
. PRODUCT_NAME . PRODUCT_NAME
. "</a>"; . "</a>";
echo sprintf(_('%1$s %2$s, the open radio software for scheduling and remote station management.'), echo sprintf(
_('%1$s %2$s, the open radio software for scheduling and remote station management.'),
$productSiteAnchor, $productSiteAnchor,
$this->airtime_version) $this->airtime_version
)
?> ?>
<br /> <br />
<br />© <?php echo (gmdate('Y')); ?> <br />© <?php echo (gmdate('Y')); ?>
@ -19,8 +21,12 @@ $companySiteAnchor = "<a href='" . COMPANY_SITE_URL . "' target='_blank'>"
$licenseAnchor = "<a href='" . LICENSE_URL . "' target='_blank'>" $licenseAnchor = "<a href='" . LICENSE_URL . "' target='_blank'>"
. LICENSE_VERSION . LICENSE_VERSION
. "</a>"; . "</a>";
echo sprintf(_('%1$s %2$s is distributed under the %3$s'), echo sprintf(
$companySiteAnchor, PRODUCT_NAME, $licenseAnchor) _('%1$s %2$s is distributed under the %3$s'),
$companySiteAnchor,
PRODUCT_NAME,
$licenseAnchor
)
?> ?>
</p> </p>
</div> </div>

View File

@ -3,11 +3,16 @@
<p><?php echo sprintf(_("Here's how you can get started using %s to automate your broadcasts: "), PRODUCT_NAME) ?></p> <p><?php echo sprintf(_("Here's how you can get started using %s to automate your broadcasts: "), PRODUCT_NAME) ?></p>
<ol> <ol>
<li><h4><?php echo _("Upload audio tracks");?></h4> <li>
<?php echo _("Click the 'Upload' button in the left corner to upload tracks to your library.")?></li> <h4><?php echo _("Upload audio tracks"); ?></h4>
<li><h4><?php echo _("Schedule a show");?></h4> <?php echo _("Click the 'Upload' button in the left corner to upload tracks to your library.") ?>
<?php echo _("Click on 'Calendar' in the navigation bar on the left. From there click the '+ New Show' button and fill out the required fields.")?></li> </li>
<li><h4><?php echo _("Add tracks to your show"); ?></h4> <li>
<h4><?php echo _("Schedule a show"); ?></h4>
<?php echo _("Click on 'Calendar' in the navigation bar on the left. From there click the '+ New Show' button and fill out the required fields.") ?>
</li>
<li>
<h4><?php echo _("Add tracks to your show"); ?></h4>
<?php echo _("Click on your show in the calendar and select 'Schedule Show'. In the popup window drag tracks into your show."); ?> <?php echo _("Click on your show in the calendar and select 'Schedule Show'. In the popup window drag tracks into your show."); ?>
</li> </li>
@ -16,8 +21,11 @@
<p><strong><?php echo _("Now you're good to go!") ?></strong><br /> <p><strong><?php echo _("Now you're good to go!") ?></strong><br />
<?php <?php
$userManualAnchorOpen = "<a href='" . USER_MANUAL_URL . "' target='_blank'>"; $userManualAnchorOpen = "<a href='" . USER_MANUAL_URL . "' target='_blank'>";
echo sprintf(_("For more detailed help, read the %suser manual%s."), echo sprintf(
$userManualAnchorOpen, "</a>") _("For more detailed help, read the %suser manual%s."),
$userManualAnchorOpen,
"</a>"
)
?> ?>
</p> </p>

View File

@ -119,6 +119,7 @@
playerhtml5_audio.pause(); playerhtml5_audio.pause();
togglePlayStopButton(); togglePlayStopButton();
}; };
function togglePlayStopButton() { function togglePlayStopButton() {
document.getElementById("play_button").classList.toggle("hide_button"); document.getElementById("play_button").classList.toggle("hide_button");
document.getElementById("stop_button").classList.toggle("hide_button"); document.getElementById("stop_button").classList.toggle("hide_button");
@ -145,8 +146,12 @@
// //
// The metadata is fetched when the current track is about to end. // The metadata is fetched when the current track is about to end.
function attachStreamMetadataToPlayer() { function attachStreamMetadataToPlayer() {
$.ajax({url: "<?php echo $this->metadata_api_url?>", $.ajax({
data: {type:"interval",limit:"5"}, url: "<?php echo $this->metadata_api_url ?>",
data: {
type: "interval",
limit: "5"
},
dataType: "jsonp", dataType: "jsonp",
success: function(data) { success: function(data) {
@ -201,8 +206,6 @@
} }
</script> </script>
<style type="text/css"> <style type="text/css">
@ -212,14 +215,19 @@
not work. It has to be "visible" on the page. As a hacky work around we not work. It has to be "visible" on the page. As a hacky work around we
set the height and width to 1px so users will not see it. set the height and width to 1px so users will not see it.
*/ */
#html5player_skin{width:0; height:0; overflow: hidden;} #html5player_skin {
width: 0;
height: 0;
overflow: hidden;
}
</style> </style>
</head> </head>
<body> <body>
<div id="player" <?php if ($this->player_style == "basic") echo "style='display:block;'"; else echo "style='display:none'"; ?>> <div id="player" <?php if ($this->player_style == "basic") echo "style='display:block;'";
else echo "style='display:none'"; ?>>
<div class="airtime_player"> <div class="airtime_player">
<div class="airtime_header"> <div class="airtime_header">
@ -249,7 +257,8 @@
</div> </div>
</div> </div>
<div id="premium_player" <?php if ($this->player_style == "premium") echo "style='display:block;'"; else echo "style='display:none'"; ?>> <div id="premium_player" <?php if ($this->player_style == "premium") echo "style='display:block;'";
else echo "style='display:none'"; ?>>
<div class="bottom_bar"> <div class="bottom_bar">
<div class="play cont_btn"></div> <div class="play cont_btn"></div>
@ -267,4 +276,5 @@
</div> </div>
</body> </body>
</html> </html>

View File

@ -56,10 +56,15 @@
var format_start_date = start_date.getFullYear() + "-" + (start_date.getMonth() + 1) + "-" + start_date.getDate(); var format_start_date = start_date.getFullYear() + "-" + (start_date.getMonth() + 1) + "-" + start_date.getDate();
// Assign show to correct location // Assign show to correct location
if (importSchedule["weekDays"][format_start_date] !== undefined) { if (importSchedule["weekDays"][format_start_date] !== undefined) {
importSchedule["weekDays"][format_start_date]["shows"].push( importSchedule["weekDays"][format_start_date]["shows"].push({
{ "show_start_hour": start_date.toLocaleTimeString([], {
"show_start_hour": start_date.toLocaleTimeString([], { hour: 'numeric', minute : 'numeric' }), hour: 'numeric',
"show_end_hour": end_date.toLocaleTimeString([], { hour: 'numeric', minute : 'numeric' }), minute: 'numeric'
}),
"show_end_hour": end_date.toLocaleTimeString([], {
hour: 'numeric',
minute: 'numeric'
}),
"name": element.name "name": element.name
}); });
} }
@ -98,7 +103,7 @@
$("#" + tab_id).addClass('active'); $("#" + tab_id).addClass('active');
}); });
}); });
</script> </script>
</body> </body>
</html> </html>

View File

@ -1,10 +1,12 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo _("An error has occurred.") ?></title> <title><?php echo _("An error has occurred.") ?></title>
<?php echo $this->headLink(); ?> <?php echo $this->headLink(); ?>
</head> </head>
<body> <body>
<div class="error-content" id="error-400"> <div class="error-content" id="error-400">
<h2><?php echo _("Bad Request!") ?></h2> <h2><?php echo _("Bad Request!") ?></h2>
@ -14,4 +16,5 @@
</div> </div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -1,10 +1,12 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo _("An error has occurred.") ?></title> <title><?php echo _("An error has occurred.") ?></title>
<?php echo $this->headLink(); ?> <?php echo $this->headLink(); ?>
</head> </head>
<body> <body>
<div class="error-content" id="error-403"> <div class="error-content" id="error-403">
<h2><?php echo _("Access Denied!") ?></h2> <h2><?php echo _("Access Denied!") ?></h2>
@ -14,4 +16,5 @@
</div> </div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -1,10 +1,12 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo _("An error has occurred.") ?></title> <title><?php echo _("An error has occurred.") ?></title>
<?php echo $this->headLink(); ?> <?php echo $this->headLink(); ?>
</head> </head>
<body> <body>
<div class="error-content" id="error-404"> <div class="error-content" id="error-404">
<h2><?php echo _("Page not found!") ?></h2> <h2><?php echo _("Page not found!") ?></h2>
@ -14,4 +16,5 @@
</div> </div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -1,10 +1,12 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"> <html xmlns="http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo _("An error has occurred.") ?></title> <title><?php echo _("An error has occurred.") ?></title>
<?php echo $this->headLink(); ?> <?php echo $this->headLink(); ?>
</head> </head>
<body> <body>
<div class="error-content" id="error-500"> <div class="error-content" id="error-500">
<h2><?php echo _("Oops!") ?></h2> <h2><?php echo _("Oops!") ?></h2>
@ -14,4 +16,5 @@
</div> </div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -1,11 +1,12 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"; <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" ; "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>
<html xmlns=" http://www.w3.org/1999/xhtml"> <html xmlns=" http://www.w3.org/1999/xhtml">
<head> <head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo _("An error has occurred.") ?></title> <title><?php echo _("An error has occurred.") ?></title>
<?php echo $this->headLink(); ?> <?php echo $this->headLink(); ?>
</head> </head>
<body> <body>
<div class="error-content"> <div class="error-content">
<h2><?php echo $this->escape($this->message) ?></h2> <h2><?php echo $this->escape($this->message) ?></h2>
@ -15,4 +16,5 @@
</div> </div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -1,6 +1,8 @@
<dt id="<?php echo $this->element->getName() ?>-label" class="<?php echo $this->class ?>"> <dt id="<?php echo $this->element->getName() ?>-label" class="<?php echo $this->class ?>">
<?php echo $this->formLabel($this->element->getName(), <?php echo $this->formLabel(
$this->element->getLabel()) ?> $this->element->getName(),
$this->element->getLabel()
) ?>
</dt> </dt>
<dd id="<?php echo $this->element->getName() ?>-element" class="<?php echo $this->class ?>"> <dd id="<?php echo $this->element->getName() ?>-element" class="<?php echo $this->class ?>">
<?php echo $this->{$this->element->helper}( <?php echo $this->{$this->element->helper}(

View File

@ -8,7 +8,10 @@
<?php for ($i = 1; $i <= 10; $i++) : ?> <?php for ($i = 1; $i <= 10; $i++) : ?>
<li <?php if (($i > 1) <li <?php if (($i > 1)
&& ($this->element->getElement('add_show_rebroadcast_date_absolute_' . $i)->getValue() == "" && ($this->element->getElement('add_show_rebroadcast_date_absolute_' . $i)->getValue() == ""
&& $this->element->getElement('add_show_rebroadcast_time_absolute_'.$i)->getValue() == "")){echo 'style=display:none';} ?>> && $this->element->getElement('add_show_rebroadcast_time_absolute_' . $i)->getValue() == "")
) {
echo 'style=display:none';
} ?>>
<?php echo $this->element->getElement('add_show_rebroadcast_date_absolute_' . $i) ?> <?php echo $this->element->getElement('add_show_rebroadcast_date_absolute_' . $i) ?>
<span class="inline-text">@</span> <span class="inline-text">@</span>
<?php echo $this->element->getElement('add_show_rebroadcast_time_absolute_' . $i) ?> <?php echo $this->element->getElement('add_show_rebroadcast_time_absolute_' . $i) ?>
@ -19,7 +22,8 @@
</a> </a>
<?php endif; ?> <?php endif; ?>
<?php if (($this->element->getElement('add_show_rebroadcast_date_absolute_' . $i)->hasErrors()) <?php if (($this->element->getElement('add_show_rebroadcast_date_absolute_' . $i)->hasErrors())
|| ($this->element->getElement('add_show_rebroadcast_time_absolute_'.$i)->hasErrors())) : ?> || ($this->element->getElement('add_show_rebroadcast_time_absolute_' . $i)->hasErrors())
) : ?>
<ul class='errors'> <ul class='errors'>
<?php $errors = array_merge( <?php $errors = array_merge(
$this->element->getElement('add_show_rebroadcast_date_absolute_' . $i)->getMessages(), $this->element->getElement('add_show_rebroadcast_date_absolute_' . $i)->getMessages(),

View File

@ -8,7 +8,10 @@
<?php for ($i = 1; $i <= 10; $i++) : ?> <?php for ($i = 1; $i <= 10; $i++) : ?>
<li <?php if (($i > 1) <li <?php if (($i > 1)
&& ($this->element->getElement('add_show_rebroadcast_date_' . $i)->getValue() == "" && ($this->element->getElement('add_show_rebroadcast_date_' . $i)->getValue() == ""
&& $this->element->getElement('add_show_rebroadcast_time_'.$i)->getValue() == "")){echo 'style=display:none';} ?>> && $this->element->getElement('add_show_rebroadcast_time_' . $i)->getValue() == "")
) {
echo 'style=display:none';
} ?>>
<?php echo $this->element->getElement('add_show_rebroadcast_date_' . $i) ?> <?php echo $this->element->getElement('add_show_rebroadcast_date_' . $i) ?>
<span class="inline-text">@</span> <span class="inline-text">@</span>
<?php echo $this->element->getElement('add_show_rebroadcast_time_' . $i) ?> <?php echo $this->element->getElement('add_show_rebroadcast_time_' . $i) ?>
@ -19,7 +22,8 @@
</a> </a>
<?php endif; ?> <?php endif; ?>
<?php if (($this->element->getElement('add_show_rebroadcast_date_' . $i)->hasErrors()) <?php if (($this->element->getElement('add_show_rebroadcast_date_' . $i)->hasErrors())
|| ($this->element->getElement('add_show_rebroadcast_time_'.$i)->hasErrors())) : ?> || ($this->element->getElement('add_show_rebroadcast_time_' . $i)->hasErrors())
) : ?>
<ul class='errors'> <ul class='errors'>
<?php $errors = array_merge( <?php $errors = array_merge(
$this->element->getElement('add_show_rebroadcast_date_' . $i)->getMessages(), $this->element->getElement('add_show_rebroadcast_date_' . $i)->getMessages(),

View File

@ -1,6 +1,8 @@
<dt id="<?php echo $this->element->getName() ?>-label" class="<?php echo $this->class ?>"> <dt id="<?php echo $this->element->getName() ?>-label" class="<?php echo $this->class ?>">
<?php echo $this->formLabel($this->element->getName(), <?php echo $this->formLabel(
$this->element->getLabel()) ?> $this->element->getName(),
$this->element->getLabel()
) ?>
</dt> </dt>
<dd id="<?php echo $this->element->getName() ?>-element"> <dd id="<?php echo $this->element->getName() ?>-element">
<?php echo $this->{$this->element->helper}( <?php echo $this->{$this->element->helper}(
@ -9,5 +11,7 @@
$this->element->getAttribs() $this->element->getAttribs()
) ?> ) ?>
<?php if($this->element->hasErrors()) { echo $this->formErrors($this->element->getMessages());} ?> <?php if ($this->element->hasErrors()) {
echo $this->formErrors($this->element->getMessages());
} ?>
</dd> </dd>

View File

@ -12,7 +12,8 @@
<dt id="add_show_start_date-label"> <dt id="add_show_start_date-label">
<label for="add_show_start_date" class="required"> <label for="add_show_start_date" class="required">
<?php //echo $this->element->getElement('add_show_start_date')->getLabel()?> <?php //echo $this->element->getElement('add_show_start_date')->getLabel()
?>
</label> </label>
</dt> </dt>
<dd> <dd>

View File

@ -1,19 +1,15 @@
<style type="text/css"> <style type="text/css">
.player-title { .player-title {
width: 70px; width: 70px;
border-style: none border-style: none float: left;
float: left;
} }
.preview-label { .preview-label {
line-height: 60px; line-height: 60px;
border-style: none border-style: none float: left;
float: left;
font-size: 20px; font-size: 20px;
color: #fff color: #fff
} }
</style> </style>
<fieldset class="padded"> <fieldset class="padded">
<dl class="zend_form"> <dl class="zend_form">
@ -38,7 +34,8 @@
<?php echo $this->element->getElement('player_embed_src')->render(); ?> <?php echo $this->element->getElement('player_embed_src')->render(); ?>
<?php //echo $this->element->getElement('player_display_track_metadata'); ?> <?php //echo $this->element->getElement('player_display_track_metadata');
?>
<table id="player_compatibility_chart" style="text-align:center; position:relative; top:40px;"> <table id="player_compatibility_chart" style="text-align:center; position:relative; top:40px;">
<th colspan="5" style="text-align:center"><?php echo _("Stream Compatibility") ?></th> <th colspan="5" style="text-align:center"><?php echo _("Stream Compatibility") ?></th>

View File

@ -16,7 +16,8 @@
</ul> </ul>
<?php endif; ?> <?php endif; ?>
</dd> </dd>
<dd class="block-display selected-item"><strong><?php echo _("Current Import Folder:"); ?></strong><?php $stor = Application_Model_MusicDir::getStorDir(); echo $stor->getDirectory(); ?></dd> <dd class="block-display selected-item"><strong><?php echo _("Current Import Folder:"); ?></strong><?php $stor = Application_Model_MusicDir::getStorDir();
echo $stor->getDirectory(); ?></dd>
<dt id="watchedFolder-label" class="block-display"> <dt id="watchedFolder-label" class="block-display">
<label class="required" for="watchedFolder"><?php echo $this->element->getElement('watchedFolder')->getLabel() ?></label> <label class="required" for="watchedFolder"><?php echo $this->element->getElement('watchedFolder')->getLabel() ?></label>

View File

@ -9,8 +9,13 @@
<?php echo $this->element->getElement('sb_show_filter') ?> <?php echo $this->element->getElement('sb_show_filter') ?>
<!-- --><?php //if ($this->element->getElement('sb_my_shows')):?> <!-- --><?php //if ($this->element->getElement('sb_my_shows')):
<!-- <label>--><?php //echo $this->element->getElement('sb_my_shows')->getLabel(); ?><!--</label>--> ?>
<!-- --><?php //echo $this->element->getElement('sb_my_shows'); ?> <!-- <label>--><?php //echo $this->element->getElement('sb_my_shows')->getLabel();
<!-- --><?php //endif;?> ?>
<!--</label>-->
<!-- --><?php //echo $this->element->getElement('sb_my_shows');
?>
<!-- --><?php //endif;
?>
</div> </div>

View File

@ -21,7 +21,6 @@
} elseif ($j + 1 <= $this->modRowMap[$i] - 1) { } elseif ($j + 1 <= $this->modRowMap[$i] - 1) {
$n = $j + 1; $n = $j + 1;
$nextIndex = $i . "_" . $n; $nextIndex = $i . "_" . $n;
} }
$nextDisabled = $this->element->getElement("sp_criteria_field_" . $nextIndex)->getAttrib('disabled') == 'disabled' ? true : false; $nextDisabled = $this->element->getElement("sp_criteria_field_" . $nextIndex)->getAttrib('disabled') == 'disabled' ? true : false;
?> ?>
@ -34,7 +33,9 @@
<?php echo $this->element->getElement("sp_criteria_value_" . $i . "_" . $j) ?> <?php echo $this->element->getElement("sp_criteria_value_" . $i . "_" . $j) ?>
<span class='sp_text_font' id="datetime_select" <?php echo $this->element->getElement("sp_criteria_datetime_select_" . $i . "_" . $j)->getAttrib("disabled") == "disabled" ? 'style="display:none;"' : "" ?>><?php echo $this->element->getElement('sp_criteria_datetime_select_' . $i . "_" . $j) ?><?php echo _(" ago "); ?></span> <span class='sp_text_font' id="datetime_select" <?php echo $this->element->getElement("sp_criteria_datetime_select_" . $i . "_" . $j)->getAttrib("disabled") == "disabled" ? 'style="display:none;"' : "" ?>><?php echo $this->element->getElement('sp_criteria_datetime_select_' . $i . "_" . $j) ?><?php echo _(" ago "); ?></span>
<a <?php if ($disabled) { echo 'style=display:none'; } ?> class='modifier_add_link' id='modifier_add_<?php echo $i ?>'> <a <?php if ($disabled) {
echo 'style=display:none';
} ?> class='modifier_add_link' id='modifier_add_<?php echo $i ?>'>
+ <?php echo (_("New Modifier")); ?> + <?php echo (_("New Modifier")); ?>
</a> </a>
@ -93,7 +94,9 @@
foreach ($this->element->getElement('sp_type')->getMultiOptions() as $radio) : ?> foreach ($this->element->getElement('sp_type')->getMultiOptions() as $radio) : ?>
<label class='sp-label' for='sp_type-<?php echo $i ?>'> <label class='sp-label' for='sp_type-<?php echo $i ?>'>
<input type="radio" value="<?php echo $i ?>" id="sp_type-<?php echo $i ?>" name="sp_type" <?php if($i == $value){echo 'checked="checked"';}?> ><?php echo $radio ?> <input type="radio" value="<?php echo $i ?>" id="sp_type-<?php echo $i ?>" name="sp_type" <?php if ($i == $value) {
echo 'checked="checked"';
} ?>><?php echo $radio ?>
</label> </label>
<?php $i = $i + 1; ?> <?php $i = $i + 1; ?>
<?php endforeach; ?> <?php endforeach; ?>

View File

@ -133,6 +133,7 @@
<script type="text/javascript"> <script type="text/javascript">
var playlist; var playlist;
function buildJplayerPlaylist(page, data) { function buildJplayerPlaylist(page, data) {
playlist = new Array(); playlist = new Array();
var media; var media;
@ -292,7 +293,6 @@
} }
} }
); );
</script> </script>
</div> </div>
<?php <?php
@ -354,5 +354,4 @@
}); });
}); });
</script> </script>

View File

@ -6,28 +6,94 @@ foreach ($this->md as $key => &$value) {
?> ?>
<?php if ($this->type == "audioclip") : ?> <?php if ($this->type == "audioclip") : ?>
<table class='library-track-md'> <table class='library-track-md'>
<tr><td><?php echo _("Title:"); ?></td><td><?php echo ($this->md["MDATA_KEY_TITLE"]);?></td></tr> <tr>
<tr><td><?php echo _("Creator:"); ?></td><td><?php echo ($this->md["MDATA_KEY_CREATOR"]);?></td></tr> <td><?php echo _("Title:"); ?></td>
<tr><td><?php echo _("Album:"); ?></td><td><?php echo ($this->md["MDATA_KEY_SOURCE"]);?></td></tr> <td><?php echo ($this->md["MDATA_KEY_TITLE"]); ?></td>
<tr><td><?php echo _("Track:"); ?></td><td><?php echo ($this->md["MDATA_KEY_TRACKNUMBER"]);?></td></tr> </tr>
<tr><td><?php echo _("Length:"); ?></td><td><?php echo ($this->md["MDATA_KEY_DURATION"]);?></td></tr> <tr>
<tr><td class='file-md-qtip-nowrap'><?php echo _("Sample Rate:"); ?></td><td><?php echo ($this->md["MDATA_KEY_SAMPLERATE"]);?></td></tr> <td><?php echo _("Creator:"); ?></td>
<tr><td><?php echo _("Bit Rate:"); ?></td><td><?php echo ($this->md["MDATA_KEY_BITRATE"]);?></td></tr> <td><?php echo ($this->md["MDATA_KEY_CREATOR"]); ?></td>
<tr><td><?php echo _("Mood:"); ?></td><td><?php echo ($this->md["MDATA_KEY_MOOD"]);?></td></tr> </tr>
<tr><td><?php echo _("Genre:"); ?></td><td><?php echo ($this->md["MDATA_KEY_GENRE"]);?></td></tr> <tr>
<tr><td><?php echo _("Year:"); ?></td><td><?php echo ($this->md["MDATA_KEY_YEAR"]);?></td></tr> <td><?php echo _("Album:"); ?></td>
<tr><td><?php echo _("Label:"); ?></td><td><?php echo ($this->md["MDATA_KEY_LABEL"]);?></td></tr> <td><?php echo ($this->md["MDATA_KEY_SOURCE"]); ?></td>
<tr><td><?php echo _("BPM:"); ?></td><td><?php echo ($this->md["MDATA_KEY_BPM"]);?></td></tr> </tr>
<tr><td><?php echo _("Composer:"); ?></td><td><?php echo ($this->md["MDATA_KEY_COMPOSER"]);?></td></tr> <tr>
<tr><td><?php echo _("Conductor:"); ?></td><td><?php echo ($this->md["MDATA_KEY_CONDUCTOR"]);?></td></tr> <td><?php echo _("Track:"); ?></td>
<tr><td><?php echo _("Copyright:"); ?></td><td><?php echo ($this->md["MDATA_KEY_COPYRIGHT"]);?></td></tr> <td><?php echo ($this->md["MDATA_KEY_TRACKNUMBER"]); ?></td>
<tr><td><?php echo _("Isrc Number:"); ?></td><td><?php echo ($this->md["MDATA_KEY_ISRC"]);?></td></tr> </tr>
<tr><td><?php echo _("Website:"); ?></td><td><?php echo ($this->md["MDATA_KEY_URL"]);?></td></tr> <tr>
<tr><td><?php echo _("Artwork:"); ?></td><td><?php echo ($this->md["MDATA_KEY_ARTWORK"]);?></td></tr> <td><?php echo _("Length:"); ?></td>
<tr><td><?php echo _("Artwork Data:"); ?></td><td><?php echo ($this->md["MDATA_KEY_ARTWORK_DATA"]);?></td></tr> <td><?php echo ($this->md["MDATA_KEY_DURATION"]); ?></td>
<tr><td><?php echo _("Language:"); ?></td><td><?php echo ($this->md["MDATA_KEY_LANGUAGE"]);?></td></tr> </tr>
<tr><td><?php echo _("Track Type:"); ?></td><td><?php echo ($this->md["MDATA_KEY_TRACK_TYPE"]);?></td></tr> <tr>
<tr><td class='file-md-qtip-nowrap'><?php echo _("File Path:"); ?></td><td><?php echo ($this->md["MDATA_KEY_FILEPATH"]);?></td></tr> <td class='file-md-qtip-nowrap'><?php echo _("Sample Rate:"); ?></td>
<td><?php echo ($this->md["MDATA_KEY_SAMPLERATE"]); ?></td>
</tr>
<tr>
<td><?php echo _("Bit Rate:"); ?></td>
<td><?php echo ($this->md["MDATA_KEY_BITRATE"]); ?></td>
</tr>
<tr>
<td><?php echo _("Mood:"); ?></td>
<td><?php echo ($this->md["MDATA_KEY_MOOD"]); ?></td>
</tr>
<tr>
<td><?php echo _("Genre:"); ?></td>
<td><?php echo ($this->md["MDATA_KEY_GENRE"]); ?></td>
</tr>
<tr>
<td><?php echo _("Year:"); ?></td>
<td><?php echo ($this->md["MDATA_KEY_YEAR"]); ?></td>
</tr>
<tr>
<td><?php echo _("Label:"); ?></td>
<td><?php echo ($this->md["MDATA_KEY_LABEL"]); ?></td>
</tr>
<tr>
<td><?php echo _("BPM:"); ?></td>
<td><?php echo ($this->md["MDATA_KEY_BPM"]); ?></td>
</tr>
<tr>
<td><?php echo _("Composer:"); ?></td>
<td><?php echo ($this->md["MDATA_KEY_COMPOSER"]); ?></td>
</tr>
<tr>
<td><?php echo _("Conductor:"); ?></td>
<td><?php echo ($this->md["MDATA_KEY_CONDUCTOR"]); ?></td>
</tr>
<tr>
<td><?php echo _("Copyright:"); ?></td>
<td><?php echo ($this->md["MDATA_KEY_COPYRIGHT"]); ?></td>
</tr>
<tr>
<td><?php echo _("Isrc Number:"); ?></td>
<td><?php echo ($this->md["MDATA_KEY_ISRC"]); ?></td>
</tr>
<tr>
<td><?php echo _("Website:"); ?></td>
<td><?php echo ($this->md["MDATA_KEY_URL"]); ?></td>
</tr>
<tr>
<td><?php echo _("Artwork:"); ?></td>
<td><?php echo ($this->md["MDATA_KEY_ARTWORK"]); ?></td>
</tr>
<tr>
<td><?php echo _("Artwork Data:"); ?></td>
<td><?php echo ($this->md["MDATA_KEY_ARTWORK_DATA"]); ?></td>
</tr>
<tr>
<td><?php echo _("Language:"); ?></td>
<td><?php echo ($this->md["MDATA_KEY_LANGUAGE"]); ?></td>
</tr>
<tr>
<td><?php echo _("Track Type:"); ?></td>
<td><?php echo ($this->md["MDATA_KEY_TRACK_TYPE"]); ?></td>
</tr>
<tr>
<td class='file-md-qtip-nowrap'><?php echo _("File Path:"); ?></td>
<td><?php echo ($this->md["MDATA_KEY_FILEPATH"]); ?></td>
</tr>
</table> </table>
<?php endif; ?> <?php endif; ?>
@ -82,7 +148,8 @@ foreach ($this->md as $key => &$value) {
<?php if ($row["type"] == 2) { <?php if ($row["type"] == 2) {
$bl = new Application_Model_Block($row["item_id"]); $bl = new Application_Model_Block($row["item_id"]);
$isStatic = $bl->isStatic(); ?> $isStatic = $bl->isStatic(); ?>
<tr class='file-md-qtip-playlist <?php if ($isStatic) echo 'static'; else echo 'dynamic';?>'> <tr class='file-md-qtip-playlist <?php if ($isStatic) echo 'static';
else echo 'dynamic'; ?>'>
<td class='file-md-qtip-row-width-title file-md-qtip-nowrap'><?php echo $row["track_title"] ?></td> <td class='file-md-qtip-row-width-title file-md-qtip-nowrap'><?php echo $row["track_title"] ?></td>
<td class='file-md-qtip-row-width-artist file-md-qtip-nowrap'><?php echo $row["creator"] ?></td> <td class='file-md-qtip-row-width-artist file-md-qtip-nowrap'><?php echo $row["creator"] ?></td>
<td class='file-md-qtip-row-width-small'><?php echo $bl->getLength(); ?></td> <td class='file-md-qtip-row-width-small'><?php echo $bl->getLength(); ?></td>

View File

@ -10,7 +10,9 @@
<h3><?php echo _("Stream Data Collection Status") ?></h3> <h3><?php echo _("Stream Data Collection Status") ?></h3>
<fieldset class="padded stream-setting-global"> <fieldset class="padded stream-setting-global">
<?php foreach ($this->errorStatus as $k => $v) { ?> <?php foreach ($this->errorStatus as $k => $v) { ?>
<div class='stream-status <?php echo ($v == 'OK')? 'status-good' : 'status-error' ?>'><p><?php echo $k?>: <?php echo $v?></p></div> <div class='stream-status <?php echo ($v == 'OK') ? 'status-good' : 'status-error' ?>'>
<p><?php echo $k ?>: <?php echo $v ?></p>
</div>
<?php } ?> <?php } ?>
</fieldset> </fieldset>
</div> </div>

View File

@ -14,10 +14,13 @@
} }
?> ?>
<?php if ($this->navigation()->accept($page)) : ?> <?php if ($this->navigation()->accept($page)) : ?>
<li class="top <?php if($page->isActive(true)){echo 'active';} ?>"> <li class="top <?php if ($page->isActive(true)) {
echo 'active';
} ?>">
<?php if ($page->hasPages()) : ?> <?php if ($page->hasPages()) : ?>
<a class="top_link" href="<?php echo $page->getHref(); ?>"> <a class="top_link" href="<?php echo $page->getHref(); ?>">
<span class="down"><?php echo $page->getClass(); echo _($page->getLabel()); ?></span> <span class="down"><?php echo $page->getClass();
echo _($page->getLabel()); ?></span>
</a> </a>
<ul class="sub"> <ul class="sub">
@ -29,14 +32,16 @@
<?php if ($this->navigation()->accept($sub)) : ?> <?php if ($this->navigation()->accept($sub)) : ?>
<li> <li>
<a href="<?php echo $sub->getHref(); ?>" <?php echo ($sub->getTarget() != "")?"target=\"".$sub->getTarget()."\"":""; ?>><?php echo $page->getClass(); echo _($sub->getLabel()); ?></a> <a href="<?php echo $sub->getHref(); ?>" <?php echo ($sub->getTarget() != "") ? "target=\"" . $sub->getTarget() . "\"" : ""; ?>><?php echo $page->getClass();
echo _($sub->getLabel()); ?></a>
</li> </li>
<?php endif; ?> <?php endif; ?>
<?php endforeach; ?> <?php endforeach; ?>
</ul> </ul>
<?php else : ?> <?php else : ?>
<a class="top_link" href="<?php echo $page->getHref(); ?>"> <a class="top_link" href="<?php echo $page->getHref(); ?>">
<span><?php echo $page->getClass(); echo _($page->getLabel()); ?></span> <span><?php echo $page->getClass();
echo _($page->getLabel()); ?></span>
</a> </a>
<?php endif; ?> <?php endif; ?>
</li> </li>

View File

@ -9,7 +9,8 @@
<div class="text-row"><strong><?php echo _("Previous:"); ?></strong> <span id='previous'></span> <span id='prev-length'></span></div> <div class="text-row"><strong><?php echo _("Previous:"); ?></strong> <span id='previous'></span> <span id='prev-length'></span></div>
<div class="now-playing-info song"> <div class="now-playing-info song">
<div class="time-flow"><span class="song-length" id="song-length"></span><span class="time-elapsed" id="time-elapsed"></span><span class="time-remaining" id="time-remaining"></span></div> <div class="time-flow"><span class="song-length" id="song-length"></span><span class="time-elapsed" id="time-elapsed"></span><span class="time-remaining" id="time-remaining"></span></div>
<span id='current'></span></div> <span id='current'></span>
</div>
<div class="progressbar"> <div class="progressbar">
<div class="progress-song" id="progress-bar" style="width:0%;"></div> <div class="progress-song" id="progress-bar" style="width:0%;"></div>
</div> </div>

View File

@ -1,4 +1,8 @@
<?php if ($this->objType == "block") { $displayText = "smart block"; } else { $displayText = $this->escape($this->objType); } ?> <?php if ($this->objType == "block") {
$displayText = "smart block";
} else {
$displayText = $this->escape($this->objType);
} ?>
<h3>You do not have permission to edit this <?php echo $displayText; ?>.</h3> <h3>You do not have permission to edit this <?php echo $displayText; ?>.</h3>
<input class="obj_id" type="hidden" value="<?php echo $this->obj->getId(); ?>" /> <input class="obj_id" type="hidden" value="<?php echo $this->obj->getId(); ?>" />
<input class='obj_type' type='hidden' value="<?php echo $this->escape($this->objType); ?>" /> <input class='obj_type' type='hidden' value="<?php echo $this->escape($this->objType); ?>" />

View File

@ -28,7 +28,8 @@ if (isset($this->obj)) {
</dd> </dd>
</dl> </dl>
<?php //echo $this->form; ?> <?php //echo $this->form;
?>
</div> </div>

View File

@ -3,16 +3,12 @@
<input type="button" class="pl-waveform-cues-btn" value="<?php echo _("Show Waveform") ?>"></input> <input type="button" class="pl-waveform-cues-btn" value="<?php echo _("Show Waveform") ?>"></input>
</dd> </dd>
<dt><?php echo _("Cue In: "); ?><span class='spl_cue_hint'><?php echo _("(hh:mm:ss.t)") ?></span></dt> <dt><?php echo _("Cue In: "); ?><span class='spl_cue_hint'><?php echo _("(hh:mm:ss.t)") ?></span></dt>
<dd id="spl_cue_in_<?php echo $this->id; ?>" class="spl_cue_in" <dd id="spl_cue_in_<?php echo $this->id; ?>" class="spl_cue_in" data-cue-in="<?php echo $this->cueIn; ?>" data-cue-sec="<?php echo $this->cueInSec; ?>">
data-cue-in="<?php echo $this->cueIn; ?>"
data-cue-sec="<?php echo $this->cueInSec; ?>">
<span contenteditable="true" class="spl_text_input"><?php echo $this->cueIn; ?></span> <span contenteditable="true" class="spl_text_input"><?php echo $this->cueIn; ?></span>
</dd> </dd>
<dd class="edit-error"></dd> <dd class="edit-error"></dd>
<dt><?php echo _("Cue Out: "); ?><span class='spl_cue_hint'><?php echo _("(hh:mm:ss.t)") ?></span></dt> <dt><?php echo _("Cue Out: "); ?><span class='spl_cue_hint'><?php echo _("(hh:mm:ss.t)") ?></span></dt>
<dd id="spl_cue_out_<?php echo $this->id; ?>" class="spl_cue_out" <dd id="spl_cue_out_<?php echo $this->id; ?>" class="spl_cue_out" data-cue-out="<?php echo $this->cueOut; ?>" data-cue-sec="<?php echo $this->cueOutSec; ?>">
data-cue-out="<?php echo $this->cueOut; ?>"
data-cue-sec="<?php echo $this->cueOutSec; ?>">
<span contenteditable="true" class="spl_text_input"><?php echo $this->cueOut; ?></span> <span contenteditable="true" class="spl_text_input"><?php echo $this->cueOut; ?></span>
</dd> </dd>
<dd class="edit-error"></dd> <dd class="edit-error"></dd>

View File

@ -4,26 +4,18 @@
</dd> </dd>
<?php if ($this->item1Type == 0) { ?> <?php if ($this->item1Type == 0) { ?>
<dt><?php echo _("Fade out: "); ?><span class='spl_cue_hint'><?php echo _("(ss.t)") ?></span></dt> <dt><?php echo _("Fade out: "); ?><span class='spl_cue_hint'><?php echo _("(ss.t)") ?></span></dt>
<dd id="spl_fade_out_<?php echo $this->item1; ?>" class="spl_fade_out" <dd id="spl_fade_out_<?php echo $this->item1; ?>" class="spl_fade_out" data-fadeout="<?php echo $this->item1Url; ?>" data-cuein="<?php echo $this->cueIn1; ?>" data-cueout="<?php echo $this->cueOut1; ?>" data-length="<?php echo $this->fadeOut; ?>" data-type="logarithmic" data-item="<?php echo $this->item1; ?>">
data-fadeout="<?php echo $this->item1Url; ?>"
data-cuein="<?php echo $this->cueIn1; ?>"
data-cueout="<?php echo $this->cueOut1; ?>"
data-length="<?php echo $this->fadeOut; ?>"
data-type="logarithmic"
data-item="<?php echo $this->item1; ?>">
<span contenteditable="true" class="spl_text_input"><?php echo $this->fadeOut; ?></span> <span contenteditable="true" class="spl_text_input"><?php echo $this->fadeOut; ?></span>
</dd> </dd>
<dd class="edit-error"></dd> <dd class="edit-error"></dd>
<?php } <?php }
if (isset($this->item2Url)) { ?> if (isset($this->item2Url)) { ?>
<dt><?php echo _("Fade in: "); ?><span class='spl_cue_hint'><?php echo _("(ss.t)") ?></span></dt> <dt><?php echo _("Fade in: "); ?><span class='spl_cue_hint'><?php echo _("(ss.t)") ?></span></dt>
<dd id="spl_fade_in_<?php echo $this->item2; ?>" class="spl_fade_in" <dd id="spl_fade_in_<?php echo $this->item2; ?>" class="spl_fade_in" data-fadein="<?php echo $this->item2Url; ?>" data-offset="<?php if ($this->item1Type == 0) {
data-fadein="<?php echo $this->item2Url; ?>" echo $this->offset;
data-offset="<?php if ($this->item1Type == 0) { echo $this->offset; } else { echo 0; } ?>" } else {
data-cuein="<?php echo $this->cueIn2; ?>" echo 0;
data-cueout="<?php echo $this->cueOut2; ?>" data-length="<?php echo $this->fadeIn; ?>" } ?>" data-cuein="<?php echo $this->cueIn2; ?>" data-cueout="<?php echo $this->cueOut2; ?>" data-length="<?php echo $this->fadeIn; ?>" data-type="logarithmic" data-item="<?php echo $this->item2; ?>">
data-type="logarithmic"
data-item="<?php echo $this->item2; ?>">
<span contenteditable="true" class="spl_text_input"><?php echo $this->fadeIn; ?></span> <span contenteditable="true" class="spl_text_input"><?php echo $this->fadeIn; ?></span>
</dd> </dd>
<dd class="edit-error"></dd> <dd class="edit-error"></dd>

View File

@ -72,10 +72,12 @@ if (isset($this->obj)) {
<dl id="spl_editor-main" class="inline-list"> <dl id="spl_editor-main" class="inline-list">
<dt><?php echo _("Fade in: "); ?></dt> <dt><?php echo _("Fade in: "); ?></dt>
<dd> <dd>
<input class="spl_main_fade_in playlist_main_fade_input" value="0" /><span class='spl_cue_hint'> seconds</span></dd> <input class="spl_main_fade_in playlist_main_fade_input" value="0" /><span class='spl_cue_hint'> seconds</span>
</dd>
<dd class="edit-error"></dd> <dd class="edit-error"></dd>
<dt><?php echo _("Fade out: "); ?></dt> <dt><?php echo _("Fade out: "); ?></dt>
<dd><input class="spl_main_fade_out playlist_main_fade_input" value="0" /><span class='spl_cue_hint'> seconds</span></dd></dd> <dd><input class="spl_main_fade_out playlist_main_fade_input" value="0" /><span class='spl_cue_hint'> seconds</span></dd>
</dd>
<dd class="edit-error"></dd> <dd class="edit-error"></dd>
</dl> </dl>
</div> </div>
@ -91,7 +93,8 @@ if (isset($this->obj)) {
<div class='btn-group pull-right'> <div class='btn-group pull-right'>
<button class="btn" title='Save smart block&#39s title, description, and criteria' type="button" id="save_button"><?php echo _("Save") ?></button> <button class="btn" title='Save smart block&#39s title, description, and criteria' type="button" id="save_button"><?php echo _("Save") ?></button>
</div> </div>
<div id='sp-success-saved' class='success' style='display:none'><span</div> <div id='sp-success-saved' class='success' style='display:none'>
<span< /div>
</div> </div>
<?php else : ?> <?php else : ?>

View File

@ -12,8 +12,7 @@ if ($isSmartBlock && $this->showPoolCount) { ?>
</span> </span>
<?php if ($this->poolCount > 0) { ?> <?php if ($this->poolCount > 0) { ?>
<span class='checked-icon sp-checked-icon' id='sp_pool_count_icon'></span> <span class='checked-icon sp-checked-icon' id='sp_pool_count_icon'></span>
<?php } <?php } else { ?>
else { ?>
<span class='sp-warning-icon' id='sp_pool_count_icon'></span> <span class='sp-warning-icon' id='sp_pool_count_icon'></span>
<?php } ?> <?php } ?>
</div> </div>
@ -22,7 +21,8 @@ if ($isSmartBlock && $this->showPoolCount) { ?>
if (count($items) && ($isSmartBlock || $isPlaylist)) : ?> if (count($items) && ($isSmartBlock || $isPlaylist)) : ?>
<?php $i = 0; ?> <?php $i = 0; ?>
<?php if ($isSmartBlock && !($this->obj->isStatic())) { <?php if ($isSmartBlock && !($this->obj->isStatic())) {
echo _("</br>This is only a preview of possible content generated by the smart block based upon the above criteria.");} echo _("</br>This is only a preview of possible content generated by the smart block based upon the above criteria.");
}
?> ?>
<?php foreach ($items as $item) : <?php foreach ($items as $item) :
$staticBlock = null; $staticBlock = null;
@ -31,11 +31,9 @@ if ($item['type'] == 2) {
$bl = new Application_Model_Block($item['item_id']); $bl = new Application_Model_Block($item['item_id']);
$staticBlock = $bl->isStatic(); $staticBlock = $bl->isStatic();
$fileUrl = null; $fileUrl = null;
} } else if ($item['type'] == 1) {
else if ($item['type'] == 1) {
$fileUrl = null; $fileUrl = null;
} } else if ($item['type'] == 0) {
else if ($item['type'] == 0) {
$audiofile = Application_Model_StoredFile::RecallById($item['item_id']); $audiofile = Application_Model_StoredFile::RecallById($item['item_id']);
$fileUrl = $audiofile->getFileUrl(); $fileUrl = $audiofile->getFileUrl();
} }
@ -104,7 +102,8 @@ if (($i < count($items) -1) && ($items[$i+1]['type'] == 0)) {
'cueInSec' => $item['cueInSec'], 'cueInSec' => $item['cueInSec'],
'cueOutSec' => $item['cueOutSec'], 'cueOutSec' => $item['cueOutSec'],
'uri' => $fileUrl, 'uri' => $fileUrl,
'origLength' => $item['orig_length'])); ?> 'origLength' => $item['orig_length']
)); ?>
</div> </div>
<?php } ?> <?php } ?>

View File

@ -1 +1 @@
<?php echo $this->form; ?> <?php echo $this->form;

View File

@ -2,7 +2,9 @@
<div> <div>
<h2><?php echo (_("Playout History Templates")); ?></h2> <h2><?php echo (_("Playout History Templates")); ?></h2>
<div><h4><?php echo _("Log Sheet Templates") ?></h4></div> <div>
<h4><?php echo _("Log Sheet Templates") ?></h4>
</div>
<button id="new_item_template" class="btn btn-new"><?php echo _("New Log Sheet Template") ?></button> <button id="new_item_template" class="btn btn-new"><?php echo _("New Log Sheet Template") ?></button>
<ul id="template_list"> <ul id="template_list">
<?php if (count($this->template_list) == 0) : ?> <?php if (count($this->template_list) == 0) : ?>
@ -33,7 +35,9 @@
</div> </div>
<br><br> <br><br>
<div> <div>
<div><h4><?php echo _("File Summary Templates") ?></h4></div> <div>
<h4><?php echo _("File Summary Templates") ?></h4>
</div>
<button id="new_file_template" class="btn btn-new"><?php echo _("New File Summary Template") ?></button> <button id="new_file_template" class="btn btn-new"><?php echo _("New File Summary Template") ?></button>
<ul id="template_file"> <ul id="template_file">
<?php if (count($this->template_file) == 0) : ?> <?php if (count($this->template_file) == 0) : ?>

View File

@ -21,13 +21,7 @@
$usedFileMD[] = $field["name"]; $usedFileMD[] = $field["name"];
} ?> } ?>
<li id="<?php echo "field_".$i?>" <li id="<?php echo "field_" . $i ?>" data-id="<?php echo isset($field["id"]) ? $field["id"] : ""; ?>" data-name="<?php echo $field["name"] ?>" data-label="<?php echo $field["label"] ?>" data-type="<?php echo $field["type"] ?>" data-filemd="<?php echo var_export($field["isFileMd"], true) ?>" class="<?php echo ($field["isFileMd"]) ? 'field_filemd' : 'field_other' ?>">
data-id="<?php echo isset($field["id"]) ? $field["id"] : ""; ?>"
data-name="<?php echo $field["name"]?>"
data-label="<?php echo $field["label"]?>"
data-type="<?php echo $field["type"]?>"
data-filemd="<?php echo var_export($field["isFileMd"], true)?>"
class="<?php echo ($field["isFileMd"]) ? 'field_filemd' : 'field_other' ?>">
<span><?php echo $field["label"] ?></span> <span><?php echo $field["label"] ?></span>
<span><?php echo $field["type"] ?></span> <span><?php echo $field["type"] ?></span>
<?php if (!in_array($field["name"], $this->required_fields)) : ?> <?php if (!in_array($field["name"], $this->required_fields)) : ?>
@ -52,10 +46,7 @@
continue; continue;
} ?> } ?>
<li id="<?php echo "md_".$md["name"]?>" <li id="<?php echo "md_" . $md["name"] ?>" data-name="<?php echo $md["name"] ?>" data-type="<?php echo $md["type"] ?>" data-label="<?php echo $md["label"] ?>">
data-name="<?php echo $md["name"]?>"
data-type="<?php echo $md["type"]?>"
data-label="<?php echo $md["label"]?>">
<?php echo $md["label"] ?> <?php echo $md["label"] ?>
<a class="field_add" href="#"><i class="icon icon-plus"></i></a> <a class="field_add" href="#"><i class="icon icon-plus"></i></a>
</li> </li>

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: asantoni * User: asantoni

View File

@ -1,4 +1,5 @@
<?php <?php
/** /**
* Created by PhpStorm. * Created by PhpStorm.
* User: asantoni * User: asantoni

View File

@ -114,10 +114,14 @@
</div> </div>
<p id="station_podcast_help_text"> <p id="station_podcast_help_text">
<?php echo(sprintf(_("For detailed information on what these metadata fields mean, please see the %sRSS specification%s <?php echo (sprintf(
_("For detailed information on what these metadata fields mean, please see the %sRSS specification%s
or %sApple's podcasting documentation%s."), or %sApple's podcasting documentation%s."),
'<a href="http://cyber.law.harvard.edu/rss/rss.html#requiredChannelElements">', '</a>', '<a href="http://cyber.law.harvard.edu/rss/rss.html#requiredChannelElements">',
'<a target="_blank" href="http://www.apple.com/ca/itunes/podcasts/specs.html">', "</a>")); ?> '</a>',
'<a target="_blank" href="http://www.apple.com/ca/itunes/podcasts/specs.html">',
"</a>"
)); ?>
</p> </p>
</form> </form>

View File

@ -1,3 +1,2 @@
<?php <?php
echo $this->entries; echo $this->entries;
?>

View File

@ -1,3 +1,2 @@
<?php <?php
echo $this->data; echo $this->data;
?>

View File

@ -1,4 +1,3 @@
<table id="schedule_block_table"> <table id="schedule_block_table">
<tr> <tr>
<td> <td>

View File

@ -11,7 +11,11 @@
</tr> </tr>
<?php $i = 0; ?> <?php $i = 0; ?>
<?php foreach ($this->showContent as $row) : ?> <?php foreach ($this->showContent as $row) : ?>
<tr id="au_<?php echo $row["item_id"] ?>" class="<?php if($i&1){echo "even";}else{echo "odd";}?>"> <tr id="au_<?php echo $row["item_id"] ?>" class="<?php if ($i & 1) {
echo "even";
} else {
echo "odd";
} ?>">
<td><?php echo $row["starts"] ?></td> <td><?php echo $row["starts"] ?></td>
<td><?php echo $this->escape($row["track_title"]) ?></td> <td><?php echo $this->escape($row["track_title"]) ?></td>
<td><?php echo $this->escape($row["creator"]) ?></td> <td><?php echo $this->escape($row["creator"]) ?></td>

View File

@ -1,7 +1,9 @@
<div><!-- jQuery UI changes the styling on the outermost div; use a blank div so as not to break the .wrapper styling--> <div>
<!-- jQuery UI changes the styling on the outermost div; use a blank div so as not to break the .wrapper styling-->
<div class="wrapper"> <div class="wrapper">
<div id="media_selector_wrapper"> <div id="media_selector_wrapper">
<?php $subnavPrefix = ""; require_once APPLICATION_PATH . "/views/scripts/partialviews/dashboard-sub-nav.php"; ?> <?php $subnavPrefix = "";
require_once APPLICATION_PATH . "/views/scripts/partialviews/dashboard-sub-nav.php"; ?>
</div> </div>
<?php echo $this->csrf ?> <?php echo $this->csrf ?>

View File

@ -41,7 +41,8 @@
<td class="description"> <td class="description">
<?php echo _("PDO and PostgreSQL libraries") ?> <?php echo _("PDO and PostgreSQL libraries") ?>
</td> </td>
<td class="solution <?php if ($postgres) {echo 'check';?>"> <td class="solution <?php if ($postgres) {
echo 'check'; ?>">
<?php <?php
} else { } else {
?>"> ?>">
@ -58,7 +59,8 @@
<td class="description"> <td class="description">
<?php echo _("Database configuration for LibreTime") ?> <?php echo _("Database configuration for LibreTime") ?>
</td> </td>
<td class="solution <?php if ($database) {echo 'check';?>"> <td class="solution <?php if ($database) {
echo 'check'; ?>">
<?php <?php
} else { } else {
?>"> ?>">
@ -77,7 +79,8 @@
<td class="description"> <td class="description">
<?php echo _("RabbitMQ configuration for LibreTime") ?> <?php echo _("RabbitMQ configuration for LibreTime") ?>
</td> </td>
<td class="solution <?php if ($rabbitmq) {echo 'check';?>"> <td class="solution <?php if ($rabbitmq) {
echo 'check'; ?>">
<?php <?php
} else { } else {
?>"> ?>">
@ -98,7 +101,8 @@
<td class="description"> <td class="description">
<?php echo _("LibreTime media analyzer service") ?> <?php echo _("LibreTime media analyzer service") ?>
</td> </td>
<td class="solution <?php if ($analyzer) {echo 'check';?>"> <td class="solution <?php if ($analyzer) {
echo 'check'; ?>">
<?php <?php
} else { } else {
?>"> ?>">
@ -118,7 +122,8 @@
<td class="description"> <td class="description">
<?php echo _("LibreTime playout service") ?> <?php echo _("LibreTime playout service") ?>
</td> </td>
<td class="solution <?php if ($pypo) {echo 'check';?>"> <td class="solution <?php if ($pypo) {
echo 'check'; ?>">
<?php <?php
} else { } else {
?>"> ?>">
@ -138,7 +143,8 @@
<td class="description"> <td class="description">
<?php echo _("LibreTime liquidsoap service") ?> <?php echo _("LibreTime liquidsoap service") ?>
</td> </td>
<td class="solution <?php if ($liquidsoap) {echo 'check';?>" > <td class="solution <?php if ($liquidsoap) {
echo 'check'; ?>">
<?php <?php
} else { } else {
?>"> ?>">
@ -158,7 +164,8 @@
<td class="description"> <td class="description">
<?php echo _("LibreTime Celery Task service") ?> <?php echo _("LibreTime Celery Task service") ?>
</td> </td>
<td class="solution <?php if ($celery) {echo 'check';?>" > <td class="solution <?php if ($celery) {
echo 'check'; ?>">
<?php <?php
} else { } else {
?>"> ?>">
@ -178,7 +185,8 @@
<td class="description"> <td class="description">
<?php echo _("LibreTime API service") ?> <?php echo _("LibreTime API service") ?>
</td> </td>
<td class="solution <?php if ($api) {echo 'check';?>" > <td class="solution <?php if ($api) {
echo 'check'; ?>">
<?php <?php
} else { } else {
?>"> ?>">

View File

@ -1,4 +1,3 @@
<div class="ui-widget prefpanel clearfix padded-strong tracktype-management"> <div class="ui-widget prefpanel clearfix padded-strong tracktype-management">
<h2><?php echo _("Manage Track Types") ?></h2> <h2><?php echo _("Manage Track Types") ?></h2>

View File

@ -1,3 +1,2 @@
<?php <?php
echo $this->entries; echo $this->entries;
?>

View File

@ -1,3 +1,2 @@
<?php <?php
echo $this->entries; echo $this->entries;
?>

View File

@ -1,3 +1,2 @@
<?php <?php
echo $this->entries; echo $this->entries;
?>

View File

@ -1,3 +1,2 @@
<?php <?php
echo $this->entries; echo $this->entries;
?>

View File

@ -1,6 +1,7 @@
<?php if (isset($this->obj)) : ?> <?php if (isset($this->obj)) : ?>
<input class="obj_id" type="hidden" value="<?php echo $this->obj->getId(); ?>" /> <input class="obj_id" type="hidden" value="<?php echo $this->obj->getId(); ?>" />
<input class="obj_lastMod" type="hidden" value="<?php echo "1";//$this->obj->getLastModified('U'); ?>"/> <input class="obj_lastMod" type="hidden" value="<?php echo "1"; //$this->obj->getLastModified('U');
?>" />
<input class="obj_type" type="hidden" value="webstream" /> <input class="obj_type" type="hidden" value="webstream" />
<div class="status" style="display:none;"></div> <div class="status" style="display:none;"></div>

View File

@ -1,5 +1,5 @@
$(document).ready(function () { $(document).ready(function () {
$.ajaxSetup({ $.ajaxSetup({
cache: false cache: false,
}); });
}); });

View File

@ -8,29 +8,30 @@ var URL_BAR_HEIGHT = 32;
*or a playlist or a show. *or a playlist or a show.
*/ */
$(document).ready(function () { $(document).ready(function () {
$.jPlayer.timeFormat.showHour = true; $.jPlayer.timeFormat.showHour = true;
var audioUri = $('.audioUri').text(); var audioUri = $(".audioUri").text();
var audioMime = $('.audioMime').text(); var audioMime = $(".audioMime").text();
var playlistID = $('.playlistID').text(); var playlistID = $(".playlistID").text();
var playlistIndex = $('.playlistIndex').text(); var playlistIndex = $(".playlistIndex").text();
var showID = $('.showID').text(); var showID = $(".showID").text();
var showIndex = $('.showIndex').text(); var showIndex = $(".showIndex").text();
var blockId = $('.blockId').text(); var blockId = $(".blockId").text();
var blockIndex = $('.blockIndex').text(); var blockIndex = $(".blockIndex").text();
_playlist_jplayer = new jPlayerPlaylist({ _playlist_jplayer = new jPlayerPlaylist(
{
jPlayer: "#jquery_jplayer_1", jPlayer: "#jquery_jplayer_1",
cssSelectorAncestor: "#jp_container_1" cssSelectorAncestor: "#jp_container_1",
},[], //array of songs will be filled with below's json call },
[], //array of songs will be filled with below's json call
{ {
swfPath: baseUrl + "js/jplayer", swfPath: baseUrl + "js/jplayer",
supplied: "oga, mp3, m4v, m4a, wav", supplied: "oga, mp3, m4v, m4a, wav",
size: { size: {
width: "0px", width: "0px",
height: "0px", height: "0px",
cssClass: "jp-video-270p" cssClass: "jp-video-270p",
}, },
playlistOptions: { playlistOptions: {
autoPlay: false, autoPlay: false,
@ -40,7 +41,7 @@ $(document).ready(function(){
displayTime: 0, displayTime: 0,
addTime: 0, addTime: 0,
removeTime: 0, removeTime: 0,
shuffleTime: 0 shuffleTime: 0,
}, },
ready: function () { ready: function () {
if (playlistID != "" && playlistID !== "") { if (playlistID != "" && playlistID !== "") {
@ -52,8 +53,9 @@ $(document).ready(function(){
} else if (blockId != "" && blockIndex != "") { } else if (blockId != "" && blockIndex != "") {
playBlock(blockId, blockIndex); playBlock(blockId, blockIndex);
} }
},
} }
}); );
$("#jp_container_1").on("mouseenter", "ul.jp-controls li", function (ev) { $("#jp_container_1").on("mouseenter", "ul.jp-controls li", function (ev) {
$(this).addClass("ui-state-hover"); $(this).addClass("ui-state-hover");
@ -62,7 +64,6 @@ $(document).ready(function(){
$("#jp_container_1").on("mouseleave", "ul.jp-controls li", function (ev) { $("#jp_container_1").on("mouseleave", "ul.jp-controls li", function (ev) {
$(this).removeClass("ui-state-hover"); $(this).removeClass("ui-state-hover");
}); });
}); });
/** /**
@ -72,23 +73,28 @@ $(document).ready(function(){
* - Select the element played from and start playing. If playlist is null then start at index 0. * - Select the element played from and start playing. If playlist is null then start at index 0.
**/ **/
function playAllPlaylist(p_playlistID, p_playlistIndex) { function playAllPlaylist(p_playlistID, p_playlistIndex) {
var viewsPlaylistID = $('.playlistID').text(); var viewsPlaylistID = $(".playlistID").text();
if (_idToPostionLookUp !== undefined && viewsPlaylistID == p_playlistID) { if (_idToPostionLookUp !== undefined && viewsPlaylistID == p_playlistID) {
play(p_playlistIndex); play(p_playlistIndex);
} else { } else {
buildplaylist(baseUrl+"audiopreview/get-playlist/playlistID/"+p_playlistID, p_playlistIndex); buildplaylist(
baseUrl + "audiopreview/get-playlist/playlistID/" + p_playlistID,
p_playlistIndex
);
} }
} }
function playBlock(p_blockId, p_blockIndex) function playBlock(p_blockId, p_blockIndex) {
{ var viewsBlockId = $(".blockId").text();
var viewsBlockId = $('.blockId').text();
if (_idToPostionLookUp !== undefined && viewsBlockId == p_blockId) { if (_idToPostionLookUp !== undefined && viewsBlockId == p_blockId) {
play(p_blockIndex); play(p_blockIndex);
} else { } else {
buildplaylist(baseUrl+"audiopreview/get-block/blockId/"+p_blockId, p_blockIndex); buildplaylist(
baseUrl + "audiopreview/get-block/blockId/" + p_blockId,
p_blockIndex
);
} }
} }
@ -101,12 +107,14 @@ function playBlock(p_blockId, p_blockIndex)
* and call the controller. * and call the controller.
**/ **/
function playAllShow(p_showID, p_index) { function playAllShow(p_showID, p_index) {
var viewsShowID = $(".showID").text();
var viewsShowID = $('.showID').text();
if (_idToPostionLookUp !== undefined && viewsShowID == p_showID) { if (_idToPostionLookUp !== undefined && viewsShowID == p_showID) {
play(p_index); play(p_index);
} else { } else {
buildplaylist(baseUrl+"audiopreview/get-show/showID/"+p_showID, p_index); buildplaylist(
baseUrl + "audiopreview/get-show/showID/" + p_showID,
p_index
);
} }
} }
@ -119,7 +127,8 @@ function playAllShow(p_showID, p_index) {
*/ */
function buildplaylist(p_url, p_playIndex) { function buildplaylist(p_url, p_playIndex) {
_idToPostionLookUp = Array(); _idToPostionLookUp = Array();
$.getJSON(p_url, function(data){ // get the JSON array produced by my PHP $.getJSON(p_url, function (data) {
// get the JSON array produced by my PHP
var myPlaylist = new Array(); var myPlaylist = new Array();
var media; var media;
var index; var index;
@ -127,26 +136,30 @@ function buildplaylist(p_url, p_playIndex) {
var skipped = 0; var skipped = 0;
for (index in data) { for (index in data) {
if (data[index]['type'] == 0) { if (data[index]["type"] == 0) {
if (data[index]['element_mp3'] != undefined){ if (data[index]["element_mp3"] != undefined) {
media = {title: data[index]['element_title'], media = {
artist: data[index]['element_artist'], title: data[index]["element_title"],
mp3:data[index]['uri'] artist: data[index]["element_artist"],
mp3: data[index]["uri"],
}; };
} else if (data[index]['element_oga'] != undefined) { } else if (data[index]["element_oga"] != undefined) {
media = {title: data[index]['element_title'], media = {
artist: data[index]['element_artist'], title: data[index]["element_title"],
oga:data[index]['uri'] artist: data[index]["element_artist"],
oga: data[index]["uri"],
}; };
} else if (data[index]['element_m4a'] != undefined) { } else if (data[index]["element_m4a"] != undefined) {
media = {title: data[index]['element_title'], media = {
artist: data[index]['element_artist'], title: data[index]["element_title"],
m4a:data[index]['uri'] artist: data[index]["element_artist"],
m4a: data[index]["uri"],
}; };
} else if (data[index]['element_wav'] != undefined) { } else if (data[index]["element_wav"] != undefined) {
media = {title: data[index]['element_title'], media = {
artist: data[index]['element_artist'], title: data[index]["element_title"],
wav:data[index]['uri'] artist: data[index]["element_artist"],
wav: data[index]["uri"],
}; };
} else { } else {
// skip this track since it's not supported // skip this track since it's not supported
@ -154,8 +167,8 @@ function buildplaylist(p_url, p_playIndex) {
skipped++; skipped++;
continue; continue;
} }
} else if (data[index]['type'] == 1) { } else if (data[index]["type"] == 1) {
var mime = data[index]['mime']; var mime = data[index]["mime"];
if (mime.search(/mp3/i) > 0 || mime.search(/mpeg/i) > 0) { if (mime.search(/mp3/i) > 0 || mime.search(/mpeg/i) > 0) {
key = "mp3"; key = "mp3";
} else if (mime.search(/og(g|a)/i) > 0 || mime.search(/vorbis/i) > 0) { } else if (mime.search(/og(g|a)/i) > 0 || mime.search(/vorbis/i) > 0) {
@ -167,13 +180,14 @@ function buildplaylist(p_url, p_playIndex) {
} }
if (key) { if (key) {
media = {title: data[index]['element_title'], media = {
artist: data[index]['element_artist'] title: data[index]["element_title"],
artist: data[index]["element_artist"],
}; };
media[key] = data[index]['uri'] media[key] = data[index]["uri"];
} }
} }
if (media && isAudioSupported(data[index]['mime'])) { if (media && isAudioSupported(data[index]["mime"])) {
// javascript doesn't support associative array with numeric key // javascript doesn't support associative array with numeric key
// so we need to remove the gap if we skip any of tracks due to // so we need to remove the gap if we skip any of tracks due to
// browser incompatibility. // browser incompatibility.
@ -181,7 +195,7 @@ function buildplaylist(p_url, p_playIndex) {
} }
// we should create a map according to the new position in the // we should create a map according to the new position in the
// player itself total is the index on the player // player itself total is the index on the player
_idToPostionLookUp[data[index]['element_id']] = total; _idToPostionLookUp[data[index]["element_id"]] = total;
total++; total++;
} }
_playlist_jplayer.setPlaylist(myPlaylist); _playlist_jplayer.setPlaylist(myPlaylist);
@ -192,7 +206,10 @@ function buildplaylist(p_url, p_playIndex) {
var container = $("#jp_container_1"); var container = $("#jp_container_1");
// Add 2px to account for borders // Add 2px to account for borders
window.resizeTo(container.width() + 2, container.height() + URL_BAR_HEIGHT + 2); window.resizeTo(
container.width() + 2,
container.height() + URL_BAR_HEIGHT + 2
);
}); });
} }
@ -203,7 +220,7 @@ function buildplaylist(p_url, p_playIndex) {
function play(p_playlistIndex) { function play(p_playlistIndex) {
playlistIndex = _idToPostionLookUp[p_playlistIndex]; playlistIndex = _idToPostionLookUp[p_playlistIndex];
if (playlistIndex == undefined) { if (playlistIndex == undefined) {
playlistIndex = 0 playlistIndex = 0;
} }
//_playlist_jplayer.select(playlistIndex); //_playlist_jplayer.select(playlistIndex);
_playlist_jplayer.play(playlistIndex); _playlist_jplayer.play(playlistIndex);
@ -229,8 +246,15 @@ function playOne(uri, mime) {
} }
if (key) { if (key) {
media = {title: $('.audioFileTitle').text() != 'null' ?$('.audioFileTitle').text():"", media = {
artist: $('.audioFileArtist').text() != 'null' ?$('.audioFileArtist').text():"" title:
$(".audioFileTitle").text() != "null"
? $(".audioFileTitle").text()
: "",
artist:
$(".audioFileArtist").text() != "null"
? $(".audioFileArtist").text()
: "",
}; };
media[key] = uri; media[key] = uri;
} }
@ -244,5 +268,8 @@ function playOne(uri, mime) {
var container = $("#jp_container_1"); var container = $("#jp_container_1");
// Add 2px to account for borders // Add 2px to account for borders
window.resizeTo(container.width() + 2, container.height() + URL_BAR_HEIGHT + 2); window.resizeTo(
container.width() + 2,
container.height() + URL_BAR_HEIGHT + 2
);
} }

View File

@ -1,5 +1,7 @@
var AIRTIME = (function (AIRTIME) { var AIRTIME = (function (AIRTIME) {
var mod, DEFAULT_CLASS = 'ui-button ui-state-default', DISABLED_CLASS = 'ui-state-disabled'; var mod,
DEFAULT_CLASS = "ui-button ui-state-default",
DISABLED_CLASS = "ui-state-disabled";
if (AIRTIME.button === undefined) { if (AIRTIME.button === undefined) {
AIRTIME.button = {}; AIRTIME.button = {};
@ -28,7 +30,7 @@ var AIRTIME = (function(AIRTIME) {
if (button.hasClass(DISABLED_CLASS)) { if (button.hasClass(DISABLED_CLASS)) {
button.removeClass(DISABLED_CLASS); button.removeClass(DISABLED_CLASS);
button.removeAttr('disabled'); button.removeAttr("disabled");
} }
}; };
@ -41,10 +43,9 @@ var AIRTIME = (function(AIRTIME) {
if (!button.hasClass(DISABLED_CLASS)) { if (!button.hasClass(DISABLED_CLASS)) {
button.addClass(DISABLED_CLASS); button.addClass(DISABLED_CLASS);
button.attr('disabled', 'disabled'); button.attr("disabled", "disabled");
} }
}; };
return AIRTIME; return AIRTIME;
})(AIRTIME || {});
}(AIRTIME || {}));

View File

@ -1,8 +1,7 @@
function isAudioSupported(mime) { function isAudioSupported(mime) {
var audio = new Audio(); var audio = new Audio();
if ((typeof mime) !== "string" || (mime === null)) { if (typeof mime !== "string" || mime === null) {
return false; return false;
} }
@ -17,8 +16,13 @@ function isAudioSupported(mime){
//file is an mp3 and flash is installed (jPlayer will fall back to flash to play mp3s). //file is an mp3 and flash is installed (jPlayer will fall back to flash to play mp3s).
//Note that checking the navigator.mimeTypes value does not work for IE7, but the alternative //Note that checking the navigator.mimeTypes value does not work for IE7, but the alternative
//is adding a javascript library to do the work for you, which seems like overkill.... //is adding a javascript library to do the work for you, which seems like overkill....
return (!!audio.canPlayType && audio.canPlayType(bMime) != "") || return (
(mime.indexOf("mp3") != -1 && navigator.mimeTypes ["application/x-shockwave-flash"] != undefined) || (!!audio.canPlayType && audio.canPlayType(bMime) != "") ||
(mime.indexOf("mp4") != -1 && navigator.mimeTypes ["application/x-shockwave-flash"] != undefined) || (mime.indexOf("mp3") != -1 &&
(mime.indexOf("mpeg") != -1 && navigator.mimeTypes ["application/x-shockwave-flash"] != undefined); navigator.mimeTypes["application/x-shockwave-flash"] != undefined) ||
(mime.indexOf("mp4") != -1 &&
navigator.mimeTypes["application/x-shockwave-flash"] != undefined) ||
(mime.indexOf("mpeg") != -1 &&
navigator.mimeTypes["application/x-shockwave-flash"] != undefined)
);
} }

View File

@ -2,7 +2,6 @@ var previewWidth = 482,
previewHeight = 110; previewHeight = 110;
$(document).ready(function () { $(document).ready(function () {
/* Removed as this is now (hopefully) unnecessary */ /* Removed as this is now (hopefully) unnecessary */
//$("#Panel").stickyPanel({ //$("#Panel").stickyPanel({
// topPadding: 1, // topPadding: 1,
@ -11,7 +10,9 @@ $(document).ready(function() {
//}); //});
//this statement tells the browser to fade out any success message after 5 seconds //this statement tells the browser to fade out any success message after 5 seconds
setTimeout(function(){$(".success").fadeOut("slow")}, 5000); setTimeout(function () {
$(".success").fadeOut("slow");
}, 5000);
}); });
/* /*
@ -30,7 +31,7 @@ var i18n_months = [
$.i18n._("September"), $.i18n._("September"),
$.i18n._("October"), $.i18n._("October"),
$.i18n._("November"), $.i18n._("November"),
$.i18n._("December") $.i18n._("December"),
]; ];
var i18n_months_short = [ var i18n_months_short = [
@ -45,7 +46,7 @@ var i18n_months_short = [
$.i18n._("Sep"), $.i18n._("Sep"),
$.i18n._("Oct"), $.i18n._("Oct"),
$.i18n._("Nov"), $.i18n._("Nov"),
$.i18n._("Dec") $.i18n._("Dec"),
]; ];
var i18n_days_short = [ var i18n_days_short = [
@ -55,7 +56,7 @@ var i18n_days_short = [
$.i18n._("We"), $.i18n._("We"),
$.i18n._("Th"), $.i18n._("Th"),
$.i18n._("Fr"), $.i18n._("Fr"),
$.i18n._("Sa") $.i18n._("Sa"),
]; ];
var HTTPMethods = Object.freeze({ var HTTPMethods = Object.freeze({
@ -64,7 +65,7 @@ var HTTPMethods = Object.freeze({
PUT: "PUT", PUT: "PUT",
PATCH: "PATCH", PATCH: "PATCH",
DELETE: "DELETE", DELETE: "DELETE",
OPTIONS: "OPTIONS" OPTIONS: "OPTIONS",
}); });
var dateStartId = "#sb_date_start", var dateStartId = "#sb_date_start",
@ -73,25 +74,24 @@ var dateStartId = "#sb_date_start",
timeEndId = "#sb_time_end"; timeEndId = "#sb_time_end";
function getDatatablesStrings(overrideDict) { function getDatatablesStrings(overrideDict) {
var dict = { var dict = {
"sEmptyTable": $.i18n._("No data available in table"), sEmptyTable: $.i18n._("No data available in table"),
"sInfo": $.i18n._("Showing _START_ to _END_ of _TOTAL_ entries"), sInfo: $.i18n._("Showing _START_ to _END_ of _TOTAL_ entries"),
"sInfoEmpty": $.i18n._("Showing 0 to 0 of 0 entries"), sInfoEmpty: $.i18n._("Showing 0 to 0 of 0 entries"),
"sInfoFiltered": "", // $.i18n._("(filtered from _MAX_ total entries)"), sInfoFiltered: "", // $.i18n._("(filtered from _MAX_ total entries)"),
"sInfoPostFix": $.i18n._(""), sInfoPostFix: $.i18n._(""),
"sInfoThousands": $.i18n._(","), sInfoThousands: $.i18n._(","),
"sLengthMenu": $.i18n._("Show _MENU_"), sLengthMenu: $.i18n._("Show _MENU_"),
"sLoadingRecords": $.i18n._("Loading..."), sLoadingRecords: $.i18n._("Loading..."),
//"sProcessing": $.i18n._("Processing..."), //"sProcessing": $.i18n._("Processing..."),
"sProcessing": $.i18n._(""), sProcessing: $.i18n._(""),
"sSearch": $.i18n._(""), sSearch: $.i18n._(""),
"sZeroRecords": $.i18n._("No matching records found"), sZeroRecords: $.i18n._("No matching records found"),
"oPaginate": { oPaginate: {
"sFirst": "&laquo;", sFirst: "&laquo;",
"sLast": "&raquo;", sLast: "&raquo;",
"sNext": "&rsaquo;", sNext: "&rsaquo;",
"sPrevious": "&lsaquo;" sPrevious: "&lsaquo;",
}, },
//"oPaginate": { //"oPaginate": {
// "sFirst": $.i18n._("First"), // "sFirst": $.i18n._("First"),
@ -99,10 +99,10 @@ function getDatatablesStrings(overrideDict) {
// "sNext": $.i18n._("Next"), // "sNext": $.i18n._("Next"),
// "sPrevious": $.i18n._("Previous") // "sPrevious": $.i18n._("Previous")
//}, //},
"oAria": { oAria: {
"sSortAscending": $.i18n._(": activate to sort column ascending"), sSortAscending: $.i18n._(": activate to sort column ascending"),
"sSortDescending": $.i18n._(": activate to sort column descending") sSortDescending: $.i18n._(": activate to sort column descending"),
} },
}; };
return $.extend({}, dict, overrideDict); return $.extend({}, dict, overrideDict);
@ -131,10 +131,10 @@ var _preview_window = null;
function openAudioPreview(p_event) { function openAudioPreview(p_event) {
p_event.stopPropagation(); p_event.stopPropagation();
var audioFileID = $(this).attr('audioFile'); var audioFileID = $(this).attr("audioFile");
var objId = $('.obj_id:first').attr('value'); var objId = $(".obj_id:first").attr("value");
var objType = $('.obj_type:first').attr('value'); var objType = $(".obj_type:first").attr("value");
var playIndex = $(this).parent().parent().attr('id'); var playIndex = $(this).parent().parent().attr("id");
playIndex = playIndex.substring(4); //remove the spl_ playIndex = playIndex.substring(4); //remove the spl_
if (objType == "playlist") { if (objType == "playlist") {
@ -148,7 +148,11 @@ function open_audio_preview(type, id) {
// The reason that we need to encode artist and title string is that // The reason that we need to encode artist and title string is that
// sometime they contain '/' or '\' and apache reject %2f or %5f // sometime they contain '/' or '\' and apache reject %2f or %5f
// so the work around is to encode it twice. // so the work around is to encode it twice.
openPreviewWindow(baseUrl+'audiopreview/audio-preview/audioFileID/'+id+'/type/'+type, previewWidth, previewHeight); openPreviewWindow(
baseUrl + "audiopreview/audio-preview/audioFileID/" + id + "/type/" + type,
previewWidth,
previewHeight
);
_preview_window.focus(); _preview_window.focus();
} }
@ -159,25 +163,42 @@ function open_audio_preview(type, id) {
*given index. *given index.
*/ */
function open_playlist_preview(p_playlistID, p_playlistIndex) { function open_playlist_preview(p_playlistID, p_playlistIndex) {
if (p_playlistIndex == undefined) //Use a resonable default. if (p_playlistIndex == undefined)
//Use a resonable default.
p_playlistIndex = 0; p_playlistIndex = 0;
if (_preview_window != null && !_preview_window.closed) if (_preview_window != null && !_preview_window.closed)
_preview_window.playAllPlaylist(p_playlistID, p_playlistIndex); _preview_window.playAllPlaylist(p_playlistID, p_playlistIndex);
else else
openPreviewWindow(baseUrl+'audiopreview/playlist-preview/playlistIndex/'+p_playlistIndex+'/playlistID/'+p_playlistID, previewWidth, previewHeight); openPreviewWindow(
baseUrl +
"audiopreview/playlist-preview/playlistIndex/" +
p_playlistIndex +
"/playlistID/" +
p_playlistID,
previewWidth,
previewHeight
);
_preview_window.focus(); _preview_window.focus();
} }
function open_block_preview(p_blockId, p_blockIndex) { function open_block_preview(p_blockId, p_blockIndex) {
if (p_blockIndex == undefined) //Use a resonable default. if (p_blockIndex == undefined)
//Use a resonable default.
p_blockIndex = 0; p_blockIndex = 0;
if (_preview_window != null && !_preview_window.closed) if (_preview_window != null && !_preview_window.closed)
_preview_window.playBlock(p_blockId, p_blockIndex); _preview_window.playBlock(p_blockId, p_blockIndex);
else else
openPreviewWindow(baseUrl+'audiopreview/block-preview/blockIndex/'+p_blockIndex+'/blockId/'+p_blockId, previewWidth, previewHeight); openPreviewWindow(
baseUrl +
"audiopreview/block-preview/blockIndex/" +
p_blockIndex +
"/blockId/" +
p_blockId,
previewWidth,
previewHeight
);
_preview_window.focus(); _preview_window.focus();
} }
@ -191,61 +212,80 @@ function open_show_preview(p_showID, p_showIndex) {
if (_preview_window != null && !_preview_window.closed) if (_preview_window != null && !_preview_window.closed)
_preview_window.playAllShow(p_showID, p_showIndex); _preview_window.playAllShow(p_showID, p_showIndex);
else else
openPreviewWindow(baseUrl+'audiopreview/show-preview/showID/'+p_showID+'/showIndex/'+p_showIndex, previewWidth, previewHeight); openPreviewWindow(
baseUrl +
"audiopreview/show-preview/showID/" +
p_showID +
"/showIndex/" +
p_showIndex,
previewWidth,
previewHeight
);
_preview_window.focus(); _preview_window.focus();
} }
function openPreviewWindow(url, w, h) { function openPreviewWindow(url, w, h) {
var dim = (w && h) ? 'width=' + w + ',height=' + h + ',' : ''; var dim = w && h ? "width=" + w + ",height=" + h + "," : "";
// Hardcoding this here is kinda gross, but the alternatives aren't much better... // Hardcoding this here is kinda gross, but the alternatives aren't much better...
_preview_window = window.open(url, $.i18n._('Audio Player'), dim + 'scrollbars=yes'); _preview_window = window.open(
url,
$.i18n._("Audio Player"),
dim + "scrollbars=yes"
);
return false; return false;
} }
function validateTimeRange() { function validateTimeRange() {
var oRange, var oRange,
inputs = $('.sb-timerange > input'), inputs = $(".sb-timerange > input"),
start, end; start,
end;
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId); oRange = AIRTIME.utilities.fnGetScheduleRange(
dateStartId,
timeStartId,
dateEndId,
timeEndId
);
start = oRange.start; start = oRange.start;
end = oRange.end; end = oRange.end;
if (end >= start) { if (end >= start) {
inputs.removeClass('error'); inputs.removeClass("error");
} else { } else {
if (!inputs.hasClass('error')) { if (!inputs.hasClass("error")) {
inputs.addClass('error'); inputs.addClass("error");
} }
} }
return { return {
start: start, start: start,
end: end, end: end,
isValid: end >= start isValid: end >= start,
}; };
} }
// validate uploaded images // validate uploaded images
function validateImage(img, el) { function validateImage(img, el) {
// remove any existing error messages // remove any existing error messages
if ($("#img-err")) { $("#img-err").remove(); } if ($("#img-err")) {
$("#img-err").remove();
}
if (img.size > 2048000) { // 2MB - pull this from somewhere instead? if (img.size > 2048000) {
// 2MB - pull this from somewhere instead?
// hack way of inserting an error message // hack way of inserting an error message
var err = $.i18n._("Selected file is too large"); var err = $.i18n._("Selected file is too large");
el.parent().after( el.parent().after(
"<ul id='img-err' class='errors'>" + "<ul id='img-err' class='errors'>" + "<li>" + err + "</li>" + "</ul>"
"<li>" + err + "</li>" + );
"</ul>");
return false; return false;
} else if (validateMimeType(img.type) < 0) { } else if (validateMimeType(img.type) < 0) {
var err = $.i18n._("File format is not supported"); var err = $.i18n._("File format is not supported");
el.parent().after( el.parent().after(
"<ul id='img-err' class='errors'>" + "<ul id='img-err' class='errors'>" + "<li>" + err + "</li>" + "</ul>"
"<li>" + err + "</li>" + );
"</ul>");
return false; return false;
} }
return true; return true;
@ -254,9 +294,9 @@ function validateImage(img, el) {
// validate image mime type // validate image mime type
function validateMimeType(mime) { function validateMimeType(mime) {
var extensions = [ var extensions = [
'image/jpeg', "image/jpeg",
'image/png', "image/png",
'image/gif' "image/gif",
// BMP? // BMP?
]; ];
return $.inArray(mime, extensions); return $.inArray(mime, extensions);
@ -267,9 +307,11 @@ function pad(number, length) {
} }
function removeSuccessMsg() { function removeSuccessMsg() {
var $status = $('.success'); var $status = $(".success");
$status.fadeOut("slow", function(){$status.empty()}); $status.fadeOut("slow", function () {
$status.empty();
});
} }
function hideHint(h) { function hideHint(h) {
@ -282,8 +324,11 @@ function showHint(h) {
function getUsabilityHint() { function getUsabilityHint() {
var pathname = window.location.pathname; var pathname = window.location.pathname;
$.getJSON(baseUrl + "api/get-usability-hint", {"format": "json", "userPath": pathname}, function(json) { $.getJSON(
var $hint_div = $('.usability_hint'); baseUrl + "api/get-usability-hint",
{ format: "json", userPath: pathname },
function (json) {
var $hint_div = $(".usability_hint");
var current_hint = $hint_div.html(); var current_hint = $hint_div.html();
if (json === "") { if (json === "") {
// there are no more hints to display to the user // there are no more hints to display to the user
@ -301,7 +346,8 @@ function getUsabilityHint() {
showHint($hint_div); showHint($hint_div);
} }
} }
}); }
);
} }
// TODO: build this out so we can use it as a fallback in fail cases // TODO: build this out so we can use it as a fallback in fail cases
@ -314,7 +360,7 @@ function buildErrorDialog(message) {
resizable: false, resizable: false,
modal: true, modal: true,
width: "auto", width: "auto",
height: "auto" height: "auto",
}); });
} }
@ -340,17 +386,26 @@ jQuery.fn.addTitles = function(selector) {
jQuery.fn.scrollText = function (selector) { jQuery.fn.scrollText = function (selector) {
this.each(function () { this.each(function () {
$(this).on("mouseenter", selector, function () { $(this).on("mouseenter", selector, function () {
var sw = $(this)[0].scrollWidth - parseFloat($(this).css("textIndent")), iw = $(this).innerWidth(); var sw = $(this)[0].scrollWidth - parseFloat($(this).css("textIndent")),
iw = $(this).innerWidth();
if (sw > iw) { if (sw > iw) {
$(this).stop().animate({ $(this)
textIndent: "-" + (sw + 1 - iw) + "px" .stop()
}, sw * 8); .animate(
{
textIndent: "-" + (sw + 1 - iw) + "px",
},
sw * 8
);
} }
}); });
$(this).on("mouseleave", selector, function () { $(this).on("mouseleave", selector, function () {
$(this).stop().animate({ $(this).stop().animate(
textIndent: "0" {
}, 500); textIndent: "0",
},
500
);
}); });
}); });

View File

@ -1,21 +1,18 @@
$(document).ready(function () { $(document).ready(function () {
$("#facebook-login").click(function () { $("#facebook-login").click(function () {
AIRTIME.facebook.promptForFacebookPage(); AIRTIME.facebook.promptForFacebookPage();
}); });
}); });
window.fbAsyncInit = function () { window.fbAsyncInit = function () {
FB.init({ FB.init({
appId: FACEBOOK_APP_ID, appId: FACEBOOK_APP_ID,
xfbml: true, xfbml: true,
version : 'v2.4' version: "v2.4",
}); });
}; };
var AIRTIME = (function (AIRTIME) { var AIRTIME = (function (AIRTIME) {
//Module initialization //Module initialization
if (AIRTIME.facebook === undefined) { if (AIRTIME.facebook === undefined) {
AIRTIME.facebook = {}; AIRTIME.facebook = {};
@ -24,7 +21,8 @@ var AIRTIME = (function(AIRTIME) {
var mod = AIRTIME.facebook; var mod = AIRTIME.facebook;
(function (d, s, id) { (function (d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0]; var js,
fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) { if (d.getElementById(id)) {
return; return;
} }
@ -32,47 +30,62 @@ var AIRTIME = (function(AIRTIME) {
js.id = id; js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js"; js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs); fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk')); })(document, "script", "facebook-jssdk");
mod.promptForFacebookPage = function () { mod.promptForFacebookPage = function () {
FB.login(function (response) { FB.login(
function (response) {
if (response.authResponse) { if (response.authResponse) {
mod.getPagesOwnedByUser(response.authResponse.userID, response.authResponse.accessToken); mod.getPagesOwnedByUser(
response.authResponse.userID,
response.authResponse.accessToken
);
mod.addPageTab(); mod.addPageTab();
} else { } else {
console.log('Authorization failed.'); console.log("Authorization failed.");
}
}, {scope: 'manage_pages'});
} }
},
{ scope: "manage_pages" }
);
};
mod.getPagesOwnedByUser = function (userId, accessToken) { mod.getPagesOwnedByUser = function (userId, accessToken) {
FB.api('/' + userId + '/accounts', function (response) { FB.api(
"/" + userId + "/accounts",
function (response) {
console.log(response); console.log(response);
}, {access_token: accessToken}); },
} { access_token: accessToken }
);
};
mod.addPageTab = function () { mod.addPageTab = function () {
FB.ui( FB.ui(
{ method: 'pagetab' }, { method: "pagetab" },
function (resp) { function (resp) {
console.log("response:"); console.log("response:");
console.log(resp); console.log(resp);
var pageIdList = []; var pageIdList = [];
var tabs = resp["tabs_added"]; var tabs = resp["tabs_added"];
if ((tabs != undefined) && (Object.keys(tabs).length > 0)) { if (tabs != undefined && Object.keys(tabs).length > 0) {
for (var pageId in tabs) { for (var pageId in tabs) {
pageIdList.push(pageId); pageIdList.push(pageId);
} }
//POST these back to Airtime, which will then proxy it over to our social app. (multiple requests from Airtime) //POST these back to Airtime, which will then proxy it over to our social app. (multiple requests from Airtime)
$.post('facebook-tab-success', { "pages" : JSON.stringify(pageIdList) }, function() { $.post(
"facebook-tab-success",
{ pages: JSON.stringify(pageIdList) },
function () {
alert("Successfully added to your Facebook page!"); alert("Successfully added to your Facebook page!");
}).done(function() { }
)
}).fail(function() { .done(function () {})
alert("Sorry, an error occurred and we were unable to add the widget to your Facebook page."); .fail(function () {
alert(
"Sorry, an error occurred and we were unable to add the widget to your Facebook page."
);
}); });
} }
}, },
@ -81,8 +94,7 @@ var AIRTIME = (function(AIRTIME) {
//redirect_uri: 'https://localhost' //redirect_uri: 'https://localhost'
} }
); );
} };
return AIRTIME; return AIRTIME;
})(AIRTIME || {});
}(AIRTIME || {}));

View File

@ -22,7 +22,6 @@ var live_dj_on_air = false;
var scheduled_play_on_air = false; var scheduled_play_on_air = false;
var scheduled_play_source = false; var scheduled_play_source = false;
//a reference returned by setTimeout. Useful for when we want clearTimeout() //a reference returned by setTimeout. Useful for when we want clearTimeout()
var newSongTimeoutId = null; var newSongTimeoutId = null;
@ -56,7 +55,7 @@ function secondsTimer(){
function newSongStart() { function newSongStart() {
nextSongPrepare = true; nextSongPrepare = true;
if (nextSong.type == 'track') { if (nextSong.type == "track") {
currentSong = nextSong; currentSong = nextSong;
nextSong = null; nextSong = null;
} }
@ -71,22 +70,30 @@ function nextShowStart(){
function updateProgressBarValue() { function updateProgressBarValue() {
var showPercentDone = 0; var showPercentDone = 0;
if (currentShow.length > 0) { if (currentShow.length > 0) {
showPercentDone = (approximateServerTime - currentShow[0].showStartPosixTime)/currentShow[0].showLengthMs*100; showPercentDone =
((approximateServerTime - currentShow[0].showStartPosixTime) /
currentShow[0].showLengthMs) *
100;
if (showPercentDone < 0 || showPercentDone > 100) { if (showPercentDone < 0 || showPercentDone > 100) {
showPercentDone = 0; showPercentDone = 0;
currentShow = new Array(); currentShow = new Array();
currentSong = null; currentSong = null;
} }
} }
$('#progress-show').attr("style", "width:"+showPercentDone+"%"); $("#progress-show").attr("style", "width:" + showPercentDone + "%");
var songPercentDone = 0; var songPercentDone = 0;
var scheduled_play_div = $("#scheduled_play_div"); var scheduled_play_div = $("#scheduled_play_div");
var scheduled_play_line_to_switch = scheduled_play_div.parent().find(".line-to-switch"); var scheduled_play_line_to_switch = scheduled_play_div
.parent()
.find(".line-to-switch");
if (currentSong !== null) { if (currentSong !== null) {
var songElapsedTime = 0; var songElapsedTime = 0;
songPercentDone = (approximateServerTime - currentSong.songStartPosixTime)/currentSong.songLengthMs*100; songPercentDone =
((approximateServerTime - currentSong.songStartPosixTime) /
currentSong.songLengthMs) *
100;
songElapsedTime = approximateServerTime - currentSong.songStartPosixTime; songElapsedTime = approximateServerTime - currentSong.songStartPosixTime;
if (songPercentDone < 0) { if (songPercentDone < 0) {
songPercentDone = 0; songPercentDone = 0;
@ -94,134 +101,188 @@ function updateProgressBarValue(){
} else if (songPercentDone > 100) { } else if (songPercentDone > 100) {
songPercentDone = 100; songPercentDone = 100;
} else { } else {
if ((currentSong.media_item_played == true && currentShow.length > 0) || (songElapsedTime < 5000 && currentShow[0].record != 1)) { if (
(currentSong.media_item_played == true && currentShow.length > 0) ||
(songElapsedTime < 5000 && currentShow[0].record != 1)
) {
scheduled_play_line_to_switch.attr("class", "line-to-switch on"); scheduled_play_line_to_switch.attr("class", "line-to-switch on");
scheduled_play_div.addClass("ready"); scheduled_play_div.addClass("ready");
scheduled_play_source = true; scheduled_play_source = true;
} } else {
else{
scheduled_play_source = false; scheduled_play_source = false;
scheduled_play_line_to_switch.attr("class", "line-to-switch off"); scheduled_play_line_to_switch.attr("class", "line-to-switch off");
scheduled_play_div.removeClass("ready"); scheduled_play_div.removeClass("ready");
} }
$('#progress-show').attr("class", "progress-show"); $("#progress-show").attr("class", "progress-show");
} }
} else { } else {
scheduled_play_source = false; scheduled_play_source = false;
scheduled_play_line_to_switch.attr("class", "line-to-switch off"); scheduled_play_line_to_switch.attr("class", "line-to-switch off");
scheduled_play_div.removeClass("ready"); scheduled_play_div.removeClass("ready");
$('#progress-show').attr("class", "progress-show-error"); $("#progress-show").attr("class", "progress-show-error");
} }
$('#progress-bar').attr("style", "width:"+songPercentDone+"%"); $("#progress-bar").attr("style", "width:" + songPercentDone + "%");
} }
function updatePlaybar() { function updatePlaybar() {
/* Column 0 update */ /* Column 0 update */
if (previousSong !== null) { if (previousSong !== null) {
$('#previous').text(previousSong.name+","); $("#previous").text(previousSong.name + ",");
$('#prev-length').text(convertToHHMMSSmm(previousSong.songLengthMs)); $("#prev-length").text(convertToHHMMSSmm(previousSong.songLengthMs));
} else { } else {
$('#previous').empty(); $("#previous").empty();
$('#prev-length').empty(); $("#prev-length").empty();
} }
if (currentSong !== null && !master_dj_on_air && !live_dj_on_air) { if (currentSong !== null && !master_dj_on_air && !live_dj_on_air) {
if (currentSong.record == "1") { if (currentSong.record == "1") {
$('#current').html("<span style='color:red; font-weight:bold'>"+$.i18n._("Recording:")+"</span>"+currentSong.name+","); $("#current").html(
"<span style='color:red; font-weight:bold'>" +
$.i18n._("Recording:") +
"</span>" +
currentSong.name +
","
);
} else { } else {
$('#current').text(currentSong.name+","); $("#current").text(currentSong.name + ",");
if (currentSong.metadata && currentSong.metadata.artwork_data) { if (currentSong.metadata && currentSong.metadata.artwork_data) {
var check_current_song = Cookies.get("current_track");
var check_current_song = Cookies.get('current_track'); var loaded = Cookies.get("loaded");
var loaded = Cookies.get('loaded');
if (check_current_song != currentSong.name) { if (check_current_song != currentSong.name) {
$('#now-playing-artwork_containter').html("<img height='75' width='75' class'artwork' src='"+ currentSong.metadata.artwork_data +"' />"); $("#now-playing-artwork_containter").html(
Cookies.remove('current_track'); "<img height='75' width='75' class'artwork' src='" +
Cookies.set('current_track', currentSong.name); currentSong.metadata.artwork_data +
"' />"
);
Cookies.remove("current_track");
Cookies.set("current_track", currentSong.name);
} }
// makes sure it stays updated with current track if page loads // makes sure it stays updated with current track if page loads
if (loaded != UNIQID) { if (loaded != UNIQID) {
Cookies.remove('current_track'); Cookies.remove("current_track");
Cookies.remove('loaded'); Cookies.remove("loaded");
Cookies.set('loaded', UNIQID); Cookies.set("loaded", UNIQID);
} }
} }
} }
} else { } else {
if (master_dj_on_air) { if (master_dj_on_air) {
if (showName) { if (showName) {
$('#current').html($.i18n._("Current")+": <span style='color:red; font-weight:bold'>"+showName+" - "+$.i18n._("Master Stream")+"</span>"); $("#current").html(
$.i18n._("Current") +
": <span style='color:red; font-weight:bold'>" +
showName +
" - " +
$.i18n._("Master Stream") +
"</span>"
);
} else { } else {
$('#current').html($.i18n._("Current")+": <span style='color:red; font-weight:bold'>"+$.i18n._("Master Stream")+"</span>"); $("#current").html(
$.i18n._("Current") +
": <span style='color:red; font-weight:bold'>" +
$.i18n._("Master Stream") +
"</span>"
);
} }
} else if (live_dj_on_air) { } else if (live_dj_on_air) {
if (showName) { if (showName) {
$('#current').html($.i18n._("Current")+": <span style='color:red; font-weight:bold'>"+showName+" - "+$.i18n._("Live Stream")+"</span>"); $("#current").html(
$.i18n._("Current") +
": <span style='color:red; font-weight:bold'>" +
showName +
" - " +
$.i18n._("Live Stream") +
"</span>"
);
} else { } else {
$('#current').html($.i18n._("Current")+": <span style='color:red; font-weight:bold'>"+$.i18n._("Live Stream")+"</span>"); $("#current").html(
$.i18n._("Current") +
": <span style='color:red; font-weight:bold'>" +
$.i18n._("Live Stream") +
"</span>"
);
} }
} else { } else {
$('#current').html($.i18n._("Current")+": <span style='color:red; font-weight:bold'>"+$.i18n._("Nothing Scheduled")+"</span>"); $("#current").html(
$.i18n._("Current") +
": <span style='color:red; font-weight:bold'>" +
$.i18n._("Nothing Scheduled") +
"</span>"
);
} }
} }
if (nextSong !== null) { if (nextSong !== null) {
$('#next').text(nextSong.name+","); $("#next").text(nextSong.name + ",");
$('#next-length').text(convertToHHMMSSmm(nextSong.songLengthMs)); $("#next-length").text(convertToHHMMSSmm(nextSong.songLengthMs));
} else { } else {
$('#next').empty(); $("#next").empty();
$('#next-length').empty(); $("#next-length").empty();
} }
$('#start').empty(); $("#start").empty();
$('#end').empty(); $("#end").empty();
$('#time-elapsed').empty(); $("#time-elapsed").empty();
$('#time-remaining').empty(); $("#time-remaining").empty();
$('#song-length').empty(); $("#song-length").empty();
if (currentSong !== null && !master_dj_on_air && !live_dj_on_air) { if (currentSong !== null && !master_dj_on_air && !live_dj_on_air) {
$('#start').text(currentSong.starts.split(' ')[1]); $("#start").text(currentSong.starts.split(" ")[1]);
$('#end').text(currentSong.ends.split(' ')[1]); $("#end").text(currentSong.ends.split(" ")[1]);
/* Get rid of the millisecond accuracy so that the second counters for both /* Get rid of the millisecond accuracy so that the second counters for both
* show and song change at the same time. */ * show and song change at the same time. */
var songStartRoughly = parseInt(Math.round(currentSong.songStartPosixTime/1000), 10)*1000; var songStartRoughly =
var songEndRoughly = parseInt(Math.round(currentSong.songEndPosixTime/1000), 10)*1000; parseInt(Math.round(currentSong.songStartPosixTime / 1000), 10) * 1000;
var songEndRoughly =
parseInt(Math.round(currentSong.songEndPosixTime / 1000), 10) * 1000;
$('#time-elapsed').text(convertToHHMMSS(approximateServerTime - songStartRoughly)); $("#time-elapsed").text(
$('#time-remaining').text(convertToHHMMSS(songEndRoughly - approximateServerTime)); convertToHHMMSS(approximateServerTime - songStartRoughly)
$('#song-length').text(convertToHHMMSS(currentSong.songLengthMs)); );
$("#time-remaining").text(
convertToHHMMSS(songEndRoughly - approximateServerTime)
);
$("#song-length").text(convertToHHMMSS(currentSong.songLengthMs));
} }
/* Column 1 update */ /* Column 1 update */
$('#playlist').text($.i18n._("Current Show:")); $("#playlist").text($.i18n._("Current Show:"));
var recElem = $('.recording-show'); var recElem = $(".recording-show");
if (currentShow.length > 0) { if (currentShow.length > 0) {
$('#playlist').text(currentShow[0].name); $("#playlist").text(currentShow[0].name);
(currentShow[0].record == "1") ? recElem.show(): recElem.hide(); currentShow[0].record == "1" ? recElem.show() : recElem.hide();
} else { } else {
recElem.hide(); recElem.hide();
} }
$('#show-length').empty(); $("#show-length").empty();
if (currentShow.length > 0) { if (currentShow.length > 0) {
$('#show-length').text(convertDateToHHMM(currentShow[0].showStartPosixTime) + " - " + convertDateToHHMM(currentShow[0].showEndPosixTime)); $("#show-length").text(
convertDateToHHMM(currentShow[0].showStartPosixTime) +
" - " +
convertDateToHHMM(currentShow[0].showEndPosixTime)
);
} }
/* Column 2 update */ /* Column 2 update */
$('#time').text(convertDateToHHMMSS(approximateServerTime)); $("#time").text(convertDateToHHMMSS(approximateServerTime));
} }
function calcAdditionalData(currentItem) { function calcAdditionalData(currentItem) {
currentItem.songStartPosixTime = convertDateToPosixTime(currentItem.starts); currentItem.songStartPosixTime = convertDateToPosixTime(currentItem.starts);
currentItem.songEndPosixTime = convertDateToPosixTime(currentItem.ends); currentItem.songEndPosixTime = convertDateToPosixTime(currentItem.ends);
currentItem.songLengthMs = currentItem.songEndPosixTime - currentItem.songStartPosixTime; currentItem.songLengthMs =
currentItem.songEndPosixTime - currentItem.songStartPosixTime;
} }
function calcAdditionalShowData(show) { function calcAdditionalShowData(show) {
if (show.length > 0) { if (show.length > 0) {
show[0].showStartPosixTime = convertDateToPosixTime(show[0].start_timestamp); show[0].showStartPosixTime = convertDateToPosixTime(
show[0].start_timestamp
);
show[0].showEndPosixTime = convertDateToPosixTime(show[0].end_timestamp); show[0].showEndPosixTime = convertDateToPosixTime(show[0].end_timestamp);
show[0].showLengthMs = show[0].showEndPosixTime - show[0].showStartPosixTime; show[0].showLengthMs =
show[0].showEndPosixTime - show[0].showStartPosixTime;
} }
} }
@ -288,7 +349,6 @@ function parseItems(obj){
calculateTimeToNextShow(); calculateTimeToNextShow();
} }
var schedulePosixTime = convertDateToPosixTime(obj.schedulerTime); var schedulePosixTime = convertDateToPosixTime(obj.schedulerTime);
var date = new Date(); var date = new Date();
localRemoteTimeOffset = date.getTime() - schedulePosixTime; localRemoteTimeOffset = date.getTime() - schedulePosixTime;
@ -318,7 +378,6 @@ function parseSourceStatus(obj){
} }
function parseSwitchStatus(obj) { function parseSwitchStatus(obj) {
if (obj.live_dj_source == "on") { if (obj.live_dj_source == "on") {
live_dj_on_air = true; live_dj_on_air = true;
} else { } else {
@ -355,7 +414,7 @@ function parseSwitchStatus(obj){
live_dj_switch.removeClass("active"); live_dj_switch.removeClass("active");
} }
master_dj_switch.find("span").html(obj.master_dj_source) master_dj_switch.find("span").html(obj.master_dj_source);
if (master_dj_on_air) { if (master_dj_on_air) {
master_dj_switch.addClass("active"); master_dj_switch.addClass("active");
} else { } else {
@ -364,8 +423,12 @@ function parseSwitchStatus(obj){
} }
function controlOnAirLight() { function controlOnAirLight() {
if ((scheduled_play_on_air && scheduled_play_source) || live_dj_on_air || master_dj_on_air) { if (
$('#on-air-info').attr("class", "on-air-info on"); (scheduled_play_on_air && scheduled_play_source) ||
live_dj_on_air ||
master_dj_on_air
) {
$("#on-air-info").attr("class", "on-air-info on");
onAirOffIterations = 0; onAirOffIterations = 0;
} else if (onAirOffIterations < 20) { } else if (onAirOffIterations < 20) {
//if less than 4 seconds have gone by (< 20 executions of this function) //if less than 4 seconds have gone by (< 20 executions of this function)
@ -374,7 +437,7 @@ function controlOnAirLight(){
//off between tracks: CC-3725 //off between tracks: CC-3725
onAirOffIterations++; onAirOffIterations++;
} else { } else {
$('#on-air-info').attr("class", "on-air-info off"); $("#on-air-info").attr("class", "on-air-info off");
} }
} }
@ -383,66 +446,88 @@ function controlSwitchLight(){
var master_li = $("#master_dj_div").parent(); var master_li = $("#master_dj_div").parent();
var scheduled_play_li = $("#scheduled_play_div").parent(); var scheduled_play_li = $("#scheduled_play_div").parent();
if((scheduled_play_on_air && scheduled_play_source) && !live_dj_on_air && !master_dj_on_air){ if (
scheduled_play_li.find(".line-to-on-air").attr("class", "line-to-on-air on"); scheduled_play_on_air &&
scheduled_play_source &&
!live_dj_on_air &&
!master_dj_on_air
) {
scheduled_play_li
.find(".line-to-on-air")
.attr("class", "line-to-on-air on");
live_li.find(".line-to-on-air").attr("class", "line-to-on-air off"); live_li.find(".line-to-on-air").attr("class", "line-to-on-air off");
master_li.find(".line-to-on-air").attr("class", "line-to-on-air off"); master_li.find(".line-to-on-air").attr("class", "line-to-on-air off");
} else if (live_dj_on_air && !master_dj_on_air) { } else if (live_dj_on_air && !master_dj_on_air) {
scheduled_play_li.find(".line-to-on-air").attr("class", "line-to-on-air off"); scheduled_play_li
.find(".line-to-on-air")
.attr("class", "line-to-on-air off");
live_li.find(".line-to-on-air").attr("class", "line-to-on-air on"); live_li.find(".line-to-on-air").attr("class", "line-to-on-air on");
master_li.find(".line-to-on-air").attr("class", "line-to-on-air off"); master_li.find(".line-to-on-air").attr("class", "line-to-on-air off");
} else if (master_dj_on_air) { } else if (master_dj_on_air) {
scheduled_play_li.find(".line-to-on-air").attr("class", "line-to-on-air off"); scheduled_play_li
.find(".line-to-on-air")
.attr("class", "line-to-on-air off");
live_li.find(".line-to-on-air").attr("class", "line-to-on-air off"); live_li.find(".line-to-on-air").attr("class", "line-to-on-air off");
master_li.find(".line-to-on-air").attr("class", "line-to-on-air on"); master_li.find(".line-to-on-air").attr("class", "line-to-on-air on");
} else { } else {
scheduled_play_li.find(".line-to-on-air").attr("class", "line-to-on-air off"); scheduled_play_li
.find(".line-to-on-air")
.attr("class", "line-to-on-air off");
live_li.find(".line-to-on-air").attr("class", "line-to-on-air off"); live_li.find(".line-to-on-air").attr("class", "line-to-on-air off");
master_li.find(".line-to-on-air").attr("class", "line-to-on-air off"); master_li.find(".line-to-on-air").attr("class", "line-to-on-air off");
} }
} }
function getScheduleFromServer() { function getScheduleFromServer() {
$.ajax({ url: baseUrl+"Schedule/get-current-playlist/format/json", $.ajax({
url: baseUrl + "Schedule/get-current-playlist/format/json",
dataType: "json", dataType: "json",
success: function (data) { success: function (data) {
parseItems(data.entries); parseItems(data.entries);
parseSourceStatus(data.source_status); parseSourceStatus(data.source_status);
parseSwitchStatus(data.switch_status); parseSwitchStatus(data.switch_status);
showName = data.show_name; showName = data.show_name;
}, error:function(jqXHR, textStatus, errorThrown){}}); },
error: function (jqXHR, textStatus, errorThrown) {},
});
} }
function setupQtip() { function setupQtip() {
var qtipElem = $('#about-link'); var qtipElem = $("#about-link");
if (qtipElem.length > 0) { if (qtipElem.length > 0) {
qtipElem.qtip({ qtipElem.qtip({
content: $('#about-txt').html(), content: $("#about-txt").html(),
show: 'mouseover', show: "mouseover",
hide: { when: 'mouseout', fixed: true }, hide: { when: "mouseout", fixed: true },
position: { position: {
corner: { corner: {
target: 'center', target: "center",
tooltip: 'topRight' tooltip: "topRight",
} },
}, },
style: { style: {
border: { border: {
width: 0, width: 0,
radius: 4 radius: 4,
},
name: "light", // Use the default light style
}, },
name: 'light' // Use the default light style
}
}); });
} }
} }
function setSwitchListener(ele) { function setSwitchListener(ele) {
var sourcename = $(ele).attr('id'); var sourcename = $(ele).attr("id");
var status_span = $(ele).find("span"); var status_span = $(ele).find("span");
var status = status_span.html(); var status = status_span.html();
$.get(baseUrl+"Dashboard/switch-source/format/json/sourcename/"+sourcename+"/status/"+status, function(data){ $.get(
baseUrl +
"Dashboard/switch-source/format/json/sourcename/" +
sourcename +
"/status/" +
status,
function (data) {
if (data.error) { if (data.error) {
alert(data.error); alert(data.error);
} else { } else {
@ -453,17 +538,23 @@ function setSwitchListener(ele){
} }
status_span.html(data.status); status_span.html(data.status);
} }
}); }
);
} }
function kickSource(ele) { function kickSource(ele) {
var sourcename = $(ele).attr('id'); var sourcename = $(ele).attr("id");
$.get(baseUrl+"Dashboard/disconnect-source/format/json/sourcename/"+sourcename, function(data){ $.get(
baseUrl +
"Dashboard/disconnect-source/format/json/sourcename/" +
sourcename,
function (data) {
if (data.error) { if (data.error) {
alert(data.error); alert(data.error);
} }
}); }
);
} }
var stream_window = null; var stream_window = null;
@ -477,9 +568,13 @@ function init() {
setupQtip(); setupQtip();
$('.listen-control-button').click(function() { $(".listen-control-button").click(function () {
if (stream_window == null || stream_window.closed) if (stream_window == null || stream_window.closed)
stream_window=window.open(baseUrl+"Dashboard/stream-player", 'name', 'width=400,height=158'); stream_window = window.open(
baseUrl + "Dashboard/stream-player",
"name",
"width=400,height=158"
);
stream_window.focus(); stream_window.focus();
return false; return false;
}); });
@ -491,8 +586,8 @@ function init() {
* field. Therefore, we fill the password field with 6 x's * field. Therefore, we fill the password field with 6 x's
*/ */
function setCurrentUserPseudoPassword() { function setCurrentUserPseudoPassword() {
$('#cu_password').val("xxxxxx"); $("#cu_password").val("xxxxxx");
$('#cu_passwordVerify').val("xxxxxx"); $("#cu_passwordVerify").val("xxxxxx");
} }
/*$(window).resize(function() { /*$(window).resize(function() {
@ -503,26 +598,25 @@ function setCurrentUserPseudoPassword() {
});*/ });*/
$(document).ready(function () { $(document).ready(function () {
if ($('#master-panel').length > 0) if ($("#master-panel").length > 0) init();
init(); if ($(".errors").length === 0) {
if ($('.errors').length === 0) {
setCurrentUserPseudoPassword(); setCurrentUserPseudoPassword();
} }
$('body').on('click','#current-user', function() { $("body").on("click", "#current-user", function () {
$.ajax({ $.ajax({
url: baseUrl+'user/edit-user/format/json' url: baseUrl + "user/edit-user/format/json",
}); });
}); });
$('body').on('click', '#cu_save_user', function() { $("body").on("click", "#cu_save_user", function () {
Cookies.set('airtime_locale', $('#cu_locale').val(), {path: '/'}); Cookies.set("airtime_locale", $("#cu_locale").val(), { path: "/" });
}); });
// When the 'Listen' button is clicked we set the width // When the 'Listen' button is clicked we set the width
// of the share button to the width of the 'Live Stream' // of the share button to the width of the 'Live Stream'
// text. This differs depending on the language setting // text. This differs depending on the language setting
$('#popup-link').css('width', $('.jp-container h1').css('width')); $("#popup-link").css("width", $(".jp-container h1").css("width"));
/*$('#menu-btn').click(function() { /*$('#menu-btn').click(function() {
$('#nav .responsive-menu').slideToggle(); $('#nav .responsive-menu').slideToggle();

View File

@ -1,13 +1,10 @@
/* function to create popup window */ /* function to create popup window */
function popup(mylink) { function popup(mylink) {
if (!window.focus) if (!window.focus) return true;
return true;
var href; var href;
if (typeof(mylink) == 'string') if (typeof mylink == "string") href = mylink;
href=mylink; else href = mylink.href;
else window.open(href, "player", "width=300,height=100,scrollbars=yes");
href=mylink.href;
window.open(href, "player", 'width=300,height=100,scrollbars=yes');
return false; return false;
} }
@ -29,12 +26,10 @@ function getDateFromString(time){
} }
return new Date(year, month, day); return new Date(year, month, day);
} }
function convertSecondsToDaysHoursMinutesSeconds(seconds) { function convertSecondsToDaysHoursMinutesSeconds(seconds) {
if (seconds < 0) if (seconds < 0) seconds = 0;
seconds = 0;
seconds = parseInt(seconds, 10); seconds = parseInt(seconds, 10);
@ -67,12 +62,9 @@ function convertToHHMMSS(timeInMS){
minutes = minutes.toString(); minutes = minutes.toString();
seconds = seconds.toString(); seconds = seconds.toString();
if (hours.length == 1) if (hours.length == 1) hours = "0" + hours;
hours = "0" + hours; if (minutes.length == 1) minutes = "0" + minutes;
if (minutes.length == 1) if (seconds.length == 1) seconds = "0" + seconds;
minutes = "0" + minutes;
if (seconds.length == 1)
seconds = "0" + seconds;
return hours + ":" + minutes + ":" + seconds; return hours + ":" + minutes + ":" + seconds;
} }
@ -95,24 +87,16 @@ function convertToHHMMSSmm(timeInMS){
seconds = seconds.toString(); seconds = seconds.toString();
ms = ms.toString(); ms = ms.toString();
if (hours.length == 1) if (hours.length == 1) hours = "0" + hours;
hours = "0" + hours; if (minutes.length == 1) minutes = "0" + minutes;
if (minutes.length == 1) if (seconds.length == 1) seconds = "0" + seconds;
minutes = "0" + minutes;
if (seconds.length == 1)
seconds = "0" + seconds;
if (ms.length == 3) if (ms.length == 3) ms = ms.substring(0, 2);
ms = ms.substring(0, 2); else if (ms.length == 2) ms = "0" + ms.substring(0, 1);
else if (ms.length == 2) else if (ms.length == 1) ms = "00";
ms = "0" + ms.substring(0,1);
else if (ms.length == 1)
ms = "00";
if (hours == "00") if (hours == "00") return minutes + ":" + seconds + "." + ms;
return minutes + ":" + seconds + "." + ms; else return hours + ":" + minutes + ":" + seconds + "." + ms;
else
return hours + ":" + minutes + ":" + seconds+ "." + ms;
} }
function convertDateToHHMM(epochTime) { function convertDateToHHMM(epochTime) {
@ -121,10 +105,8 @@ function convertDateToHHMM(epochTime){
var hours = d.getUTCHours().toString(); var hours = d.getUTCHours().toString();
var minutes = d.getUTCMinutes().toString(); var minutes = d.getUTCMinutes().toString();
if (hours.length == 1) if (hours.length == 1) hours = "0" + hours;
hours = "0" + hours; if (minutes.length == 1) minutes = "0" + minutes;
if (minutes.length == 1)
minutes = "0" + minutes;
return hours + ":" + minutes; return hours + ":" + minutes;
} }
@ -136,19 +118,15 @@ function convertDateToHHMMSS(epochTime){
var minutes = d.getUTCMinutes().toString(); var minutes = d.getUTCMinutes().toString();
var seconds = d.getUTCSeconds().toString(); var seconds = d.getUTCSeconds().toString();
if (hours.length == 1) if (hours.length == 1) hours = "0" + hours;
hours = "0" + hours; if (minutes.length == 1) minutes = "0" + minutes;
if (minutes.length == 1) if (seconds.length == 1) seconds = "0" + seconds;
minutes = "0" + minutes;
if (seconds.length == 1)
seconds = "0" + seconds;
return hours + ":" + minutes + ":" + seconds; return hours + ":" + minutes + ":" + seconds;
} }
/* Takes in a string of format similar to 2011-02-07 02:59:57, /* Takes in a string of format similar to 2011-02-07 02:59:57,
* and converts this to epoch/posix time. */ * and converts this to epoch/posix time. */
function convertDateToPosixTime(s) { function convertDateToPosixTime(s) {
var datetime = s.split(" "); var datetime = s.split(" ");
var date = datetime[0].split("-"); var date = datetime[0].split("-");
@ -166,14 +144,13 @@ function convertDateToPosixTime(s){
var temp = time[2].split("."); var temp = time[2].split(".");
sec = temp[0]; sec = temp[0];
msec = temp[1]; msec = temp[1];
} else } else sec = time[2];
sec = time[2];
return Date.UTC(year, month - 1, day, hour, minute, sec, msec); return Date.UTC(year, month - 1, day, hour, minute, sec, msec);
} }
function getFileExt(filename) { function getFileExt(filename) {
return filename.split('.').pop(); return filename.split(".").pop();
} }
function resizeImg(ele, targetWidth, targetHeight) { function resizeImg(ele, targetWidth, targetHeight) {
@ -226,7 +203,11 @@ function isInView(el) {
return ( return (
rect.top >= 0 && rect.top >= 0 &&
rect.left >= 0 && rect.left >= 0 &&
rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && /*or $(window).height() */ rect.bottom <=
rect.right <= (window.innerWidth || document.documentElement.clientWidth) /*or $(window).width() */ (window.innerHeight ||
document.documentElement.clientHeight) /*or $(window).height() */ &&
rect.right <=
(window.innerWidth ||
document.documentElement.clientWidth) /*or $(window).width() */
); );
} }

View File

@ -14,23 +14,41 @@ function getContent() {
if (isUpToDate()) { if (isUpToDate()) {
msg = $.i18n._("You are running the latest version"); msg = $.i18n._("You are running the latest version");
} else { } else {
msg = $.i18n._("New version available: ") + link + '<ul>'; msg = $.i18n._("New version available: ") + link + "<ul>";
if (isPreRelease) { if (isPreRelease) {
msg += '<li>'+$.i18n._("You have a pre-release version of LibreTime intalled."); msg +=
"<li>" +
$.i18n._("You have a pre-release version of LibreTime intalled.");
} }
if (hasPatch) { if (hasPatch) {
msg += '<li>'+$.i18n._("A patch update for your LibreTime installation is available."); msg +=
"<li>" +
$.i18n._(
"A patch update for your LibreTime installation is available."
);
} }
if (hasMinor) { if (hasMinor) {
msg += '<li>'+$.i18n._("A feature update for your LibreTime installation is available."); msg +=
"<li>" +
$.i18n._(
"A feature update for your LibreTime installation is available."
);
} }
if (hasMajor && !hasMultiMajor) { if (hasMajor && !hasMultiMajor) {
msg += '<li>'+$.i18n._("A major update for your LibreTime installation is available."); msg +=
"<li>" +
$.i18n._(
"A major update for your LibreTime installation is available."
);
} }
if (hasMultiMajor) { if (hasMultiMajor) {
msg += '<li>'+$.i18n._("Multiple major updates for LibreTime installation are available. Please upgrade as soon as possible."); msg +=
"<li>" +
$.i18n._(
"Multiple major updates for LibreTime installation are available. Please upgrade as soon as possible."
);
} }
msg += '</ul>'; msg += "</ul>";
} }
return msg; return msg;
@ -41,7 +59,6 @@ function getContent() {
*/ */
function getHasPatch() { function getHasPatch() {
return versionNotifyInfo.hasPatch; return versionNotifyInfo.hasPatch;
} }
/** /**
@ -72,9 +89,6 @@ function getIsPreRelease() {
return versionNotifyInfo.isPreRelease; return versionNotifyInfo.isPreRelease;
} }
/** /**
* Get the current version * Get the current version
*/ */
@ -93,7 +107,9 @@ function getLatestVersion() {
* Returns the download link to latest release in HTML * Returns the download link to latest release in HTML
*/ */
function getLatestLink() { function getLatestLink() {
return "<a href='' onclick='openLatestLink();'>" + getLatestVersion() + "</a>"; return (
"<a href='' onclick='openLatestLink();'>" + getLatestVersion() + "</a>"
);
} }
/** /**
@ -114,37 +130,37 @@ function openLatestLink() {
* Sets up the tooltip for version notification * Sets up the tooltip for version notification
*/ */
function setupVersionQtip() { function setupVersionQtip() {
var qtipElem = $('#version-icon'); var qtipElem = $("#version-icon");
if (qtipElem.length > 0) { if (qtipElem.length > 0) {
qtipElem.qtip({ qtipElem.qtip({
id: 'version', id: "version",
content: { content: {
text: getContent(), text: getContent(),
title: { title: {
text: getCurrentVersion(), text: getCurrentVersion(),
button: isUpToDate() ? false : true button: isUpToDate() ? false : true,
} },
}, },
hide: { hide: {
event: isUpToDate() ? 'mouseleave' : 'unfocus' event: isUpToDate() ? "mouseleave" : "unfocus",
}, },
position: { position: {
my: "top right", my: "top right",
at: "bottom left" at: "bottom left",
}, },
style: { style: {
border: { border: {
width: 0, width: 0,
radius: 4 radius: 4,
},
classes: "ui-tooltip-dark ui-tooltip-rounded",
}, },
classes: "ui-tooltip-dark ui-tooltip-rounded"
}
}); });
} }
} }
$(document).ready(function () { $(document).ready(function () {
if($('#version-icon').length > 0) { if ($("#version-icon").length > 0) {
setupVersionQtip(); setupVersionQtip();
} }
}); });

View File

@ -8,11 +8,10 @@ var AIRTIME = (function(AIRTIME) {
mod = AIRTIME.library; mod = AIRTIME.library;
mod.checkAddButton = function () { mod.checkAddButton = function () {
var selected = mod.getChosenItemsLength(), var selected = mod.getChosenItemsLength(),
sortable = $('.spl_sortable:visible'), sortable = $(".spl_sortable:visible"),
check = false, check = false,
blockType = $('input[name=sp_type]:checked', '#smart-block-form').val(); blockType = $("input[name=sp_type]:checked", "#smart-block-form").val();
// make sure audioclips are selected and a playlist or static block is currently open. // make sure audioclips are selected and a playlist or static block is currently open.
// static blocks have value of 0 // static blocks have value of 0
@ -27,23 +26,26 @@ var AIRTIME = (function(AIRTIME) {
AIRTIME.button.disableButton("btn-group #library-plus", false); AIRTIME.button.disableButton("btn-group #library-plus", false);
} }
var objType = $('.obj_type').val(), var objType = $(".obj_type").val(),
btnText; btnText;
if (objType === 'playlist') { if (objType === "playlist") {
btnText = ' '+$.i18n._('Add to current playlist'); btnText = " " + $.i18n._("Add to current playlist");
} else if (objType === 'block') { } else if (objType === "block") {
btnText = ' '+$.i18n._('Add to current smart block'); btnText = " " + $.i18n._("Add to current smart block");
} else { } else {
btnText = ' '+$.i18n._('Add to current playlist'); btnText = " " + $.i18n._("Add to current playlist");
} }
AIRTIME.library.changeAddButtonText($('.btn-group #library-plus #lib-plus-text'), btnText); AIRTIME.library.changeAddButtonText(
$(".btn-group #library-plus #lib-plus-text"),
btnText
);
}; };
mod.fnRowCallback = function (nRow, aData, iDisplayIndex, iDisplayIndexFull) { mod.fnRowCallback = function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
var $nRow = $(nRow); var $nRow = $(nRow);
if (aData.ftype === "audioclip") { if (aData.ftype === "audioclip") {
$nRow.addClass("lib-audio"); $nRow.addClass("lib-audio");
$image = $nRow.find('td.library_type'); $image = $nRow.find("td.library_type");
if (!isAudioSupported(aData.mime)) { if (!isAudioSupported(aData.mime)) {
$image.html('<span class="ui-icon ui-icon-locked"></span>'); $image.html('<span class="ui-icon ui-icon-locked"></span>');
aData.image = '<span class="ui-icon ui-icon-locked"></span>'; aData.image = '<span class="ui-icon ui-icon-locked"></span>';
@ -56,8 +58,10 @@ var AIRTIME = (function(AIRTIME) {
$nRow.addClass("lib-pl"); $nRow.addClass("lib-pl");
} }
$nRow.attr("id", aData["tr_id"]).data("aData", aData).data("screen", $nRow
"playlist"); .attr("id", aData["tr_id"])
.data("aData", aData)
.data("screen", "playlist");
if (aData["bl_type"] !== undefined) { if (aData["bl_type"] !== undefined) {
$nRow.attr("bl_type", aData["bl_type"]); $nRow.attr("bl_type", aData["bl_type"]);
@ -65,18 +69,20 @@ var AIRTIME = (function(AIRTIME) {
}; };
mod.fnDrawCallback = function () { mod.fnDrawCallback = function () {
mod.redrawChosen(); mod.redrawChosen();
mod.checkToolBarIcons(); mod.checkToolBarIcons();
$('#library_display tr.lib-audio, tr.lib-stream, tr.lib-pl, tr.lib-block') $(
.draggable( "#library_display tr.lib-audio, tr.lib-stream, tr.lib-pl, tr.lib-block"
{ ).draggable({
helper: function () { helper: function () {
var $el = $(this),
var $el = $(this), selected = mod selected = mod.getChosenAudioFilesLength(),
.getChosenAudioFilesLength(), container, message, li = $(".side_playlist ul[id='spl_sortable'] li:first"), container,
width = li.width(), height = 55; message,
li = $(".side_playlist ul[id='spl_sortable'] li:first"),
width = li.width(),
height = 55;
if (width > 798) width = 798; if (width > 798) width = 798;
// dragging an element that has an unselected // dragging an element that has an unselected
@ -91,35 +97,43 @@ var AIRTIME = (function(AIRTIME) {
message = sprintf($.i18n._("Adding %s Items"), selected); message = sprintf($.i18n._("Adding %s Items"), selected);
} }
container = $('<div class="helper"/>').append( container = $('<div class="helper"/>')
"<li/>").find("li").addClass( .append("<li/>")
"ui-state-default").append("<div/>") .find("li")
.find("div").addClass( .addClass("ui-state-default")
"list-item-container").append( .append("<div/>")
message).end().width(width) .find("div")
.height(height).end(); .addClass("list-item-container")
.append(message)
.end()
.width(width)
.height(height)
.end();
return container; return container;
}, },
cursor : 'pointer', cursor: "pointer",
cursorAt: { cursorAt: {
top: 30, top: 30,
left: 100 left: 100,
}, },
connectToSortable : '.spl_sortable' connectToSortable: ".spl_sortable",
}); });
}; };
mod.dblClickAdd = function (data, type) { mod.dblClickAdd = function (data, type) {
var i, aMediaIds = []; var i,
aMediaIds = [];
// process selected files/playlists. // process selected files/playlists.
aMediaIds.push(new Array(data.id, data.ftype)); aMediaIds.push(new Array(data.id, data.ftype));
// check if a playlist/block is open before adding items // check if a playlist/block is open before adding items
if ($('input[id="obj_type"]').val() == 'playlist' if (
|| $('input[id="obj_type"]').val() == 'block') { $('input[id="obj_type"]').val() == "playlist" ||
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, 'after'); $('input[id="obj_type"]').val() == "block"
) {
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, "after");
} }
}; };
@ -130,45 +144,53 @@ var AIRTIME = (function(AIRTIME) {
$toolbar.append($menu); $toolbar.append($menu);
// add to playlist button // add to playlist button
$toolbar $toolbar
.find('.icon-plus').parent() .find(".icon-plus")
.parent()
.click(function () { .click(function () {
if (AIRTIME.button.isDisabled("btn-group #library-plus") === true) {
if (AIRTIME.button.isDisabled('btn-group #library-plus') === true) {
return; return;
} }
var aData = AIRTIME.library.getSelectedData(), i, temp, length, aMediaIds = []; var aData = AIRTIME.library.getSelectedData(),
i,
temp,
length,
aMediaIds = [];
// process selected files/playlists. // process selected files/playlists.
for (i = 0, length = aData.length; i < length; i++) { for (i = 0, length = aData.length; i < length; i++) {
temp = aData[i]; temp = aData[i];
if (temp.ftype === "audioclip" if (
|| temp.ftype === "block" temp.ftype === "audioclip" ||
|| (temp.ftype === "stream" && $( temp.ftype === "block" ||
".obj_type").val() === "playlist")) { (temp.ftype === "stream" && $(".obj_type").val() === "playlist")
aMediaIds.push(new Array(temp.id, ) {
temp.ftype)); aMediaIds.push(new Array(temp.id, temp.ftype));
} }
} }
if (aMediaIds.length > 0) { if (aMediaIds.length > 0) {
AIRTIME.playlist.fnAddItems(aMediaIds, AIRTIME.playlist.fnAddItems(aMediaIds, undefined, "after");
undefined, 'after');
} else { } else {
if ($('.obj_type').val() == 'block') { if ($(".obj_type").val() == "block") {
alert($.i18n._('You can only add tracks to smart blocks.')); alert($.i18n._("You can only add tracks to smart blocks."));
} else if ($('.obj_type').val() == 'playlist') { } else if ($(".obj_type").val() == "playlist") {
alert($.i18n._('You can only add tracks, smart blocks, and webstreams to playlists.')); alert(
$.i18n._(
"You can only add tracks, smart blocks, and webstreams to playlists."
)
);
} }
} }
}); });
// delete from library. // delete from library.
$toolbar.find('.icon-trash').parent().click(function() { $toolbar
.find(".icon-trash")
if (AIRTIME.button.isDisabled('icon-trash') === true) { .parent()
.click(function () {
if (AIRTIME.button.isDisabled("icon-trash") === true) {
return; return;
} }
@ -179,5 +201,4 @@ var AIRTIME = (function(AIRTIME) {
}; };
return AIRTIME; return AIRTIME;
})(AIRTIME || {});
}(AIRTIME || {}));

View File

@ -8,10 +8,16 @@ var AIRTIME = (function(AIRTIME) {
mod = AIRTIME.library; mod = AIRTIME.library;
mod.checkAddButton = function () { mod.checkAddButton = function () {
var selected = mod.getChosenItemsLength(), $cursor = $('tr.sb-selected'), check = false, var selected = mod.getChosenItemsLength(),
shows = $('tr.sb-header'), current = $('tr.sb-current-show'), $cursor = $("tr.sb-selected"),
check = false,
shows = $("tr.sb-header"),
current = $("tr.sb-current-show"),
// TODO: this is an ugly way of doing this... we should find a more robust way of checking which view we're in. // TODO: this is an ugly way of doing this... we should find a more robust way of checking which view we're in.
btnText = (window.location.href.toLowerCase().indexOf("schedule") > -1) ? $.i18n._('Add to show') : $.i18n._('Add to next show'); btnText =
window.location.href.toLowerCase().indexOf("schedule") > -1
? $.i18n._("Add to show")
: $.i18n._("Add to next show");
// make sure library items are selected and a cursor is selected. // make sure library items are selected and a cursor is selected.
if (selected !== 0) { if (selected !== 0) {
@ -25,16 +31,16 @@ var AIRTIME = (function(AIRTIME) {
} }
if ($cursor.length !== 0) { if ($cursor.length !== 0) {
btnText = $.i18n._('Add after selected items'); btnText = $.i18n._("Add after selected items");
} else if (current.length !== 0) { } else if (current.length !== 0) {
btnText = $.i18n._('Add to current show'); btnText = $.i18n._("Add to current show");
} }
} else if (sortable.length > 0 && sortable.is(":visible")) { } else if (sortable.length > 0 && sortable.is(":visible")) {
var objType = $('.active-tab .obj_type').val(); var objType = $(".active-tab .obj_type").val();
if (objType === 'block') { if (objType === "block") {
btnText = $.i18n._('Add to current smart block'); btnText = $.i18n._("Add to current smart block");
} else { } else {
btnText = $.i18n._('Add to current playlist'); btnText = $.i18n._("Add to current playlist");
} }
} else { } else {
check = false; check = false;
@ -46,7 +52,10 @@ var AIRTIME = (function(AIRTIME) {
AIRTIME.button.disableButton("btn-group #library-plus", false); AIRTIME.button.disableButton("btn-group #library-plus", false);
} }
AIRTIME.library.changeAddButtonText($('.btn-group #library-plus #lib-plus-text'), btnText); AIRTIME.library.changeAddButtonText(
$(".btn-group #library-plus #lib-plus-text"),
btnText
);
}; };
mod.fnRowCallback = function (nRow, aData, iDisplayIndex, iDisplayIndexFull) { mod.fnRowCallback = function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
@ -54,7 +63,7 @@ var AIRTIME = (function(AIRTIME) {
if (aData.ftype === "audioclip") { if (aData.ftype === "audioclip") {
$nRow.addClass("lib-audio"); $nRow.addClass("lib-audio");
$image = $nRow.find('td.library_type'); $image = $nRow.find("td.library_type");
if (!isAudioSupported(aData.mime)) { if (!isAudioSupported(aData.mime)) {
$image.html('<span class="ui-icon ui-icon-locked"></span>'); $image.html('<span class="ui-icon ui-icon-locked"></span>');
aData.image = '<span class="ui-icon ui-icon-locked"></span>'; aData.image = '<span class="ui-icon ui-icon-locked"></span>';
@ -65,8 +74,10 @@ var AIRTIME = (function(AIRTIME) {
$nRow.addClass("lib-pl"); $nRow.addClass("lib-pl");
} }
$nRow.attr("id", aData["tr_id"]).data("aData", aData).data("screen", $nRow
"timeline"); .attr("id", aData["tr_id"])
.data("aData", aData)
.data("screen", "timeline");
}; };
/** /**
@ -83,29 +94,40 @@ var AIRTIME = (function(AIRTIME) {
return; return;
} }
} }
var emptyRow = table.find('tr:has(td.dataTables_empty)'), var emptyRow = table.find("tr:has(td.dataTables_empty)"),
wrapper = table.closest(".dataTables_wrapper"), wrapper = table.closest(".dataTables_wrapper"),
libEmpty = wrapper.find('.empty_placeholder'); libEmpty = wrapper.find(".empty_placeholder");
if (emptyRow.length > 0) { if (emptyRow.length > 0) {
emptyRow.hide(); emptyRow.hide();
var mediaType = parseInt($('.media_type_selector.selected').data('selection-id')), var mediaType = parseInt(
img = wrapper.find('.empty_placeholder_image'); $(".media_type_selector.selected").data("selection-id")
),
img = wrapper.find(".empty_placeholder_image");
if (!opts && isNaN(mediaType)) { if (!opts && isNaN(mediaType)) {
return; return;
} }
// Remove all classes for when we change between empty media types // Remove all classes for when we change between empty media types
img.removeClass(function() { return $(this).attr("class"); }); img.removeClass(function () {
return $(this).attr("class");
});
if (opts) { if (opts) {
img.addClass("empty_placeholder_image " + opts.iconClass); img.addClass("empty_placeholder_image " + opts.iconClass);
wrapper.find('.empty_placeholder_text').html(opts.html); wrapper.find(".empty_placeholder_text").html(opts.html);
} else { } else {
opts = AIRTIME.library.placeholder(mediaType); opts = AIRTIME.library.placeholder(mediaType);
img.addClass("empty_placeholder_image icon-white " + opts.icon); img.addClass("empty_placeholder_image icon-white " + opts.icon);
wrapper.find('.empty_placeholder_text').html( wrapper
$.i18n._("You haven't added any " + opts.media) .find(".empty_placeholder_text")
+ "<br/>" + $.i18n._(opts.subtext) .html(
+ "<br/><a target='_blank' href='" + opts.href + "'>" + $.i18n._("Learn about " + opts.media) + "</a>" $.i18n._("You haven't added any " + opts.media) +
"<br/>" +
$.i18n._(opts.subtext) +
"<br/><a target='_blank' href='" +
opts.href +
"'>" +
$.i18n._("Learn about " + opts.media) +
"</a>"
); );
} }
@ -116,7 +138,7 @@ var AIRTIME = (function(AIRTIME) {
}; };
mod.fnDrawCallback = function fnLibDrawCallback() { mod.fnDrawCallback = function fnLibDrawCallback() {
var table = $('#library_display'), var table = $("#library_display"),
cb = table.find('th[class*="checkbox"]'); cb = table.find('th[class*="checkbox"]');
if (cb.find("input").length == 0) { if (cb.find("input").length == 0) {
cb.append("<input id='super-checkbox' type='checkbox'>"); cb.append("<input id='super-checkbox' type='checkbox'>");
@ -135,14 +157,15 @@ var AIRTIME = (function(AIRTIME) {
sortable = ".active-tab .spl_sortable"; sortable = ".active-tab .spl_sortable";
} }
$('#library_display tr[class*="lib-"]') $('#library_display tr[class*="lib-"]').draggable({
.draggable(
{
helper: function () { helper: function () {
var $el = $(this),
var $el = $(this), selected = mod selected = mod.getChosenItemsLength(),
.getChosenItemsLength(), container, thead = $("#show_builder_table thead"), colspan = thead container,
.find("th").length, width = $el.width(), message; thead = $("#show_builder_table thead"),
colspan = thead.find("th").length,
width = $el.width(),
message;
// dragging an element that has an unselected // dragging an element that has an unselected
// checkbox. // checkbox.
@ -156,36 +179,47 @@ var AIRTIME = (function(AIRTIME) {
message = sprintf($.i18n._("Adding %s Items"), selected); message = sprintf($.i18n._("Adding %s Items"), selected);
} }
container = $('<div/>').attr('id', container = $("<div/>")
'draggingContainer').append('<tr/>') .attr("id", "draggingContainer")
.find("tr").append('<td/>').find("td") .append("<tr/>")
.attr("colspan", colspan).width(width) .find("tr")
.addClass("ui-state-highlight").append( .append("<td/>")
message).end().end(); .find("td")
.attr("colspan", colspan)
.width(width)
.addClass("ui-state-highlight")
.append(message)
.end()
.end();
return container; return container;
}, },
create: function (event, ui) { create: function (event, ui) {
$(this).draggable("option", "cursorAt", { $(this).draggable("option", "cursorAt", {
top: 20, top: 20,
left: Math.floor($(this).outerWidth() / 2) left: Math.floor($(this).outerWidth() / 2),
}); });
}, },
tolerance: 'pointer', tolerance: "pointer",
cursor: 'move', cursor: "move",
distance: 25, // min-distance for dragging distance: 25, // min-distance for dragging
connectToSortable: sortable connectToSortable: sortable,
}); });
}; };
mod.dblClickAdd = function (data, type) { mod.dblClickAdd = function (data, type) {
var i, length, temp, aMediaIds = [], aSchedIds = [], aData = []; var i,
length,
temp,
aMediaIds = [],
aSchedIds = [],
aData = [];
if ($("#show_builder_table").is(":visible")) { if ($("#show_builder_table").is(":visible")) {
// process selected files/playlists. // process selected files/playlists.
aMediaIds.push({ aMediaIds.push({
"id": data.id, id: data.id,
"type": type type: type,
}); });
$("#show_builder_table tr.sb-selected").each(function (i, el) { $("#show_builder_table tr.sb-selected").each(function (i, el) {
@ -196,9 +230,9 @@ var AIRTIME = (function(AIRTIME) {
for (i = 0, length = aData.length; i < length; i++) { for (i = 0, length = aData.length; i < length; i++) {
temp = aData[i]; temp = aData[i];
aSchedIds.push({ aSchedIds.push({
"id": temp.id, id: temp.id,
"instance": temp.instance, instance: temp.instance,
"timestamp": temp.timestamp timestamp: temp.timestamp,
}); });
} }
@ -214,9 +248,11 @@ var AIRTIME = (function(AIRTIME) {
aMediaIds.push(new Array(data.id, data.ftype)); aMediaIds.push(new Array(data.id, data.ftype));
// check if a playlist/block is open before adding items // check if a playlist/block is open before adding items
if ($('.active-tab .obj_type').val() == 'playlist' if (
|| $('.active-tab .obj_type').val() == 'block') { $(".active-tab .obj_type").val() == "playlist" ||
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, 'after'); $(".active-tab .obj_type").val() == "block"
) {
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, "after");
} }
} }
}; };
@ -228,20 +264,25 @@ var AIRTIME = (function(AIRTIME) {
var data = el.prev().data("aData"); var data = el.prev().data("aData");
if (data === undefined) { if (data === undefined) {
alert($.i18n._("Cannot schedule outside a show.\nTry creating a show first.")); alert(
$.i18n._("Cannot schedule outside a show.\nTry creating a show first.")
);
return false; return false;
} }
arr.push({ arr.push({
"id" : data.id, id: data.id,
"instance" : data.instance, instance: data.instance,
"timestamp" : data.timestamp timestamp: data.timestamp,
}); });
if (!isInView(el)) { if (!isInView(el)) {
$('.dataTables_scrolling.sb-padded').animate({ $(".dataTables_scrolling.sb-padded").animate(
scrollTop: el.offset().top {
}, 0); scrollTop: el.offset().top,
},
0
);
} }
return true; return true;
@ -249,26 +290,30 @@ var AIRTIME = (function(AIRTIME) {
mod.addToSchedule = function (selected) { mod.addToSchedule = function (selected) {
console.log(selected); console.log(selected);
var aMediaIds = [], aSchedIds = [], aData = []; var aMediaIds = [],
aSchedIds = [],
aData = [];
$.each(selected, function () { $.each(selected, function () {
aMediaIds.push({ aMediaIds.push({
"id": this.id, id: this.id,
"type": this.ftype type: this.ftype,
}); });
}); });
// process selected files/playlists. // process selected files/playlists.
$("#show_builder_table").find("tr.sb-selected").each(function (i, el) { $("#show_builder_table")
.find("tr.sb-selected")
.each(function (i, el) {
aData.push($(el).data("aData")); aData.push($(el).data("aData"));
}); });
// process selected schedule rows to add media after. // process selected schedule rows to add media after.
$.each(aData, function () { $.each(aData, function () {
aSchedIds.push({ aSchedIds.push({
"id": this.id, id: this.id,
"instance": this.instance, instance: this.instance,
"timestamp": this.timestamp timestamp: this.timestamp,
}); });
}); });
@ -290,19 +335,16 @@ var AIRTIME = (function(AIRTIME) {
e.stopPropagation(); e.stopPropagation();
}); });
if (localStorage.getItem('user-type') != 'G') { if (localStorage.getItem("user-type") != "G") {
$toolbar.append($menu); $toolbar.append($menu);
// add to timeline button // add to timeline button
$toolbar $toolbar.find("#library-plus").click(function () {
.find('#library-plus') if (AIRTIME.button.isDisabled("btn-group #library-plus") === true) {
.click(
function () {
if (AIRTIME.button.isDisabled('btn-group #library-plus') === true) {
return; return;
} }
var selected = AIRTIME.library.getSelectedData(), aMediaIds = []; var selected = AIRTIME.library.getSelectedData(),
aMediaIds = [];
if ($("#show_builder_table").is(":visible")) { if ($("#show_builder_table").is(":visible")) {
mod.addToSchedule(selected); mod.addToSchedule(selected);
@ -312,15 +354,17 @@ var AIRTIME = (function(AIRTIME) {
}); });
// check if a playlist/block is open before adding items // check if a playlist/block is open before adding items
if ($('.active-tab .obj_type').val() == 'playlist' if (
|| $('.active-tab .obj_type').val() == 'block') { $(".active-tab .obj_type").val() == "playlist" ||
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, 'after'); $(".active-tab .obj_type").val() == "block"
) {
AIRTIME.playlist.fnAddItems(aMediaIds, undefined, "after");
} }
} }
}); });
$toolbar.find('#publish-btn').click(function () { $toolbar.find("#publish-btn").click(function () {
if (AIRTIME.button.isDisabled('btn-group #publish-btn') === true) { if (AIRTIME.button.isDisabled("btn-group #publish-btn") === true) {
return; return;
} }
@ -333,16 +377,16 @@ var AIRTIME = (function(AIRTIME) {
}); });
// delete from library. // delete from library.
$toolbar.find('#sb-delete').click(function () { $toolbar.find("#sb-delete").click(function () {
if (AIRTIME.button.isDisabled('btn-group #sb-delete') === true) { if (AIRTIME.button.isDisabled("btn-group #sb-delete") === true) {
return; return;
} }
AIRTIME.library.fnDeleteSelectedItems(); AIRTIME.library.fnDeleteSelectedItems();
}); });
$toolbar.find('#sb-new').click(function () { $toolbar.find("#sb-new").click(function () {
if (AIRTIME.button.isDisabled('btn-group #sb-new') === true) { if (AIRTIME.button.isDisabled("btn-group #sb-new") === true) {
return; return;
} }
@ -352,14 +396,15 @@ var AIRTIME = (function(AIRTIME) {
AIRTIME.playlist.fnNew(); AIRTIME.playlist.fnNew();
} else if (selection == AIRTIME.library.MediaTypeIntegerEnum.BLOCK) { } else if (selection == AIRTIME.library.MediaTypeIntegerEnum.BLOCK) {
AIRTIME.playlist.fnNewBlock(); AIRTIME.playlist.fnNewBlock();
} else if (selection == AIRTIME.library.MediaTypeIntegerEnum.WEBSTREAM) { } else if (
selection == AIRTIME.library.MediaTypeIntegerEnum.WEBSTREAM
) {
AIRTIME.playlist.fnWsNew(); AIRTIME.playlist.fnWsNew();
} }
}); });
$toolbar.find("#sb-edit").click(function () {
$toolbar.find('#sb-edit').click(function () { if (AIRTIME.button.isDisabled("btn-group #sb-edit") === true) {
if (AIRTIME.button.isDisabled('btn-group #sb-edit') === true) {
return; return;
} }
@ -369,15 +414,19 @@ var AIRTIME = (function(AIRTIME) {
var data = $(el).data("aData"); var data = $(el).data("aData");
if (data.ftype === "audioclip") { if (data.ftype === "audioclip") {
$.get(baseUrl + "library/edit-file-md/id/" + data.id, {format: "json"}, function (json) { $.get(
baseUrl + "library/edit-file-md/id/" + data.id,
{ format: "json" },
function (json) {
AIRTIME.playlist.fileMdEdit(json, data.tr_id); AIRTIME.playlist.fileMdEdit(json, data.tr_id);
//buildEditMetadataDialog(json); //buildEditMetadataDialog(json);
}); }
);
} else if (data.ftype === "playlist" || data.ftype === "block") { } else if (data.ftype === "playlist" || data.ftype === "block") {
AIRTIME.playlist.fnEdit(data, baseUrl + 'playlist/edit'); AIRTIME.playlist.fnEdit(data, baseUrl + "playlist/edit");
AIRTIME.playlist.validatePlaylistElements(); AIRTIME.playlist.validatePlaylistElements();
} else if (data.ftype === "stream") { } else if (data.ftype === "stream") {
AIRTIME.playlist.fnEdit(data, baseUrl + 'webstream/edit'); AIRTIME.playlist.fnEdit(data, baseUrl + "webstream/edit");
} }
}); });
}); });
@ -387,5 +436,4 @@ var AIRTIME = (function(AIRTIME) {
}; };
return AIRTIME; return AIRTIME;
})(AIRTIME || {});
}(AIRTIME || {}));

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,4 @@
$(document).ready(function () { $(document).ready(function () {
var uploadProgress; var uploadProgress;
var self = this; var self = this;
self.uploadFilter = "all"; self.uploadFilter = "all";
@ -8,14 +7,14 @@ $(document).ready(function () {
0: { message: $.i18n._("Successfully imported") }, 0: { message: $.i18n._("Successfully imported") },
1: { message: $.i18n._("Pending import") }, 1: { message: $.i18n._("Pending import") },
2: { message: $.i18n._("Import failed.") }, 2: { message: $.i18n._("Import failed.") },
UNKNOWN: {message: $.i18n._("Unknown")} UNKNOWN: { message: $.i18n._("Unknown") },
}; };
if (Object.freeze) { if (Object.freeze) {
Object.freeze(self.IMPORT_STATUS_CODES); Object.freeze(self.IMPORT_STATUS_CODES);
} }
Dropzone.options.addMediaDropzone = { Dropzone.options.addMediaDropzone = {
url: '/rest/media', url: "/rest/media",
//clickable: false, //clickable: false,
acceptedFiles: acceptedMimeTypes.join(), acceptedFiles: acceptedMimeTypes.join(),
addRemoveLinks: true, addRemoveLinks: true,
@ -42,13 +41,18 @@ $(document).ready(function () {
this.on("queuecomplete", function () { this.on("queuecomplete", function () {
uploadProgress = false; uploadProgress = false;
}); });
} },
}; };
$(window).bind('beforeunload', function () { $(window).bind("beforeunload", function () {
if (uploadProgress) { if (uploadProgress) {
return sprintf($.i18n._("You are currently uploading files. %sGoing to another screen will cancel the upload process. %sAre you sure you want to leave the page?"), return sprintf(
"\n", "\n"); $.i18n._(
"You are currently uploading files. %sGoing to another screen will cancel the upload process. %sAre you sure you want to leave the page?"
),
"\n",
"\n"
);
} }
}); });
@ -68,12 +72,17 @@ $(document).ready(function () {
self.renderFileActions = function (data, type, full) { self.renderFileActions = function (data, type, full) {
if (full.import_status == 0) { if (full.import_status == 0) {
return '<a class="deleteFileAction">' + $.i18n._('Delete from Library') + '</a>'; return (
'<a class="deleteFileAction">' +
$.i18n._("Delete from Library") +
"</a>"
);
} else if (full.import_status == 1) { } else if (full.import_status == 1) {
//No actions for pending files //No actions for pending files
return $.i18n._('N/A'); return $.i18n._("N/A");
} else { //Failed downloads } else {
return '<a class="deleteFileAction">' + $.i18n._('Clear') + '</a>'; //Failed downloads
return '<a class="deleteFileAction">' + $.i18n._("Clear") + "</a>";
} }
}; };
@ -82,58 +91,66 @@ $(document).ready(function () {
// Some tips from the DataTables forums: // Some tips from the DataTables forums:
// fnGetData is used to get the object behind the row - you can also use // fnGetData is used to get the object behind the row - you can also use
// fnGetPosition if you need to get the index instead // fnGetPosition if you need to get the index instead
file = $("#recent_uploads_table").dataTable().fnGetData($(this).closest("tr")[0]); file = $("#recent_uploads_table")
.dataTable()
.fnGetData($(this).closest("tr")[0]);
$.ajax({ $.ajax({
type: 'DELETE', type: "DELETE",
url: 'rest/media/' + file.id + "?csrf_token=" + $("#csrf").attr('value'), url: "rest/media/" + file.id + "?csrf_token=" + $("#csrf").attr("value"),
success: function (resp) { success: function (resp) {
self.recentUploadsTable.fnDraw(); self.recentUploadsTable.fnDraw();
}, },
error: function () { error: function () {
alert($.i18n._("Error: The file could not be deleted. Please try again later.")); alert(
} $.i18n._(
"Error: The file could not be deleted. Please try again later."
)
);
},
}); });
}); });
self.setupRecentUploadsTable = function () { self.setupRecentUploadsTable = function () {
return $("#recent_uploads_table").dataTable({ return $("#recent_uploads_table").dataTable({
"bJQueryUI": true, bJQueryUI: true,
"bProcessing": false, bProcessing: false,
"bServerSide": true, bServerSide: true,
"sAjaxSource": '/plupload/recent-uploads/format/json', sAjaxSource: "/plupload/recent-uploads/format/json",
"sAjaxDataProp": 'files', sAjaxDataProp: "files",
"bSearchable": false, bSearchable: false,
"bInfo": true, bInfo: true,
//"sScrollY": "200px", //"sScrollY": "200px",
"bFilter": false, bFilter: false,
"bSort": false, bSort: false,
//"sDom": '<"H">frtip<"F"l>', //"sDom": '<"H">frtip<"F"l>',
"sDom": '<"dataTables_scrolling"frt><"F"lip>', sDom: '<"dataTables_scrolling"frt><"F"lip>',
"bPaginate": true, bPaginate: true,
"sPaginationType": "full_numbers", sPaginationType: "full_numbers",
"oLanguage": getDatatablesStrings({ oLanguage: getDatatablesStrings({
"sEmptyTable": $.i18n._("No files have been uploaded yet."), sEmptyTable: $.i18n._("No files have been uploaded yet."),
"sInfoEmpty": $.i18n._("Showing 0 to 0 of 0 uploads"), sInfoEmpty: $.i18n._("Showing 0 to 0 of 0 uploads"),
"sInfo": $.i18n._("Showing _START_ to _END_ of _TOTAL_ uploads"), sInfo: $.i18n._("Showing _START_ to _END_ of _TOTAL_ uploads"),
"sInfoFiltered": $.i18n._("(filtered from _MAX_ total uploads)"), sInfoFiltered: $.i18n._("(filtered from _MAX_ total uploads)"),
}), }),
"aoColumns": [ aoColumns: [
{"mData": "artist_name", "sTitle": $.i18n._("Creator")}, { mData: "artist_name", sTitle: $.i18n._("Creator") },
{"mData": "track_title", "sTitle": $.i18n._("Title")}, { mData: "track_title", sTitle: $.i18n._("Title") },
{ {
"mData": "import_status", "sTitle": $.i18n._("Import Status"), mData: "import_status",
"mRender": self.renderImportStatus sTitle: $.i18n._("Import Status"),
mRender: self.renderImportStatus,
}, },
{"mData": "utime", "sTitle": $.i18n._("Uploaded")}, { mData: "utime", sTitle: $.i18n._("Uploaded") },
{ {
"mData": "id", "sTitle": $.i18n._("Actions"), mData: "id",
"mRender": self.renderFileActions sTitle: $.i18n._("Actions"),
} mRender: self.renderFileActions,
},
], ],
"fnServerData": function (sSource, aoData, fnCallback) { fnServerData: function (sSource, aoData, fnCallback) {
/* Add some extra data to the sender */ /* Add some extra data to the sender */
aoData.push({"name": "uploadFilter", "value": self.uploadFilter}); aoData.push({ name: "uploadFilter", value: self.uploadFilter });
$.getJSON(sSource, aoData, function (json) { $.getJSON(sSource, aoData, function (json) {
fnCallback(json); fnCallback(json);
if (json.files) { if (json.files) {
@ -158,7 +175,7 @@ $(document).ready(function () {
getUsabilityHint(); getUsabilityHint();
} }
}); });
} },
}); });
}; };
@ -167,7 +184,8 @@ $(document).ready(function () {
self.isRecentUploadsRefreshTimerActive = false; self.isRecentUploadsRefreshTimerActive = false;
self.startRefreshingRecentUploads = function () { self.startRefreshingRecentUploads = function () {
if (!self.isRecentUploadsRefreshTimerActive) { //Prevent multiple timers from running if (!self.isRecentUploadsRefreshTimerActive) {
//Prevent multiple timers from running
self.recentUploadsRefreshTimer = setInterval(function () { self.recentUploadsRefreshTimer = setInterval(function () {
self.recentUploadsTable.fnDraw(); self.recentUploadsTable.fnDraw();
}, 3000); }, 3000);
@ -214,6 +232,6 @@ $(document).ready(function () {
$("#upload_type").text(" Tracks"); $("#upload_type").text(" Tracks");
$("#upload_type").css("color", "#ffffff"); $("#upload_type").css("color", "#ffffff");
} }
Cookies.set('tt_upload', ttValue); Cookies.set("tt_upload", ttValue);
}); });
}); });

View File

@ -8,7 +8,8 @@ var AIRTIME = (function (AIRTIME) {
mod = AIRTIME.podcast; mod = AIRTIME.podcast;
mod.episodeTables = {}; mod.episodeTables = {};
var endpoint = '/rest/podcast/', PodcastEpisodeTable; var endpoint = "/rest/podcast/",
PodcastEpisodeTable;
/** /**
* PodcastController constructor. * PodcastController constructor.
@ -36,7 +37,7 @@ var AIRTIME = (function (AIRTIME) {
view.find("table").attr("id", "podcast_episodes_" + podcast.id); view.find("table").attr("id", "podcast_episodes_" + podcast.id);
self.onSaveCallback = function () { self.onSaveCallback = function () {
var successMsg = $('.active-tab .btn-toolbar .success') var successMsg = $(".active-tab .btn-toolbar .success");
successMsg.text($.i18n._("Podcast settings saved")).show("fast"); successMsg.text($.i18n._("Podcast settings saved")).show("fast");
setTimeout(function () { setTimeout(function () {
successMsg.hide("fast"); successMsg.hide("fast");
@ -49,13 +50,16 @@ var AIRTIME = (function (AIRTIME) {
* Save and update the podcast object. * Save and update the podcast object.
*/ */
$scope.savePodcast = function () { $scope.savePodcast = function () {
$http.put(endpoint + $scope.podcast.id, {csrf_token: $scope.csrf, podcast: $scope.podcast}) $http
.put(endpoint + $scope.podcast.id, {
csrf_token: $scope.csrf,
podcast: $scope.podcast,
})
.success(function () { .success(function () {
self.onSaveCallback(); self.onSaveCallback();
}); });
}; };
/** /**
* Generate a smartblock and playlist for this smartblock. * Generate a smartblock and playlist for this smartblock.
*/ */
@ -66,21 +70,21 @@ var AIRTIME = (function (AIRTIME) {
{ {
csrf_token: $("#csrf").val(), csrf_token: $("#csrf").val(),
id: $scope.podcast.id, id: $scope.podcast.id,
title: $scope.podcast.title title: $scope.podcast.title,
}, },
function () { function () {
// show success message // show success message
var successMsg = $('.active-tab .pc-sb-success') var successMsg = $(".active-tab .pc-sb-success");
successMsg.show("fast"); successMsg.show("fast");
setTimeout(function () { setTimeout(function () {
successMsg.hide("fast"); successMsg.hide("fast");
}, 5000); }, 5000);
// save podcast but do not display notification beside save button below // save podcast but do not display notification beside save button below
$http.put(endpoint + $scope.podcast.id, $http
{ .put(endpoint + $scope.podcast.id, {
csrf_token: $scope.csrf, csrf_token: $scope.csrf,
podcast: $scope.podcast podcast: $scope.podcast,
}) })
.success(function () { .success(function () {
AIRTIME.library.podcastDataTable.fnDraw(); AIRTIME.library.podcastDataTable.fnDraw();
@ -108,9 +112,6 @@ var AIRTIME = (function (AIRTIME) {
return self; return self;
} }
/** /**
* Initialize the controller. * Initialize the controller.
* *
@ -150,13 +151,19 @@ var AIRTIME = (function (AIRTIME) {
PodcastController.call(this, $scope, $http, podcast, tab); PodcastController.call(this, $scope, $http, podcast, tab);
this.onSaveCallback = function () { this.onSaveCallback = function () {
$http({ $http({
method: 'POST', method: "POST",
url: '/preference/station-podcast-settings', url: "/preference/station-podcast-settings",
headers: {'Content-Type': 'application/x-www-form-urlencoded'}, headers: { "Content-Type": "application/x-www-form-urlencoded" },
data: { stationPodcastPrivacy: $("#podcast-settings").find("input:checked").val() } data: {
stationPodcastPrivacy: $("#podcast-settings")
.find("input:checked")
.val(),
},
}).success(function (data) { }).success(function (data) {
jQuery.extend($scope.podcast, data); jQuery.extend($scope.podcast, data);
$(".success").text($.i18n._("Podcast settings saved")).slideDown("fast"); $(".success")
.text($.i18n._("Podcast settings saved"))
.slideDown("fast");
setTimeout(function () { setTimeout(function () {
$(".success").slideUp("fast"); $(".success").slideUp("fast");
}, 2000); }, 2000);
@ -170,16 +177,27 @@ var AIRTIME = (function (AIRTIME) {
* *
* @type {PodcastController} * @type {PodcastController}
*/ */
StationPodcastController.prototype = Object.create(PodcastController.prototype); StationPodcastController.prototype = Object.create(
PodcastController.prototype
);
/** /**
* Remove the selected episodes from the station podcast feed. * Remove the selected episodes from the station podcast feed.
*/ */
StationPodcastController.prototype.unpublishSelectedEpisodes = function () { StationPodcastController.prototype.unpublishSelectedEpisodes = function () {
var self = this, $scope = self.$scope, var self = this,
$scope = self.$scope,
episodes = self.episodeTable.getSelectedRows(); episodes = self.episodeTable.getSelectedRows();
jQuery.each(episodes, function () { jQuery.each(episodes, function () {
self.$http.delete(endpoint + $scope.podcast.id + '/episodes/' + this.id + '?csrf_token=' + $scope.csrf) self.$http
.delete(
endpoint +
$scope.podcast.id +
"/episodes/" +
this.id +
"?csrf_token=" +
$scope.csrf
)
.success(function () { .success(function () {
self.reloadEpisodeTable(); self.reloadEpisodeTable();
}); });
@ -192,32 +210,43 @@ var AIRTIME = (function (AIRTIME) {
* @private * @private
*/ */
StationPodcastController.prototype._initTable = function () { StationPodcastController.prototype._initTable = function () {
var self = this, $scope = this.$scope, var self = this,
$scope = this.$scope,
buttons = { buttons = {
deleteBtn: { deleteBtn: {
title : $.i18n._('Unpublish'), title: $.i18n._("Unpublish"),
iconClass : 'icon-trash', iconClass: "icon-trash",
extraBtnClass : 'btn-danger', extraBtnClass: "btn-danger",
elementId : '', elementId: "",
eventHandlers: { eventHandlers: {
click: self.unpublishSelectedEpisodes.bind(self) click: self.unpublishSelectedEpisodes.bind(self),
}, },
validateConstraints: function () { validateConstraints: function () {
return this.getSelectedRows().length >= 1; return this.getSelectedRows().length >= 1;
} },
} },
}, },
params = { params = {
sAjaxSource : endpoint + $scope.podcast.id + '/episodes', sAjaxSource: endpoint + $scope.podcast.id + "/episodes",
aoColumns: [ aoColumns: [
// TODO: it might be wrong to use CcFiles here? We should alias this instead // TODO: it might be wrong to use CcFiles here? We should alias this instead
/* Title */ { "sTitle" : $.i18n._("Title") , "mDataProp" : "CcFiles.track_title" , "sClass" : "podcast_episodes_title" , "sWidth" : "170px" }, /* Title */ {
/* Description */ { "sTitle" : $.i18n._("Description") , "mDataProp" : "CcFiles.description" , "sClass" : "podcast_episodes_description" , "sWidth" : "300px" } sTitle: $.i18n._("Title"),
] mDataProp: "CcFiles.track_title",
sClass: "podcast_episodes_title",
sWidth: "170px",
},
/* Description */ {
sTitle: $.i18n._("Description"),
mDataProp: "CcFiles.description",
sClass: "podcast_episodes_description",
sWidth: "300px",
},
],
}; };
this.episodeTable = AIRTIME.podcast.initPodcastEpisodeDatatable( this.episodeTable = AIRTIME.podcast.initPodcastEpisodeDatatable(
$('.podcast_episodes'), $(".podcast_episodes"),
params, params,
buttons, buttons,
{ {
@ -225,10 +254,16 @@ var AIRTIME = (function (AIRTIME) {
podcastId: $scope.podcast.id, podcastId: $scope.podcast.id,
emptyPlaceholder: { emptyPlaceholder: {
iconClass: "icon-white icon-th-list", iconClass: "icon-white icon-th-list",
html: $.i18n._("You haven't published any episodes!") html:
+ "<br/>" + $.i18n._("You can publish your uploaded content from the 'Tracks' view.") $.i18n._("You haven't published any episodes!") +
+ "<br/><a target='_parent' href='/showbuilder#tracks'>" + $.i18n._("Try it now") + "</a>" "<br/>" +
} $.i18n._(
"You can publish your uploaded content from the 'Tracks' view."
) +
"<br/><a target='_parent' href='/showbuilder#tracks'>" +
$.i18n._("Try it now") +
"</a>",
},
} }
); );
@ -257,9 +292,22 @@ var AIRTIME = (function (AIRTIME) {
* *
* Bootstrapped for each podcast or Station podcast tab. * Bootstrapped for each podcast or Station podcast tab.
*/ */
mod.podcastApp = angular.module('podcast', []) mod.podcastApp = angular
.controller('Podcast', ['$scope', '$http', 'podcast', 'tab', PodcastController]) .module("podcast", [])
.controller('StationPodcast', ['$scope', '$http', 'podcast', 'tab', StationPodcastController]); .controller("Podcast", [
"$scope",
"$http",
"podcast",
"tab",
PodcastController,
])
.controller("StationPodcast", [
"$scope",
"$http",
"podcast",
"tab",
StationPodcastController,
]);
/** /**
* Implement bulk editing of podcasts in order to accommodate the existing selection * Implement bulk editing of podcasts in order to accommodate the existing selection
@ -288,7 +336,11 @@ var AIRTIME = (function (AIRTIME) {
}); });
if (ids.length > 0) { if (ids.length > 0) {
$.post(endpoint + "bulk", {csrf_token: $("#csrf").val(), method: method, ids: ids}, callback); $.post(
endpoint + "bulk",
{ csrf_token: $("#csrf").val(), method: method, ids: ids },
callback
);
} }
} }
@ -300,8 +352,8 @@ var AIRTIME = (function (AIRTIME) {
* @private * @private
*/ */
function _bootstrapAngularApp(podcast, tab) { function _bootstrapAngularApp(podcast, tab) {
mod.podcastApp.value('podcast', podcast); mod.podcastApp.value("podcast", podcast);
mod.podcastApp.value('tab', tab); mod.podcastApp.value("tab", tab);
var wrapper = tab.contents.find(".angular_wrapper"); var wrapper = tab.contents.find(".angular_wrapper");
angular.bootstrap(wrapper.get(0), ["podcast"]); angular.bootstrap(wrapper.get(0), ["podcast"]);
} }
@ -329,32 +381,35 @@ var AIRTIME = (function (AIRTIME) {
$(".album_names.help_icon").qtip({ $(".album_names.help_icon").qtip({
content: { content: {
text: $.i18n._('Overwrite downloaded podcast episodes\' "Album" and "Creator" metadata tag with the Podcast Name specified above and set the track title to the title of the Podcast Episode. This album name can then be used as a search criteria by a smartblock. ') text: $.i18n._(
'Overwrite downloaded podcast episodes\' "Album" and "Creator" metadata tag with the Podcast Name specified above and set the track title to the title of the Podcast Episode. This album name can then be used as a search criteria by a smartblock. '
),
}, },
hide: { hide: {
delay: 500, delay: 500,
fixed: true fixed: true,
}, },
style: { style: {
border: { border: {
width: 0, width: 0,
radius: 4 radius: 4,
}, },
classes: "ui-tooltip-dark ui-tooltip-rounded" classes: "ui-tooltip-dark ui-tooltip-rounded",
}, },
position: { position: {
my: "left bottom", my: "left bottom",
at: "right center" at: "right center",
} },
}); });
// Add podcast episode table in right-side panel below podcast edit form // Add podcast episode table in right-side panel below podcast edit form
var episodeTable = AIRTIME.podcast.initPodcastEpisodeDatatableWithButtonEvents( var episodeTable =
AIRTIME.podcast.initPodcastEpisodeDatatableWithButtonEvents(
$("#podcast_episodes_" + podcast.id), $("#podcast_episodes_" + podcast.id),
podcast.id.toString() podcast.id.toString()
); );
episodeTable.reload(podcast.id); episodeTable.reload(podcast.id);
episodeTable.clearSelection() episodeTable.clearSelection();
} }
/** /**
@ -365,17 +420,32 @@ var AIRTIME = (function (AIRTIME) {
* @private * @private
*/ */
function _initPodcastEpisodeTable() { function _initPodcastEpisodeTable() {
PodcastEpisodeTable = function(wrapperDOMNode, bItemSelection, toolbarButtons, dataTablesOptions, config) { PodcastEpisodeTable = function (
wrapperDOMNode,
bItemSelection,
toolbarButtons,
dataTablesOptions,
config
) {
this.config = config; // Internal configuration object this.config = config; // Internal configuration object
this._setupImportListener(); this._setupImportListener();
// Call the superconstructor // Call the superconstructor
return AIRTIME.widgets.Table.call(this, wrapperDOMNode, bItemSelection, toolbarButtons, dataTablesOptions, config.emptyPlaceholder); return AIRTIME.widgets.Table.call(
this,
wrapperDOMNode,
bItemSelection,
toolbarButtons,
dataTablesOptions,
config.emptyPlaceholder
);
}; // Subclass AIRTIME.widgets.Table }; // Subclass AIRTIME.widgets.Table
PodcastEpisodeTable.prototype = Object.create(AIRTIME.widgets.Table.prototype); PodcastEpisodeTable.prototype = Object.create(
AIRTIME.widgets.Table.prototype
);
PodcastEpisodeTable.prototype.constructor = PodcastEpisodeTable; PodcastEpisodeTable.prototype.constructor = PodcastEpisodeTable;
PodcastEpisodeTable.prototype._SELECTORS = Object.freeze({ PodcastEpisodeTable.prototype._SELECTORS = Object.freeze({
SELECTION_CHECKBOX: ".airtime_table_checkbox:has(input)", SELECTION_CHECKBOX: ".airtime_table_checkbox:has(input)",
SELECTION_TABLE_ROW: "tr:has(td.airtime_table_checkbox > input)" SELECTION_TABLE_ROW: "tr:has(td.airtime_table_checkbox > input)",
}); });
/** /**
@ -392,15 +462,34 @@ var AIRTIME = (function (AIRTIME) {
* @returns {string} * @returns {string}
* @private * @private
*/ */
PodcastEpisodeTable.prototype._datatablesCheckboxDataDelegate = function(rowData, callType, dataToSave) { PodcastEpisodeTable.prototype._datatablesCheckboxDataDelegate = function (
rowData,
callType,
dataToSave
) {
var defaultIcon = "<span class='icon icon-circle-arrow-down'></span>", var defaultIcon = "<span class='icon icon-circle-arrow-down'></span>",
importIcon = "<span class='sp-checked-icon checked-icon imported-flag'></span>", importIcon =
"<span class='sp-checked-icon checked-icon imported-flag'></span>",
pendingIcon = "<span class='loading-icon'></span>"; pendingIcon = "<span class='loading-icon'></span>";
if (this.config.hideIngestCheckboxes && rowData.ingested && rowData.ingested != 0) { if (
this.config.hideIngestCheckboxes &&
rowData.ingested &&
rowData.ingested != 0
) {
return rowData.ingested > 0 ? importIcon : pendingIcon; return rowData.ingested > 0 ? importIcon : pendingIcon;
} }
rowData.importIcon = (rowData.ingested != 0) ? (rowData.ingested > 0 ? importIcon : pendingIcon) : defaultIcon; rowData.importIcon =
return AIRTIME.widgets.Table.prototype._datatablesCheckboxDataDelegate.call(this, rowData, callType, dataToSave); rowData.ingested != 0
? rowData.ingested > 0
? importIcon
: pendingIcon
: defaultIcon;
return AIRTIME.widgets.Table.prototype._datatablesCheckboxDataDelegate.call(
this,
rowData,
callType,
dataToSave
);
}; };
/** /**
@ -414,13 +503,14 @@ var AIRTIME = (function (AIRTIME) {
// When using static source data, we instantiate an empty table // When using static source data, we instantiate an empty table
// and pass this function the ID of the podcast we want to display. // and pass this function the ID of the podcast we want to display.
if (id) this.config.podcastId = id; if (id) this.config.podcastId = id;
var self = this, dt = self._datatable; var self = this,
dt = self._datatable;
dt.block({ dt.block({
message: "", message: "",
theme: true, theme: true,
applyPlatformOpacityRules: false applyPlatformOpacityRules: false,
}); });
$.get(endpoint + self.config.podcastId + '/episodes', function (json) { $.get(endpoint + self.config.podcastId + "/episodes", function (json) {
dt.fnClearTable(false); dt.fnClearTable(false);
dt.fnAddData(JSON.parse(json)); dt.fnAddData(JSON.parse(json));
}).done(function () { }).done(function () {
@ -439,9 +529,11 @@ var AIRTIME = (function (AIRTIME) {
PodcastEpisodeTable.prototype._setupImportListener = function () { PodcastEpisodeTable.prototype._setupImportListener = function () {
var self = this; var self = this;
self.importListener = setInterval(function () { self.importListener = setInterval(function () {
var podcastId = self.config.podcastId, pendingRows = []; var podcastId = self.config.podcastId,
pendingRows = [];
if (!podcastId) return false; if (!podcastId) return false;
var dt = self.getDatatable(), data = dt.fnGetData(); var dt = self.getDatatable(),
data = dt.fnGetData();
// Iterate over the table data to check for any rows pending import // Iterate over the table data to check for any rows pending import
$.each(data, function () { $.each(data, function () {
if (this.ingested == -1) { if (this.ingested == -1) {
@ -451,11 +543,11 @@ var AIRTIME = (function (AIRTIME) {
if (pendingRows.length > 0) { if (pendingRows.length > 0) {
// Manually trigger the Celery task to update the internal // Manually trigger the Celery task to update the internal
// task reference because the upload will often finish quickly // task reference because the upload will often finish quickly
$.get('/api/poll-celery'); $.get("/api/poll-celery");
// Fetch the table data if there are pending rows, // Fetch the table data if there are pending rows,
// then check if any of the pending rows have // then check if any of the pending rows have
// succeeded or failed before reloading the table. // succeeded or failed before reloading the table.
$.get(endpoint + podcastId + '/episodes', function (json) { $.get(endpoint + podcastId + "/episodes", function (json) {
data = JSON.parse(json); data = JSON.parse(json);
var delta = false; var delta = false;
$.each(data, function () { $.each(data, function () {
@ -465,7 +557,8 @@ var AIRTIME = (function (AIRTIME) {
pendingRows.slice(idx, 0); pendingRows.slice(idx, 0);
} }
}); });
if (delta) { // Has there been a change? if (delta) {
// Has there been a change?
// We already have the data, so there's no reason to call // We already have the data, so there's no reason to call
// reload() here; this also provides a smoother transition // reload() here; this also provides a smoother transition
dt.fnClearTable(false); dt.fnClearTable(false);
@ -481,24 +574,24 @@ var AIRTIME = (function (AIRTIME) {
*/ */
PodcastEpisodeTable.prototype.destroy = function () { PodcastEpisodeTable.prototype.destroy = function () {
clearInterval(this.importListener); clearInterval(this.importListener);
} };
} }
/** /**
* Create and show the URL dialog for podcast creation. * Create and show the URL dialog for podcast creation.
*/ */
mod.createUrlDialog = function () { mod.createUrlDialog = function () {
$.get('/render/podcast-url-dialog', function(json) { $.get("/render/podcast-url-dialog", function (json) {
$(document.body).append(json.html); $(document.body).append(json.html);
$("#podcast_url_dialog").dialog({ $("#podcast_url_dialog").dialog({
title: $.i18n._("Add New Podcast"), title: $.i18n._("Add New Podcast"),
resizable: false, resizable: false,
modal: true, modal: true,
width: '450px', width: "450px",
height: 129, height: 129,
close: function () { close: function () {
$(this).remove(); $(this).remove();
} },
}); });
}); });
}; };
@ -510,7 +603,10 @@ var AIRTIME = (function (AIRTIME) {
* FIXME: we should probably be passing the serialized form into this function instead * FIXME: we should probably be passing the serialized form into this function instead
*/ */
mod.addPodcast = function () { mod.addPodcast = function () {
$.post(endpoint, $("#podcast_url_dialog").find("form").serialize(), function(json) { $.post(
endpoint,
$("#podcast_url_dialog").find("form").serialize(),
function (json) {
// Refresh left-side library pane to show newly created podcast // Refresh left-side library pane to show newly created podcast
AIRTIME.library.podcastDataTable.fnDraw(); AIRTIME.library.podcastDataTable.fnDraw();
@ -519,7 +615,8 @@ var AIRTIME = (function (AIRTIME) {
// open newly created podcast in right-side edit pane // open newly created podcast in right-side edit pane
_initAppFromResponse(json); _initAppFromResponse(json);
}).fail(function (e) { }
).fail(function (e) {
var errors = $("#podcast_url_dialog").find(".errors"); var errors = $("#podcast_url_dialog").find(".errors");
errors.show(200).text(e.responseText); errors.show(200).text(e.responseText);
setTimeout(function () { setTimeout(function () {
@ -532,21 +629,35 @@ var AIRTIME = (function (AIRTIME) {
* Create a bulk request to edit all currently selected podcasts. * Create a bulk request to edit all currently selected podcasts.
*/ */
mod.editSelectedPodcasts = function () { mod.editSelectedPodcasts = function () {
_bulkAction(AIRTIME.library.podcastTableWidget.getSelectedRows(), HTTPMethods.GET, function(json) { _bulkAction(
AIRTIME.library.podcastTableWidget.getSelectedRows(),
HTTPMethods.GET,
function (json) {
json.forEach(function (data) { json.forEach(function (data) {
_initAppFromResponse(data); _initAppFromResponse(data);
}); });
}); }
);
}; };
/** /**
* Create a bulk request to delete all currently selected podcasts. * Create a bulk request to delete all currently selected podcasts.
*/ */
mod.deleteSelectedPodcasts = function () { mod.deleteSelectedPodcasts = function () {
if (confirm($.i18n._("Are you sure you want to delete the selected podcasts from your library?"))) { if (
_bulkAction(AIRTIME.library.podcastTableWidget.getSelectedRows(), HTTPMethods.DELETE, function () { confirm(
$.i18n._(
"Are you sure you want to delete the selected podcasts from your library?"
)
)
) {
_bulkAction(
AIRTIME.library.podcastTableWidget.getSelectedRows(),
HTTPMethods.DELETE,
function () {
AIRTIME.library.podcastDataTable.fnDraw(); AIRTIME.library.podcastDataTable.fnDraw();
}); }
);
} }
}; };
@ -558,10 +669,15 @@ var AIRTIME = (function (AIRTIME) {
mod.editSelectedEpisodes = function (episodes) { mod.editSelectedEpisodes = function (episodes) {
$.each(episodes, function () { $.each(episodes, function () {
if (this.file && !Object.keys(this.file).length > 0) return false; if (this.file && !Object.keys(this.file).length > 0) return false;
var fileId = this.file_id || this.file.id, uid = AIRTIME.library.MediaTypeStringEnum.FILE + "_" + fileId; var fileId = this.file_id || this.file.id,
$.get(baseUrl + "library/edit-file-md/id/" + fileId, {format: "json"}, function (json) { uid = AIRTIME.library.MediaTypeStringEnum.FILE + "_" + fileId;
$.get(
baseUrl + "library/edit-file-md/id/" + fileId,
{ format: "json" },
function (json) {
AIRTIME.playlist.fileMdEdit(json, uid); AIRTIME.playlist.fileMdEdit(json, uid);
}); }
);
}); });
}; };
@ -579,12 +695,16 @@ var AIRTIME = (function (AIRTIME) {
return false; return false;
} }
if (this.file && Object.keys(this.file).length > 0) return false; if (this.file && Object.keys(this.file).length > 0) return false;
$.post(endpoint + this.podcast_id + '/episodes', JSON.stringify({ $.post(
endpoint + this.podcast_id + "/episodes",
JSON.stringify({
csrf_token: $("#csrf").val(), csrf_token: $("#csrf").val(),
episode: this episode: this,
}), function () { }),
function () {
dt.reload(dt.config.podcastId); dt.reload(dt.config.podcastId);
}); }
);
remainingDiskSpace -= this.enclosure.length; remainingDiskSpace -= this.enclosure.length;
}); });
@ -607,8 +727,10 @@ var AIRTIME = (function (AIRTIME) {
/** /**
* Initialize the podcast episode table with working buttons * Initialize the podcast episode table with working buttons
*/ */
mod.initPodcastEpisodeDatatableWithButtonEvents = function (domNode, podcastId) { mod.initPodcastEpisodeDatatableWithButtonEvents = function (
domNode,
podcastId
) {
/** /**
* Check the import statuses of each selected episode to see which * Check the import statuses of each selected episode to see which
* buttons should be enabled or disabled. * buttons should be enabled or disabled.
@ -620,7 +742,8 @@ var AIRTIME = (function (AIRTIME) {
* the button should be enabled, otherwise false. * the button should be enabled, otherwise false.
*/ */
var checkSelectedEpisodeImportStatus = function (shouldBeImported) { var checkSelectedEpisodeImportStatus = function (shouldBeImported) {
var selected = this.getSelectedRows(), isValid = true; var selected = this.getSelectedRows(),
isValid = true;
if (selected.length == 0) return false; if (selected.length == 0) return false;
$.each(selected, function () { $.each(selected, function () {
if (this.ingested < 0) isValid = false; if (this.ingested < 0) isValid = false;
@ -634,72 +757,94 @@ var AIRTIME = (function (AIRTIME) {
// Setup the default buttons (new, edit, delete) // Setup the default buttons (new, edit, delete)
podcastEpisodeButtons = AIRTIME.widgets.Table.getStandardToolbarButtons(); podcastEpisodeButtons = AIRTIME.widgets.Table.getStandardToolbarButtons();
$.extend(true, podcastEpisodeButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.NEW], $.extend(
true,
podcastEpisodeButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.NEW],
{ {
title: $.i18n._("Import"), title: $.i18n._("Import"),
eventHandlers: { eventHandlers: {
click: function () { click: function () {
var episodes = mod.episodeTables[podcastId].getSelectedRows(); var episodes = mod.episodeTables[podcastId].getSelectedRows();
AIRTIME.podcast.importSelectedEpisodes(episodes, mod.episodeTables[podcastId]); AIRTIME.podcast.importSelectedEpisodes(
} episodes,
mod.episodeTables[podcastId]
);
},
}, },
validateConstraints: function () { validateConstraints: function () {
return checkSelectedEpisodeImportStatus.call(this, false); return checkSelectedEpisodeImportStatus.call(this, false);
},
} }
}); );
$.extend(true, podcastEpisodeButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.EDIT], $.extend(
true,
podcastEpisodeButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.EDIT],
{ {
eventHandlers: { eventHandlers: {
click: function () { click: function () {
var episodes = mod.episodeTables[podcastId].getSelectedRows(); var episodes = mod.episodeTables[podcastId].getSelectedRows();
AIRTIME.podcast.editSelectedEpisodes(episodes); AIRTIME.podcast.editSelectedEpisodes(episodes);
} },
}, },
validateConstraints: function () { validateConstraints: function () {
return checkSelectedEpisodeImportStatus.call(this, true); return checkSelectedEpisodeImportStatus.call(this, true);
},
} }
}); );
$.extend(true, podcastEpisodeButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.DELETE], $.extend(
true,
podcastEpisodeButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.DELETE],
{ {
eventHandlers: { eventHandlers: {
click: function () { click: function () {
var data = [], episodes = mod.episodeTables[podcastId].getSelectedRows(); var data = [],
episodes = mod.episodeTables[podcastId].getSelectedRows();
$.each(episodes, function () { $.each(episodes, function () {
data.push({ id: this.file.id, type: this.file.ftype }); data.push({ id: this.file.id, type: this.file.ftype });
}); });
AIRTIME.podcast.deleteSelectedEpisodes(data, podcastId); AIRTIME.podcast.deleteSelectedEpisodes(data, podcastId);
} },
}, },
validateConstraints: function () { validateConstraints: function () {
return checkSelectedEpisodeImportStatus.call(this, true); return checkSelectedEpisodeImportStatus.call(this, true);
},
} }
}); );
// Reassign these because integer keys take precedence in iteration order - we want to order based on insertion // Reassign these because integer keys take precedence in iteration order - we want to order based on insertion
// FIXME: this is a pretty flimsy way to try to set up iteration order (possibly not xbrowser compatible?) // FIXME: this is a pretty flimsy way to try to set up iteration order (possibly not xbrowser compatible?)
podcastEpisodeButtons = { podcastEpisodeButtons = {
newBtn : podcastEpisodeButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.NEW], newBtn:
editBtn: podcastEpisodeButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.EDIT], podcastEpisodeButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.NEW],
delBtn : podcastEpisodeButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.DELETE] editBtn:
podcastEpisodeButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.EDIT],
delBtn:
podcastEpisodeButtons[
AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.DELETE
],
}; };
$.extend(true, podcastEpisodeButtons, { $.extend(true, podcastEpisodeButtons, {
addToScheduleBtn: { addToScheduleBtn: {
title : $.i18n._('Add to Schedule'), title: $.i18n._("Add to Schedule"),
iconClass : 'icon-plus', iconClass: "icon-plus",
extraBtnClass : 'btn-small', extraBtnClass: "btn-small",
elementId : '', elementId: "",
eventHandlers: { eventHandlers: {
click: function () { click: function () {
var data = [], selected = AIRTIME.podcast.episodeTables[podcastId].getSelectedRows(); var data = [],
$.each(selected, function () { data.push(this.file); }); selected =
AIRTIME.podcast.episodeTables[podcastId].getSelectedRows();
$.each(selected, function () {
data.push(this.file);
});
AIRTIME.library.addToSchedule(data); AIRTIME.library.addToSchedule(data);
} },
}, },
validateConstraints: function () { validateConstraints: function () {
// TODO: change text + behaviour for playlists, smart blocks, etc. // TODO: change text + behaviour for playlists, smart blocks, etc.
return checkSelectedEpisodeImportStatus.call(this, true); return checkSelectedEpisodeImportStatus.call(this, true);
} },
}, },
viewDescBtn: { viewDescBtn: {
title: $.i18n._("View"), title: $.i18n._("View"),
@ -709,12 +854,12 @@ var AIRTIME = (function (AIRTIME) {
eventHandlers: { eventHandlers: {
click: function () { click: function () {
AIRTIME.library.openPodcastEpisodeDialog(podcastId); AIRTIME.library.openPodcastEpisodeDialog(podcastId);
} },
}, },
validateConstraints: function () { validateConstraints: function () {
return this.getSelectedRows().length == 1; return this.getSelectedRows().length == 1;
} },
} },
}); });
mod.episodeTables[podcastId] = AIRTIME.podcast.initPodcastEpisodeDatatable( mod.episodeTables[podcastId] = AIRTIME.podcast.initPodcastEpisodeDatatable(
@ -725,10 +870,16 @@ var AIRTIME = (function (AIRTIME) {
hideIngestCheckboxes: false, hideIngestCheckboxes: false,
emptyPlaceholder: { emptyPlaceholder: {
iconClass: "icon-white icon-th-list", iconClass: "icon-white icon-th-list",
html: $.i18n._("This podcast doesn't have any episodes!") html:
+ "<br/>" + $.i18n._("Make sure the RSS feed contains audio items (with enclosure tags).") $.i18n._("This podcast doesn't have any episodes!") +
+ "<br/><a target='_blank' href='http://www.apple.com/ca/itunes/podcasts/specs.html'>" + $.i18n._("Learn about podcasts") + "</a>" "<br/>" +
} $.i18n._(
"Make sure the RSS feed contains audio items (with enclosure tags)."
) +
"<br/><a target='_blank' href='http://www.apple.com/ca/itunes/podcasts/specs.html'>" +
$.i18n._("Learn about podcasts") +
"</a>",
},
} }
); );
@ -738,8 +889,12 @@ var AIRTIME = (function (AIRTIME) {
if (!$.isEmptyObject(data.file)) { if (!$.isEmptyObject(data.file)) {
mod.dblClickAdd(data.file, data.file.ftype); mod.dblClickAdd(data.file, data.file.ftype);
} else { } else {
if (data.ingested >= 0) { // Only import if the file isn't pending if (data.ingested >= 0) {
AIRTIME.podcast.importSelectedEpisodes([data], mod.episodeTables[podcastId]); // Only import if the file isn't pending
AIRTIME.podcast.importSelectedEpisodes(
[data],
mod.episodeTables[podcastId]
);
} }
} }
}); });
@ -759,16 +914,56 @@ var AIRTIME = (function (AIRTIME) {
* *
* @returns {Table} the created Table object * @returns {Table} the created Table object
*/ */
mod.initPodcastEpisodeDatatable = function (domNode, params, buttons, config) { mod.initPodcastEpisodeDatatable = function (
domNode,
params,
buttons,
config
) {
params = $.extend(true, params, { params = $.extend(true, params, {
aoColumns: [ aoColumns: [
/* GUID */ { "sTitle" : "" , "mDataProp" : "guid" , "sClass" : "podcast_episodes_guid" , "bVisible" : false }, /* GUID */ {
/* Ingested */ { "sTitle" : $.i18n._("Imported?") , "mDataProp" : "importIcon" , "sClass" : "podcast_episodes_imported" , "sWidth" : "120px" }, sTitle: "",
/* Title */ { "sTitle" : $.i18n._("Title") , "mDataProp" : "title" , "sClass" : "podcast_episodes_title" , "sWidth" : "170px" }, mDataProp: "guid",
/* Author */ { "sTitle" : $.i18n._("Author") , "mDataProp" : "author" , "sClass" : "podcast_episodes_author" , "sWidth" : "170px" }, sClass: "podcast_episodes_guid",
/* Description */ { "sTitle" : $.i18n._("Description") , "mDataProp" : "description" , "sClass" : "podcast_episodes_description" , "sWidth" : "300px" }, bVisible: false,
/* Link */ { "sTitle" : $.i18n._("Link") , "mDataProp" : "link" , "sClass" : "podcast_episodes_link" , "sWidth" : "170px" }, },
/* Publication Date */ { "sTitle" : $.i18n._("Publication Date") , "mDataProp" : "pub_date" , "sClass" : "podcast_episodes_pub_date" , "sWidth" : "170px" } /* Ingested */ {
sTitle: $.i18n._("Imported?"),
mDataProp: "importIcon",
sClass: "podcast_episodes_imported",
sWidth: "120px",
},
/* Title */ {
sTitle: $.i18n._("Title"),
mDataProp: "title",
sClass: "podcast_episodes_title",
sWidth: "170px",
},
/* Author */ {
sTitle: $.i18n._("Author"),
mDataProp: "author",
sClass: "podcast_episodes_author",
sWidth: "170px",
},
/* Description */ {
sTitle: $.i18n._("Description"),
mDataProp: "description",
sClass: "podcast_episodes_description",
sWidth: "300px",
},
/* Link */ {
sTitle: $.i18n._("Link"),
mDataProp: "link",
sClass: "podcast_episodes_link",
sWidth: "170px",
},
/* Publication Date */ {
sTitle: $.i18n._("Publication Date"),
mDataProp: "pub_date",
sClass: "podcast_episodes_pub_date",
sWidth: "170px",
},
], ],
bServerSide: false, bServerSide: false,
sAjaxSource: null, sAjaxSource: null,
@ -778,39 +973,63 @@ var AIRTIME = (function (AIRTIME) {
oColVis: { oColVis: {
buttonText: $.i18n._("Columns"), buttonText: $.i18n._("Columns"),
iOverlayFade: 0, iOverlayFade: 0,
aiExclude: [0, 1, 2] aiExclude: [0, 1, 2],
}, },
bDeferRender: true, bDeferRender: true,
oColReorder: { oColReorder: {
iFixedColumns: 3 // Checkbox + imported iFixedColumns: 3, // Checkbox + imported
}, },
fnCreatedRow: function (nRow, aData, iDataIndex) { fnCreatedRow: function (nRow, aData, iDataIndex) {
var self = this; var self = this;
if (aData.file && Object.keys(aData.file).length > 0) { if (aData.file && Object.keys(aData.file).length > 0) {
$(nRow).draggable({ $(nRow).draggable({
helper: function () { helper: function () {
var $row = $(this), data = self._datatable.fnGetData(nRow); var $row = $(this),
data = self._datatable.fnGetData(nRow);
$row.data("aData", data.file); $row.data("aData", data.file);
self.selectRow(this, data, self.SELECTION_MODE.SINGLE, $row.index()); self.selectRow(
var selected = self.getSelectedRows().length, container, this,
width = self._$wrapperDOMNode.closest(".dataTables_wrapper").outerWidth(), message; data,
self.SELECTION_MODE.SINGLE,
$row.index()
);
var selected = self.getSelectedRows().length,
container,
width = self._$wrapperDOMNode
.closest(".dataTables_wrapper")
.outerWidth(),
message;
message = sprintf($.i18n._(selected > 1 ? "Adding %s Items" : "Adding %s Item"), selected); message = sprintf(
container = $('<div/>').attr('id', 'draggingContainer').append('<tr/>') $.i18n._(selected > 1 ? "Adding %s Items" : "Adding %s Item"),
.find("tr").append('<td/>').find("td") selected
.attr("colspan", 100).width(width).css("max-width", "none") );
.addClass("ui-state-highlight").append(message).end().end(); container = $("<div/>")
.attr("id", "draggingContainer")
.append("<tr/>")
.find("tr")
.append("<td/>")
.find("td")
.attr("colspan", 100)
.width(width)
.css("max-width", "none")
.addClass("ui-state-highlight")
.append(message)
.end()
.end();
return container; return container;
}, },
tolerance: 'pointer', tolerance: "pointer",
cursor: 'move', cursor: "move",
cursorAt: { cursorAt: {
top: 20, top: 20,
left: Math.floor(self._datatable.outerWidth() / 2) left: Math.floor(self._datatable.outerWidth() / 2),
}, },
distance: 25, // min-distance for dragging distance: 25, // min-distance for dragging
connectToSortable: $("#show_builder_table, .active-tab .spl_sortable") connectToSortable: $(
"#show_builder_table, .active-tab .spl_sortable"
),
}); });
} }
}, },
@ -818,11 +1037,15 @@ var AIRTIME = (function (AIRTIME) {
AIRTIME.library.drawEmptyPlaceholder(this); AIRTIME.library.drawEmptyPlaceholder(this);
// Hide the processing div // Hide the processing div
var dt = this.getDatatable(); var dt = this.getDatatable();
!dt || dt.closest(".dataTables_wrapper").find(".dataTables_processing").css("visibility", "hidden"); !dt ||
} dt
.closest(".dataTables_wrapper")
.find(".dataTables_processing")
.css("visibility", "hidden");
},
}); });
if (typeof PodcastEpisodeTable === 'undefined') { if (typeof PodcastEpisodeTable === "undefined") {
_initPodcastEpisodeTable(); _initPodcastEpisodeTable();
} }
@ -839,7 +1062,7 @@ var AIRTIME = (function (AIRTIME) {
}; };
return AIRTIME; return AIRTIME;
}(AIRTIME || {})); })(AIRTIME || {});
$(document).ready(function () { $(document).ready(function () {
$(document).on("submit", "#podcast_url_form", function (e) { $(document).on("submit", "#podcast_url_form", function (e) {

View File

@ -1,4 +1,3 @@
var AIRTIME = (function (AIRTIME) { var AIRTIME = (function (AIRTIME) {
var mod; var mod;
@ -8,13 +7,14 @@ var AIRTIME = (function (AIRTIME) {
mod = AIRTIME.publish; mod = AIRTIME.publish;
var endpoint = 'rest/media/'; var endpoint = "rest/media/";
var dialogUrl = 'library/publish-dialog'; var dialogUrl = "library/publish-dialog";
var PUBLISH_APP_NAME = 'publish'; var PUBLISH_APP_NAME = "publish";
//AngularJS app //AngularJS app
var publishApp = angular.module(PUBLISH_APP_NAME, []) var publishApp = angular
.controller('Publish', function ($sce, $scope, $http, mediaId, tab) { .module(PUBLISH_APP_NAME, [])
.controller("Publish", function ($sce, $scope, $http, mediaId, tab) {
$scope.publishData = {}; $scope.publishData = {};
var sourceInterval; var sourceInterval;
@ -30,7 +30,8 @@ var AIRTIME = (function (AIRTIME) {
function fetchSourceData() { function fetchSourceData() {
var csrfToken = jQuery("#csrf").val(); var csrfToken = jQuery("#csrf").val();
$http.get(endpoint + mediaId, {csrf_token: csrfToken}) $http
.get(endpoint + mediaId, { csrf_token: csrfToken })
.success(function (json) { .success(function (json) {
$scope.media = json; $scope.media = json;
tab.setName($scope.media.track_title); tab.setName($scope.media.track_title);
@ -38,7 +39,10 @@ var AIRTIME = (function (AIRTIME) {
// Get an object containing all sources, their translated labels, // Get an object containing all sources, their translated labels,
// and their publication state for the file with the given ID // and their publication state for the file with the given ID
$http.get(endpoint + mediaId + '/publish-sources', {csrf_token: csrfToken}) $http
.get(endpoint + mediaId + "/publish-sources", {
csrf_token: csrfToken,
})
.success(function (json) { .success(function (json) {
$scope.sources = { toPublish: [], published: [] }; $scope.sources = { toPublish: [], published: [] };
$.each(json, function () { $.each(json, function () {
@ -63,24 +67,31 @@ var AIRTIME = (function (AIRTIME) {
}); });
} }
$scope.openEditDialog = function () { $scope.openEditDialog = function () {
var uid = AIRTIME.library.MediaTypeStringEnum.FILE + "_" + mediaId; var uid = AIRTIME.library.MediaTypeStringEnum.FILE + "_" + mediaId;
$.get(baseUrl + "library/edit-file-md/id/" + mediaId, {format: "json"}, function (json) { $.get(
baseUrl + "library/edit-file-md/id/" + mediaId,
{ format: "json" },
function (json) {
AIRTIME.playlist.fileMdEdit(json, uid); AIRTIME.playlist.fileMdEdit(json, uid);
}); }
);
}; };
$scope.publish = function () { $scope.publish = function () {
var data = {}; var data = {};
jQuery.each($scope.publishData, function (k, v) { jQuery.each($scope.publishData, function (k, v) {
if (v) { if (v) {
data[k] = 'publish'; // FIXME: should be more robust data[k] = "publish"; // FIXME: should be more robust
} }
}); });
if (data && Object.keys(data).length > 0) { if (data && Object.keys(data).length > 0) {
$http.put(endpoint + mediaId + '/publish', {csrf_token: jQuery("#csrf").val(), sources: data}) $http
.put(endpoint + mediaId + "/publish", {
csrf_token: jQuery("#csrf").val(),
sources: data,
})
.success(function () { .success(function () {
tab.contents.find(".publish-btn").prop("disabled", true); tab.contents.find(".publish-btn").prop("disabled", true);
fetchSourceData(); fetchSourceData();
@ -92,8 +103,12 @@ var AIRTIME = (function (AIRTIME) {
$scope.remove = function (source) { $scope.remove = function (source) {
var data = {}; var data = {};
data[source] = 'unpublish'; // FIXME: should be more robust data[source] = "unpublish"; // FIXME: should be more robust
$http.put(endpoint + mediaId + '/publish', {csrf_token: jQuery("#csrf").val(), sources: data}) $http
.put(endpoint + mediaId + "/publish", {
csrf_token: jQuery("#csrf").val(),
sources: data,
})
.success(function () { .success(function () {
fetchSourceData(); fetchSourceData();
}); });
@ -107,7 +122,6 @@ var AIRTIME = (function (AIRTIME) {
init(); init();
}); });
/* /*
var selected = $("#podcast_table").find(".selected"), var selected = $("#podcast_table").find(".selected"),
ids = []; ids = [];
@ -117,8 +131,8 @@ var AIRTIME = (function (AIRTIME) {
});*/ });*/
function _bootstrapAngularApp(mediaId, tab) { function _bootstrapAngularApp(mediaId, tab) {
publishApp.value('mediaId', mediaId); publishApp.value("mediaId", mediaId);
publishApp.value('tab', tab); publishApp.value("tab", tab);
var wrapper = AIRTIME.tabs.getActiveTab().contents.find(".angular_wrapper"); var wrapper = AIRTIME.tabs.getActiveTab().contents.find(".angular_wrapper");
angular.bootstrap(wrapper.get(0), [PUBLISH_APP_NAME]); angular.bootstrap(wrapper.get(0), [PUBLISH_APP_NAME]);
} }
@ -138,14 +152,17 @@ var AIRTIME = (function (AIRTIME) {
}); });
}); });
});*/ });*/
}; };
mod.openPublishDialog = function (mediaId) { mod.openPublishDialog = function (mediaId) {
jQuery
jQuery.get(dialogUrl, { csrf_token: jQuery("#csrf").val() }) .get(dialogUrl, { csrf_token: jQuery("#csrf").val() })
.success(function (html) { .success(function (html) {
var tab = AIRTIME.tabs.openTab(html, PUBLISH_APP_NAME+"_"+mediaId, null); var tab = AIRTIME.tabs.openTab(
html,
PUBLISH_APP_NAME + "_" + mediaId,
null
);
_bootstrapAngularApp(mediaId, tab); _bootstrapAngularApp(mediaId, tab);
}); });
@ -165,4 +182,4 @@ var AIRTIME = (function (AIRTIME) {
}; };
return AIRTIME; return AIRTIME;
}(AIRTIME || {})); })(AIRTIME || {});

File diff suppressed because it is too large Load Diff

View File

@ -1,20 +1,25 @@
$(document).ready(function () { $(document).ready(function () {
listenerstat_content = $("#listenerstat_content") listenerstat_content = $("#listenerstat_content");
dateStartId = "#his_date_start", (dateStartId = "#his_date_start"),
timeStartId = "#his_time_start", (timeStartId = "#his_time_start"),
dateEndId = "#his_date_end", (dateEndId = "#his_date_end"),
timeEndId = "#his_time_end"; (timeEndId = "#his_time_end");
// set width dynamically // set width dynamically
var width = $("#listenerstat_content").width(); var width = $("#listenerstat_content").width();
width = width * .91; width = width * 0.91;
$("#listenerstat_content").find("#flot_placeholder").width(width); $("#listenerstat_content").find("#flot_placeholder").width(width);
$("#listenerstat_content").find("#legend").width(width); $("#listenerstat_content").find("#legend").width(width);
getDataAndPlot(); getDataAndPlot();
listenerstat_content.find("#his_submit").click(function () { listenerstat_content.find("#his_submit").click(function () {
var oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId); var oRange = AIRTIME.utilities.fnGetScheduleRange(
dateStartId,
timeStartId,
dateEndId,
timeEndId
);
var start = oRange.start; var start = oRange.start;
var end = oRange.end; var end = oRange.end;
getDataAndPlot(start, end); getDataAndPlot(start, end);
@ -25,7 +30,7 @@ $(document).ready(function() {
* Toggle a spinner overlay so the user knows the page is processing * Toggle a spinner overlay so the user knows the page is processing
*/ */
function toggleOverlay() { function toggleOverlay() {
$('#flot_placeholder').toggleClass('processing'); $("#flot_placeholder").toggleClass("processing");
} }
function getDataAndPlot(startTimestamp, endTimestamp) { function getDataAndPlot(startTimestamp, endTimestamp) {
@ -33,7 +38,10 @@ function getDataAndPlot(startTimestamp, endTimestamp) {
toggleOverlay(); toggleOverlay();
// get data // get data
$.get(baseUrl+'Listenerstat/get-data', {start: startTimestamp, end: endTimestamp}, function(data){ $.get(
baseUrl + "Listenerstat/get-data",
{ start: startTimestamp, end: endTimestamp },
function (data) {
out = new Object(); out = new Object();
$.each(data, function (mpName, v) { $.each(data, function (mpName, v) {
plotData = new Object(); plotData = new Object();
@ -43,105 +51,122 @@ function getDataAndPlot(startTimestamp, endTimestamp) {
var d = new Date(0); var d = new Date(0);
d.setUTCSeconds(ele.timestamp); d.setUTCSeconds(ele.timestamp);
plotData.data.push([d, ele.listener_count]); plotData.data.push([d, ele.listener_count]);
}) });
out[mpName] = plotData; out[mpName] = plotData;
}); });
plot(out); plot(out);
// Turn off the processing overlay // Turn off the processing overlay
toggleOverlay(); toggleOverlay();
}) }
);
} }
function plot(datasets) { function plot(datasets) {
var plot; var plot;
data = null; data = null;
function plotByChoice(doAll) function plotByChoice(doAll) {
{
// largest date object that you can set // largest date object that you can set
firstTimestamp = new Date(8640000000000000); firstTimestamp = new Date(8640000000000000);
// smallest // smallest
lastTimestamp = new Date(0); lastTimestamp = new Date(0);
data = []; data = [];
if (doAll != null) if (doAll != null) {
{
$.each(datasets, function (key, val) { $.each(datasets, function (key, val) {
if (firstTimestamp.getTime() > val.data[0][0].getTime()) { if (firstTimestamp.getTime() > val.data[0][0].getTime()) {
firstTimestamp = val.data[0][0]; firstTimestamp = val.data[0][0];
} }
if (lastTimestamp.getTime() < val.data[val.data.length-1][0].getTime()) { if (
lastTimestamp.getTime() < val.data[val.data.length - 1][0].getTime()
) {
lastTimestamp = val.data[val.data.length - 1][0]; lastTimestamp = val.data[val.data.length - 1][0];
} }
data.push(val); data.push(val);
}); });
} } else {
else $("#legend .legendCB").each(function () {
{ if (this.checked) {
$('#legend .legendCB').each(
function(){
if (this.checked)
{
data.push(datasets[this.id]); data.push(datasets[this.id]);
if (firstTimestamp.getTime() > datasets[this.id].data[0][0].getTime()) { if (
firstTimestamp.getTime() > datasets[this.id].data[0][0].getTime()
) {
firstTimestamp = datasets[this.id].data[0][0]; firstTimestamp = datasets[this.id].data[0][0];
} }
if (lastTimestamp.getTime() < datasets[this.id].data[datasets[this.id].data.length-1][0].getTime()) { if (
lastTimestamp = datasets[this.id].data[datasets[this.id].data.length-1][0]; lastTimestamp.getTime() <
datasets[this.id].data[
datasets[this.id].data.length - 1
][0].getTime()
) {
lastTimestamp =
datasets[this.id].data[datasets[this.id].data.length - 1][0];
} }
} else {
data.push({ label: this.id, data: [] });
} }
else });
{
data.push({label: this.id, data: []})
}
}
);
} }
numOfTicks = 10; numOfTicks = 10;
tickSize = (lastTimestamp.getTime() - firstTimestamp.getTime())/1000/numOfTicks; tickSize =
(lastTimestamp.getTime() - firstTimestamp.getTime()) / 1000 / numOfTicks;
plot = $.plot($("#flot_placeholder"), data, { plot = $.plot($("#flot_placeholder"), data, {
yaxis: { min: 0, tickDecimals: 0, color: '#d6d6d6', tickColor: '#d6d6d6' }, yaxis: {
xaxis: { mode: "time", timeformat:"%y/%m/%0d %H:%M", tickSize: [tickSize, "second"], min: 0,
color: '#d6d6d6', tickColor: '#d6d6d6' }, tickDecimals: 0,
color: "#d6d6d6",
tickColor: "#d6d6d6",
},
xaxis: {
mode: "time",
timeformat: "%y/%m/%0d %H:%M",
tickSize: [tickSize, "second"],
color: "#d6d6d6",
tickColor: "#d6d6d6",
},
grid: { grid: {
hoverable: true, hoverable: true,
backgroundColor: { colors: ["#333", "#555"] } backgroundColor: { colors: ["#333", "#555"] },
}, },
series: { series: {
lines: { lines: {
show: true, show: true,
fill: 0.3 fill: 0.3,
}, },
points: { show: true } points: { show: true },
}, },
legend: { legend: {
container: $('#legend'), container: $("#legend"),
noColumns: 5, noColumns: 5,
color: '#c0c0c0', color: "#c0c0c0",
labelFormatter: function (label, series) { labelFormatter: function (label, series) {
var cb = '<input style="float:left;" class="legendCB" type="checkbox" '; var cb =
'<input style="float:left;" class="legendCB" type="checkbox" ';
if (series.data.length > 0) { if (series.data.length > 0) {
cb += 'checked="true" '; cb += 'checked="true" ';
} }
cb += 'id="' + label + '" /> '; cb += 'id="' + label + '" /> ';
cb += label; cb += label;
return cb; return cb;
} },
} },
}); });
function showTooltip(x, y, contents) { function showTooltip(x, y, contents) {
$('<div id="tooltip">' + contents + '</div>').css( { $('<div id="tooltip">' + contents + "</div>")
position: 'absolute', .css({
display: 'none', position: "absolute",
display: "none",
top: y + 5, top: y + 5,
left: x + 5, left: x + 5,
border: '1px solid #fdd', border: "1px solid #fdd",
padding: '2px', padding: "2px",
'background-color': '#fee', "background-color": "#fee",
opacity: 0.80 opacity: 0.8,
}).appendTo("body").fadeIn(200); })
.appendTo("body")
.fadeIn(200);
} }
var previousPoint = null; var previousPoint = null;
@ -153,28 +178,38 @@ function plot(datasets){
$("#tooltip").remove(); $("#tooltip").remove();
var y = item.datapoint[1].toFixed(2); var y = item.datapoint[1].toFixed(2);
showTooltip(item.pageX, item.pageY, showTooltip(
sprintf($.i18n._("Listener Count on %s: %s"), item.series.label, Math.floor(y))); item.pageX,
item.pageY,
sprintf(
$.i18n._("Listener Count on %s: %s"),
item.series.label,
Math.floor(y)
)
);
} }
} } else {
else {
$("#tooltip").remove(); $("#tooltip").remove();
previousPoint = null; previousPoint = null;
} }
}); });
$('#legend').find("input").click(function(){setTimeout(plotByChoice,100);}); $("#legend")
.find("input")
.click(function () {
setTimeout(plotByChoice, 100);
});
} }
plotByChoice(true); plotByChoice(true);
oBaseDatePickerSettings = { oBaseDatePickerSettings = {
dateFormat: 'yy-mm-dd', dateFormat: "yy-mm-dd",
//i18n_months, i18n_days_short are in common.js //i18n_months, i18n_days_short are in common.js
monthNames: i18n_months, monthNames: i18n_months,
dayNamesMin: i18n_days_short, dayNamesMin: i18n_days_short,
onSelect: function (sDate, oDatePicker) { onSelect: function (sDate, oDatePicker) {
$(this).datepicker("setDate", sDate); $(this).datepicker("setDate", sDate);
} },
}; };
oBaseTimePickerSettings = { oBaseTimePickerSettings = {
@ -182,9 +217,9 @@ function plot(datasets){
showCloseButton: true, showCloseButton: true,
closeButtonText: $.i18n._("Done"), closeButtonText: $.i18n._("Done"),
showLeadingZero: false, showLeadingZero: false,
defaultTime: '0:00', defaultTime: "0:00",
hourText: $.i18n._("Hour"), hourText: $.i18n._("Hour"),
minuteText: $.i18n._("Minute") minuteText: $.i18n._("Minute"),
}; };
listenerstat_content.find(dateStartId).datepicker(oBaseDatePickerSettings); listenerstat_content.find(dateStartId).datepicker(oBaseDatePickerSettings);

View File

@ -1,19 +1,24 @@
$(document).ready(function () { $(document).ready(function () {
showlistenerstat_content = $("#showlistenerstat_content") showlistenerstat_content = $("#showlistenerstat_content");
dateStartId = "#his_date_start", (dateStartId = "#his_date_start"),
timeStartId = "#his_time_start", (timeStartId = "#his_time_start"),
dateEndId = "#his_date_end", (dateEndId = "#his_date_end"),
timeEndId = "#his_time_end", (timeEndId = "#his_time_end"),
show_id = "#his_show_filter"; (show_id = "#his_show_filter");
// set width dynamically // set width dynamically
var width = $("#showlistenerstat_content").width(); var width = $("#showlistenerstat_content").width();
width = width * .91; width = width * 0.91;
addDatePicker(); addDatePicker();
showlistenerstat_content.find("#his_submit").click(function () { showlistenerstat_content.find("#his_submit").click(function () {
// var show_id = $("#sb_show_filter").val(); // var show_id = $("#sb_show_filter").val();
var oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId); var oRange = AIRTIME.utilities.fnGetScheduleRange(
dateStartId,
timeStartId,
dateEndId,
timeEndId
);
var start = oRange.start; var start = oRange.start;
var end = oRange.end; var end = oRange.end;
showListenerDataTable(); showListenerDataTable();
@ -22,105 +27,144 @@ $(document).ready(function() {
function getShowData(startTimestamp, endTimestamp, show_id) { function getShowData(startTimestamp, endTimestamp, show_id) {
// get data // get data
$.get(baseUrl+'Listenerstat/get-all-show-data', {start: startTimestamp, end: endTimestamp }, function(data) { $.get(
baseUrl + "Listenerstat/get-all-show-data",
{ start: startTimestamp, end: endTimestamp },
function (data) {
return data; return data;
}); }
);
} }
function addDatePicker() { function addDatePicker() {
oBaseDatePickerSettings = { oBaseDatePickerSettings = {
dateFormat: 'yy-mm-dd', dateFormat: "yy-mm-dd",
//i18n_months, i18n_days_short are in common.js //i18n_months, i18n_days_short are in common.js
monthNames: i18n_months, monthNames: i18n_months,
dayNamesMin: i18n_days_short, dayNamesMin: i18n_days_short,
onSelect: function (sDate, oDatePicker) { onSelect: function (sDate, oDatePicker) {
$(this).datepicker("setDate", sDate); $(this).datepicker("setDate", sDate);
}, },
onClose: validateTimeRange onClose: validateTimeRange,
}; };
oBaseTimePickerSettings = { oBaseTimePickerSettings = {
showPeriodLabels: false, showPeriodLabels: false,
showCloseButton: true, showCloseButton: true,
closeButtonText: $.i18n._("Done"), closeButtonText: $.i18n._("Done"),
showLeadingZero: false, showLeadingZero: false,
defaultTime: '0:00', defaultTime: "0:00",
hourText: $.i18n._("Hour"), hourText: $.i18n._("Hour"),
minuteText: $.i18n._("Minute"), minuteText: $.i18n._("Minute"),
onClose: validateTimeRange onClose: validateTimeRange,
}; };
showlistenerstat_content.find(dateStartId).datepicker(oBaseDatePickerSettings).blur(validateTimeRange()); showlistenerstat_content
showlistenerstat_content.find(timeStartId).timepicker(oBaseTimePickerSettings).blur(validateTimeRange()); .find(dateStartId)
showlistenerstat_content.find(dateEndId).datepicker(oBaseDatePickerSettings).blur(validateTimeRange()); .datepicker(oBaseDatePickerSettings)
showlistenerstat_content.find(timeEndId).timepicker(oBaseTimePickerSettings).blur(validateTimeRange()); .blur(validateTimeRange());
showlistenerstat_content
.find(timeStartId)
.timepicker(oBaseTimePickerSettings)
.blur(validateTimeRange());
showlistenerstat_content
.find(dateEndId)
.datepicker(oBaseDatePickerSettings)
.blur(validateTimeRange());
showlistenerstat_content
.find(timeEndId)
.timepicker(oBaseTimePickerSettings)
.blur(validateTimeRange());
} }
function getStartEnd() { function getStartEnd() {
return AIRTIME.utilities.fnGetScheduleRange(
return AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId); dateStartId,
timeStartId,
dateEndId,
timeEndId
);
} }
function validateTimeRange() { function validateTimeRange() {
var oRange, var oRange,
inputs = $('.date_form > input'), inputs = $(".date_form > input"),
error_window = $('.error_window'), error_window = $(".error_window"),
start, end; start,
end;
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId); oRange = AIRTIME.utilities.fnGetScheduleRange(
dateStartId,
timeStartId,
dateEndId,
timeEndId
);
start = oRange.start; start = oRange.start;
end = oRange.end; end = oRange.end;
if (end >= start) { if (end >= start) {
error_window.removeClass('error'); error_window.removeClass("error");
$('.error_window').html(''); $(".error_window").html("");
} } else {
else { error_window.addClass("error");
error_window.addClass('error'); console.log("bad");
console.log('bad') $(".error_window").html("Your start date time is after your end date time");
$('.error_window').html('Your start date time is after your end date time');
} }
return { return {
start: start, start: start,
end: end, end: end,
isValid: end >= start isValid: end >= start,
}; };
} }
function showListenerDataTable() { function showListenerDataTable() {
var oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateEndId, timeEndId); var oRange = AIRTIME.utilities.fnGetScheduleRange(
dateStartId,
timeStartId,
dateEndId,
timeEndId
);
var start = oRange.start; var start = oRange.start;
var lengthMenu = [[10, 25, 50, 100, 500, -1], [10, 25, 50, 100, 500, $.i18n._("All")]]; var lengthMenu = [
[10, 25, 50, 100, 500, -1],
[10, 25, 50, 100, 500, $.i18n._("All")],
];
var end = oRange.end; var end = oRange.end;
var sDom = 'l<"dt-process-rel"r><"H"T><"dataTables_scrolling"t><"F"ip>'; var sDom = 'l<"dt-process-rel"r><"H"T><"dataTables_scrolling"t><"F"ip>';
var show_id = $("#sb_show_filter").val(); var show_id = $("#sb_show_filter").val();
var dt = $('#show_stats_datatable'); var dt = $("#show_stats_datatable");
info = getStartEnd(); info = getStartEnd();
dt.dataTable({ dt.dataTable({
"aoColumns": [ aoColumns: [
/* first name */ {"sName": "show", "mDataProp": "show"}, /* first name */ { sName: "show", mDataProp: "show" },
/* air date */ {"sName": "time", "mDataProp": "time"}, /* air date */ { sName: "time", mDataProp: "time" },
/* last name */ {"sName": "average_number_of_listeners", "mDataProp": "average_number_of_listeners"}, /* last name */ {
/* last name */ {"sName": "maximum_number_of_listeners", "mDataProp": "maximum_number_of_listeners"}], sName: "average_number_of_listeners",
"sAjaxSource": baseUrl+'Listenerstat/get-all-show-data', mDataProp: "average_number_of_listeners",
"sAjaxDataProp": "", },
"bDestroy": true, /* last name */ {
"aLengthMenu": lengthMenu, sName: "maximum_number_of_listeners",
"iDisplayLength": 25, mDataProp: "maximum_number_of_listeners",
"sPaginationType": "full_numbers", },
"bJQueryUI": true, ],
"bAutoWidth": true, sAjaxSource: baseUrl + "Listenerstat/get-all-show-data",
"sDom": sDom, sAjaxDataProp: "",
"fnServerData": function ( sSource, aoData, fnCallback ) { bDestroy: true,
aoData.push({"start": start, "end": end}); aLengthMenu: lengthMenu,
iDisplayLength: 25,
sPaginationType: "full_numbers",
bJQueryUI: true,
bAutoWidth: true,
sDom: sDom,
fnServerData: function (sSource, aoData, fnCallback) {
aoData.push({ start: start, end: end });
$.ajax({ $.ajax({
"dataType": 'json', dataType: "json",
"type": "POST", type: "POST",
"url": sSource, url: sSource,
"data": {"start": start, "end": end}, data: { start: start, end: end },
"success": fnCallback success: fnCallback,
}); });
}, },
}); });

View File

@ -4,6 +4,6 @@ $(window).load(function() {
$(document).ready(function () { $(document).ready(function () {
$("#submit").click(function () { $("#submit").click(function () {
Cookies.set('airtime_locale', $('#locale').val(), {path: '/'}); Cookies.set("airtime_locale", $("#locale").val(), { path: "/" });
}); });
}); });

View File

@ -1,5 +1,4 @@
$(document).ready(function () { $(document).ready(function () {
var dialog = $("#lang-timezone-popup"); var dialog = $("#lang-timezone-popup");
dialog.dialog({ dialog.dialog({
@ -8,8 +7,8 @@ $(document).ready(function() {
resizable: false, resizable: false,
modal: true, modal: true,
closeOnEscape: false, closeOnEscape: false,
position:['center','center'], position: ["center", "center"],
dialogClass: 'no-close', dialogClass: "no-close",
buttons: [ buttons: [
/* Testing removing the Not Now button for higher engagement /* Testing removing the Not Now button for higher engagement
{ {
@ -23,12 +22,12 @@ $(document).ready(function() {
{ {
id: "help_airtime", id: "help_airtime",
text: $.i18n._("OK"), text: $.i18n._("OK"),
"class": "btn", class: "btn",
click: function () { click: function () {
$("#lang-timezone-form").submit(); $("#lang-timezone-form").submit();
} },
} },
] ],
}); });
var language = window.navigator.userLanguage || window.navigator.language; var language = window.navigator.userLanguage || window.navigator.language;
@ -38,8 +37,8 @@ $(document).ready(function() {
language = language.replace("-", "_"); language = language.replace("-", "_");
$("#setup_language").val(language); $("#setup_language").val(language);
dayjs.extend(utc) dayjs.extend(utc);
dayjs.extend(timezone) dayjs.extend(timezone);
var timezone_name = dayjs.tz.guess(); var timezone_name = dayjs.tz.guess();
if (timezone_name === undefined) { if (timezone_name === undefined) {
@ -47,5 +46,5 @@ $(document).ready(function() {
} }
$("#setup_timezone").val(timezone_name); $("#setup_timezone").val(timezone_name);
dialog.dialog('open'); dialog.dialog("open");
}); });

View File

@ -1,7 +1,8 @@
$(document).ready(function () { $(document).ready(function () {
function doNotShowPopup() { function doNotShowPopup() {
$.get(baseUrl+"Usersettings/donotshowregistrationpopup", {format:"json"}); $.get(baseUrl + "Usersettings/donotshowregistrationpopup", {
format: "json",
});
} }
var dialog = $("#register_popup"); var dialog = $("#register_popup");
@ -11,82 +12,84 @@ $(document).ready(function(){
width: 500, width: 500,
resizable: false, resizable: false,
modal: true, modal: true,
position:['center',50], position: ["center", 50],
close: doNotShowPopup, close: doNotShowPopup,
buttons: [ buttons: [
{ {
id: "remind_me", id: "remind_me",
text: $.i18n._("Remind me in 1 week"), text: $.i18n._("Remind me in 1 week"),
"class": "btn", class: "btn",
click: function () { click: function () {
var url = baseUrl+'Usersettings/remindme'; var url = baseUrl + "Usersettings/remindme";
$.ajax({ $.ajax({
url: url, url: url,
data: {format:"json"} data: { format: "json" },
}); });
$(this).dialog("close"); $(this).dialog("close");
} },
}, },
{ {
id: "remind_never", id: "remind_never",
text: $.i18n._("Remind me never"), text: $.i18n._("Remind me never"),
"class": "btn", class: "btn",
click: function () { click: function () {
var url =baseUrl+'Usersettings/remindme-never'; var url = baseUrl + "Usersettings/remindme-never";
$.ajax({ $.ajax({
url: url, url: url,
data: {format:"json"} data: { format: "json" },
}); });
$(this).dialog("close"); $(this).dialog("close");
} },
}, },
{ {
id: "help_airtime", id: "help_airtime",
text: sprintf($.i18n._("Yes, help %s"), PRODUCT_NAME), text: sprintf($.i18n._("Yes, help %s"), PRODUCT_NAME),
"class": "btn", class: "btn",
click: function () { click: function () {
$("#register-form").submit(); $("#register-form").submit();
} },
} },
] ],
}); });
var button = $("#help_airtime"); var button = $("#help_airtime");
if ($("#link_to_terms_and_condition").length > 0) { if ($("#link_to_terms_and_condition").length > 0) {
button.removeAttr('disabled').removeClass('ui-state-disabled'); button.removeAttr("disabled").removeClass("ui-state-disabled");
} else { } else {
button.attr('disabled', 'disabled' ).addClass('ui-state-disabled'); button.attr("disabled", "disabled").addClass("ui-state-disabled");
} }
dialog.dialog('open'); dialog.dialog("open");
$(".collapsible-header")
$('.collapsible-header').live('click',function() { .live("click", function () {
$(this).next().toggle('fast'); $(this).next().toggle("fast");
$(this).toggleClass("close"); $(this).toggleClass("close");
return false; return false;
}).next().hide(); })
.next()
.hide();
$("#SupportFeedback").live('click', function(){ $("#SupportFeedback").live("click", function () {
var pub = $("#Publicise"); var pub = $("#Publicise");
var privacy = $("#Privacy"); var privacy = $("#Privacy");
var button = $("#help_airtime"); var button = $("#help_airtime");
if( !$(this).is(':checked') ){ if (!$(this).is(":checked")) {
pub.removeAttr("checked"); pub.removeAttr("checked");
pub.attr("disabled", true); pub.attr("disabled", true);
$("#public-info").hide(); $("#public-info").hide();
button.attr('disabled', 'disabled' ).addClass('ui-state-disabled'); button.attr("disabled", "disabled").addClass("ui-state-disabled");
} else { } else {
pub.removeAttr("disabled"); pub.removeAttr("disabled");
if(privacy.length == 0 || privacy.is(':checked')){ if (privacy.length == 0 || privacy.is(":checked")) {
button.removeAttr('disabled').removeClass('ui-state-disabled'); button.removeAttr("disabled").removeClass("ui-state-disabled");
} }
} }
}); });
var promote = $("#Publicise"); var promote = $("#Publicise");
promote.live('click', function(){ promote.live("click", function () {
if($(this).is(':checked')){ if ($(this).is(":checked")) {
$("#public-info").show(); $("#public-info").show();
} else { } else {
$("#public-info").hide(); $("#public-info").hide();
@ -96,28 +99,31 @@ $(document).ready(function(){
$("#public-info").show(); $("#public-info").show();
} }
$("#Privacy").live('click', function(){ $("#Privacy").live("click", function () {
var support = $("#SupportFeedback"); var support = $("#SupportFeedback");
var button = $("#help_airtime"); var button = $("#help_airtime");
if($(this).is(':checked') && support.is(':checked')){ if ($(this).is(":checked") && support.is(":checked")) {
button.removeAttr('disabled').removeClass('ui-state-disabled'); button.removeAttr("disabled").removeClass("ui-state-disabled");
} else { } else {
button.attr('disabled', 'disabled' ).addClass('ui-state-disabled'); button.attr("disabled", "disabled").addClass("ui-state-disabled");
} }
}); });
if($("#SupportFeedback").is(':checked') && ($("#Privacy").length == 0 || $("#Privacy").is(':checked'))){ if (
button.removeAttr('disabled').removeClass('ui-state-disabled'); $("#SupportFeedback").is(":checked") &&
($("#Privacy").length == 0 || $("#Privacy").is(":checked"))
) {
button.removeAttr("disabled").removeClass("ui-state-disabled");
} else { } else {
button.attr('disabled', 'disabled' ).addClass('ui-state-disabled'); button.attr("disabled", "disabled").addClass("ui-state-disabled");
} }
$('.toggle legend').live('click',function() { $(".toggle legend").live("click", function () {
$('.toggle').toggleClass('closed'); $(".toggle").toggleClass("closed");
return false; return false;
}); });
$("#Logo").live('change', function(ev){ $("#Logo").live("change", function (ev) {
var content, res, logoEl; var content, res, logoEl;
content = $(this).val(); content = $(this).val();
@ -128,24 +134,20 @@ $(document).ready(function(){
if (!res) { if (!res) {
var ul, li; var ul, li;
ul = logoEl.find('.errors'); ul = logoEl.find(".errors");
li = $("<li/>").append($.i18n._("Image must be one of jpg, jpeg, png, or gif")); li = $("<li/>").append(
$.i18n._("Image must be one of jpg, jpeg, png, or gif")
);
//errors ul has already been created. //errors ul has already been created.
if (ul.length > 0) { if (ul.length > 0) {
ul.empty() ul.empty().append(li);
.append(li); } else {
} logoEl.append('<ul class="errors"></ul>').find(".errors").append(li);
else {
logoEl
.append('<ul class="errors"></ul>')
.find(".errors")
.append(li);
} }
$(this).val(""); $(this).val("");
} } else {
else {
logoEl.find(".errors").remove(); logoEl.find(".errors").remove();
} }
}); });

View File

@ -1,5 +1,4 @@
function updateEmbedSrcParams() function updateEmbedSrcParams() {
{
var $embedCodeParams = "?"; var $embedCodeParams = "?";
var $streamMode = getStreamMode(); var $streamMode = getStreamMode();
if ($streamMode == "manual") { if ($streamMode == "manual") {
@ -11,7 +10,7 @@ function updateEmbedSrcParams()
$embedCodeParams += "&title=" + getPlayerTitle(); $embedCodeParams += "&title=" + getPlayerTitle();
$embedCodeParams += "\""; $embedCodeParams += '"';
$("textarea[name=player_embed_src]").val(function (index, value) { $("textarea[name=player_embed_src]").val(function (index, value) {
return value.replace(/\?.*?"/, $embedCodeParams); return value.replace(/\?.*?"/, $embedCodeParams);
@ -23,7 +22,7 @@ function updateEmbedSrcParams()
function updatePlayerIframeSrc(iframe_text) { function updatePlayerIframeSrc(iframe_text) {
var $player_iframe = $("#player_form iframe"); var $player_iframe = $("#player_form iframe");
var player_iframe_src = iframe_text.match(/http.*?"/)[0].slice(0, -1); var player_iframe_src = iframe_text.match(/http.*?"/)[0].slice(0, -1);
$player_iframe.attr('src', player_iframe_src); $player_iframe.attr("src", player_iframe_src);
} }
function getStreamMode() { function getStreamMode() {
@ -35,7 +34,6 @@ function getPlayerTitle() {
} }
$(document).ready(function () { $(document).ready(function () {
$("#player_stream_url-element").hide(); $("#player_stream_url-element").hide();
// stream mode change event // stream mode change event
@ -44,7 +42,6 @@ $(document).ready(function() {
if ($streamMode == "auto") { if ($streamMode == "auto") {
$("#player_stream_url-element").hide(); $("#player_stream_url-element").hide();
} else if ($streamMode == "manual") { } else if ($streamMode == "manual") {
$("#player_stream_url-element").show(); $("#player_stream_url-element").show();

View File

@ -2,18 +2,36 @@ function getRandomIdPlayer(max) {
return "playerHtml5Libretime_" + Math.floor(Math.random() * Math.floor(max)); return "playerHtml5Libretime_" + Math.floor(Math.random() * Math.floor(max));
} }
function playerhtml5_insert(settings) function playerhtml5_insert(settings) {
{ atp = "";
atp=''; if (settings.autoplay == true) atp = "autoplay";
if(settings.autoplay==true) atp='autoplay'; if (settings.forceHTTPS == true && settings.url.indexOf("https") == -1)
if(settings.forceHTTPS==true&&settings.url.indexOf('https')==-1) settings.url=settings.url.replace(/http/g, 'https'); settings.url = settings.url.replace(/http/g, "https");
if(settings.replacePort!=''&&settings.replacePort!=false&&settings.replacePort!='false') if (
{ settings.replacePort != "" &&
if(settings.replacePortTo!='') settings.replacePortTo=':'+settings.replacePortTo; settings.replacePort != false &&
settings.url=settings.url.replace(':'+settings.replacePort, settings.replacePortTo); settings.replacePort != "false"
) {
if (settings.replacePortTo != "")
settings.replacePortTo = ":" + settings.replacePortTo;
settings.url = settings.url.replace(
":" + settings.replacePort,
settings.replacePortTo
);
} }
if(settings.codec=='mp3') settings.codec='mpeg'; if (settings.codec == "mp3") settings.codec = "mpeg";
document.getElementById('html5player_skin').innerHTML += '<div id="div_'+settings.elementId+'" style="" ><audio loop controls id="'+settings.elementId+'" src="'+settings.url+'" '+atp+' type="audio/'+settings.codec+'" >' document.getElementById("html5player_skin").innerHTML +=
+'Ihr Browser unterstützt das Element <code>audio</code> nicht.' '<div id="div_' +
+'<\/audio><\/div>'; settings.elementId +
'" style="" ><audio loop controls id="' +
settings.elementId +
'" src="' +
settings.url +
'" ' +
atp +
' type="audio/' +
settings.codec +
'" >' +
"Ihr Browser unterstützt das Element <code>audio</code> nicht." +
"</audio></div>";
} }

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,6 @@ var AIRTIME = (function(AIRTIME) {
//config: name, type, filemd, required //config: name, type, filemd, required
function createTemplateLi(config) { function createTemplateLi(config) {
var templateRequired = var templateRequired =
"<li " + "<li " +
"data-name='<%= name %>' " + "data-name='<%= name %>' " +
@ -37,7 +36,8 @@ var AIRTIME = (function(AIRTIME) {
"<span class='template_item_remove'><i class='icon icon-trash'></i></span>" + "<span class='template_item_remove'><i class='icon icon-trash'></i></span>" +
"</li>"; "</li>";
var template = (config.required) === true ? templateRequired : templateOptional; var template =
config.required === true ? templateRequired : templateOptional;
template = _.template(template); template = _.template(template);
var $li = $(template(config)); var $li = $(template(config));
@ -49,8 +49,8 @@ var AIRTIME = (function(AIRTIME) {
//http://stackoverflow.com/questions/1349404/generate-a-string-of-5-random-characters-in-javascript //http://stackoverflow.com/questions/1349404/generate-a-string-of-5-random-characters-in-javascript
function randomString(len, charSet) { function randomString(len, charSet) {
//can only use small letters to avoid DB query problems. //can only use small letters to avoid DB query problems.
charSet = charSet || 'abcdefghijklmnopqrstuvwxyz'; charSet = charSet || "abcdefghijklmnopqrstuvwxyz";
var randomString = ''; var randomString = "";
for (var i = 0; i < len; i++) { for (var i = 0; i < len; i++) {
var randomPoz = Math.floor(Math.random() * charSet.length); var randomPoz = Math.floor(Math.random() * charSet.length);
randomString += charSet.substring(randomPoz, randomPoz + 1); randomString += charSet.substring(randomPoz, randomPoz + 1);
@ -59,36 +59,31 @@ var AIRTIME = (function(AIRTIME) {
} }
function addField(config) { function addField(config) {
$templateList.append(createTemplateLi(config)); $templateList.append(createTemplateLi(config));
} }
function getFieldData($el) { function getFieldData($el) {
return { return {
name: $el.data("name"), name: $el.data("name"),
type: $el.data("type"), type: $el.data("type"),
label: $el.data("label"), label: $el.data("label"),
isFileMd: $el.data("filemd") isFileMd: $el.data("filemd"),
}; };
} }
mod.onReady = function () { mod.onReady = function () {
$templateDiv = $("#configure_item_template"); $templateDiv = $("#configure_item_template");
$templateList = $(".template_item_list"); $templateList = $(".template_item_list");
$fileMDList = $(".template_file_md"); $fileMDList = $(".template_file_md");
$fileMDList.on("click", "i.icon-plus", function () { $fileMDList.on("click", "i.icon-plus", function () {
var $li = $(this).parents("li"); var $li = $(this).parents("li");
var config = { var config = {
name: $li.data("name"), name: $li.data("name"),
type: $li.data("type"), type: $li.data("type"),
label: $li.data("label"), label: $li.data("label"),
filemd: true, filemd: true,
required: false required: false,
}; };
addField(config); addField(config);
@ -116,7 +111,7 @@ var AIRTIME = (function(AIRTIME) {
label: label, label: label,
type: $div.find("select").val(), type: $div.find("select").val(),
filemd: false, filemd: false,
required: false required: false,
}; };
addField(config); addField(config);
@ -138,9 +133,18 @@ var AIRTIME = (function(AIRTIME) {
data[i] = getFieldData($li); data[i] = getFieldData($li);
} }
$.post(url, {'id': template_id, 'name': templateName, 'fields': data, 'setDefault': isDefault}, function(json) { $.post(
url,
{
id: template_id,
name: templateName,
fields: data,
setDefault: isDefault,
},
function (json) {
var x; var x;
}); }
);
} }
$templateDiv.on("click", "#template_item_save", function () { $templateDiv.on("click", "#template_item_save", function () {
@ -152,16 +156,15 @@ var AIRTIME = (function(AIRTIME) {
$templateDiv.on("click", "#template_set_default", function () { $templateDiv.on("click", "#template_set_default", function () {
var $btn = $(this), var $btn = $(this),
template_id = $btn.data("template"), template_id = $btn.data("template"),
url = baseUrl+"Playouthistorytemplate/set-template-default/format/json"; url =
baseUrl + "Playouthistorytemplate/set-template-default/format/json";
$btn.remove(); $btn.remove();
$.post(url, { id: template_id }); $.post(url, { id: template_id });
}); });
}; };
return AIRTIME; return AIRTIME;
})(AIRTIME || {});
}(AIRTIME || {}));
$(document).ready(AIRTIME.itemTemplate.onReady); $(document).ready(AIRTIME.itemTemplate.onReady);

File diff suppressed because it is too large Load Diff

View File

@ -8,10 +8,14 @@ var AIRTIME = (function(AIRTIME) {
mod = AIRTIME.template; mod = AIRTIME.template;
function createItemLi(id, name, configured) { function createItemLi(id, name, configured) {
var editUrl =
var editUrl = baseUrl+"Playouthistorytemplate/configure-template/id/"+id; baseUrl + "Playouthistorytemplate/configure-template/id/" + id;
var defaultUrl = baseUrl+"Playouthistorytemplate/set-template-default/format/json/id/"+id; var defaultUrl =
var removeUrl = baseUrl+"Playouthistorytemplate/delete-template/format/json/id/"+id; baseUrl +
"Playouthistorytemplate/set-template-default/format/json/id/" +
id;
var removeUrl =
baseUrl + "Playouthistorytemplate/delete-template/format/json/id/" + id;
var itemConfigured = var itemConfigured =
"<li class='template_configured' data-template='<%= id %>' data-name='<%= name %>'>" + "<li class='template_configured' data-template='<%= id %>' data-name='<%= name %>'>" +
@ -23,24 +27,32 @@ var AIRTIME = (function(AIRTIME) {
"<li data-template='<%= id %>' data-name='<%= name %>'>" + "<li data-template='<%= id %>' data-name='<%= name %>'>" +
"<a href='<%= editUrl %>' class='template_name'><%= name %></a>" + "<a href='<%= editUrl %>' class='template_name'><%= name %></a>" +
"<a href='<%= removeUrl %>' class='template_remove'><i class='icon icon-trash'></i></a>" + "<a href='<%= removeUrl %>' class='template_remove'><i class='icon icon-trash'></i></a>" +
"<a href='<%= defaultUrl %>' class='template_default'>" + $.i18n._('Set Default') + "</a>" + "<a href='<%= defaultUrl %>' class='template_default'>" +
$.i18n._("Set Default") +
"</a>" +
"</li>"; "</li>";
var template = (configured) === true ? itemConfigured : item; var template = configured === true ? itemConfigured : item;
var template = _.template(template); var template = _.template(template);
var $li = $(template({id: id, name: name, editUrl: editUrl, defaultUrl: defaultUrl, removeUrl: removeUrl})); var $li = $(
template({
id: id,
name: name,
editUrl: editUrl,
defaultUrl: defaultUrl,
removeUrl: removeUrl,
})
);
return $li; return $li;
} }
mod.onReady = function () { mod.onReady = function () {
$historyTemplate = $("#history_template"); $historyTemplate = $("#history_template");
$historyTemplate.on("click", ".template_remove", function (ev) { $historyTemplate.on("click", ".template_remove", function (ev) {
ev.preventDefault(); ev.preventDefault();
var $a = $(this); var $a = $(this);
@ -53,7 +65,6 @@ var AIRTIME = (function(AIRTIME) {
}); });
$historyTemplate.on("click", ".template_default", function (ev) { $historyTemplate.on("click", ".template_default", function (ev) {
ev.preventDefault(); ev.preventDefault();
var $a = $(this); var $a = $(this);
@ -63,8 +74,12 @@ var AIRTIME = (function(AIRTIME) {
$oldLi = $a.parents("ul").find("li.template_configured"); $oldLi = $a.parents("ul").find("li.template_configured");
$newLi = $a.parents("li"); $newLi = $a.parents("li");
$oldLi.replaceWith(createItemLi($oldLi.data('template'), $oldLi.data('name'), false)); $oldLi.replaceWith(
$newLi.replaceWith(createItemLi($newLi.data('template'), $newLi.data('name'), true)); createItemLi($oldLi.data("template"), $oldLi.data("name"), false)
);
$newLi.replaceWith(
createItemLi($newLi.data("template"), $newLi.data("name"), true)
);
$.post(url, function () { $.post(url, function () {
var x; var x;
@ -72,11 +87,9 @@ var AIRTIME = (function(AIRTIME) {
}); });
function createTemplate(type) { function createTemplate(type) {
var createUrl = baseUrl + "Playouthistorytemplate/create-template"; var createUrl = baseUrl + "Playouthistorytemplate/create-template";
$.post(createUrl, { format: "json", type: type }, function (json) { $.post(createUrl, { format: "json", type: type }, function (json) {
if (json.error !== undefined) { if (json.error !== undefined) {
alert(json.error); alert(json.error);
return; return;
@ -96,7 +109,6 @@ var AIRTIME = (function(AIRTIME) {
}; };
return AIRTIME; return AIRTIME;
})(AIRTIME || {});
}(AIRTIME || {}));
$(document).ready(AIRTIME.template.onReady); $(document).ready(AIRTIME.template.onReady);

View File

@ -1,129 +1,153 @@
function setWatchedDirEvents() { function setWatchedDirEvents() {
$("#storageFolder-selection").serverBrowser({
$('#storageFolder-selection').serverBrowser({
onSelect: function (path) { onSelect: function (path) {
$('#storageFolder').val(path); $("#storageFolder").val(path);
}, },
onLoad: function () { onLoad: function () {
return $('#storageFolder').val(); return $("#storageFolder").val();
}, },
width: 500, width: 500,
height: 250, height: 250,
position: ['center', 'center'], position: ["center", "center"],
//knownPaths: [{text:'Desktop', image:'desktop.png', path:'/home'}], //knownPaths: [{text:'Desktop', image:'desktop.png', path:'/home'}],
knownPaths: [], knownPaths: [],
imageUrl: 'img/icons/', imageUrl: "img/icons/",
systemImageUrl: baseUrl+'css/img/', systemImageUrl: baseUrl + "css/img/",
handlerUrl: baseUrl+'Preference/server-browse/format/json', handlerUrl: baseUrl + "Preference/server-browse/format/json",
title: $.i18n._('Choose Storage Folder'), title: $.i18n._("Choose Storage Folder"),
basePath: '', basePath: "",
requestMethod: 'POST', requestMethod: "POST",
}); });
$('#watchedFolder-selection').serverBrowser({ $("#watchedFolder-selection").serverBrowser({
onSelect: function (path) { onSelect: function (path) {
$('#watchedFolder').val(path); $("#watchedFolder").val(path);
}, },
onLoad: function () { onLoad: function () {
return $('#watchedFolder').val(); return $("#watchedFolder").val();
}, },
width: 500, width: 500,
height: 250, height: 250,
position: ['center', 'center'], position: ["center", "center"],
//knownPaths: [{text:'Desktop', image:'desktop.png', path:'/home'}], //knownPaths: [{text:'Desktop', image:'desktop.png', path:'/home'}],
knownPaths: [], knownPaths: [],
imageUrl: 'img/icons/', imageUrl: "img/icons/",
systemImageUrl: baseUrl+'css/img/', systemImageUrl: baseUrl + "css/img/",
handlerUrl: baseUrl+'Preference/server-browse/format/json', handlerUrl: baseUrl + "Preference/server-browse/format/json",
title: $.i18n._('Choose Folder to Watch'), title: $.i18n._("Choose Folder to Watch"),
basePath: '', basePath: "",
requestMethod: 'POST', requestMethod: "POST",
}); });
$('#storageFolder-ok').click(function(){ $("#storageFolder-ok").click(function () {
var url, chosen; var url, chosen;
if(confirm(sprintf($.i18n._("Are you sure you want to change the storage folder?\nThis will remove the files from your %s library!"), PRODUCT_NAME))){ if (
confirm(
sprintf(
$.i18n._(
"Are you sure you want to change the storage folder?\nThis will remove the files from your %s library!"
),
PRODUCT_NAME
)
)
) {
url = baseUrl + "Preference/change-stor-directory"; url = baseUrl + "Preference/change-stor-directory";
chosen = $('#storageFolder').val(); chosen = $("#storageFolder").val();
$.post(url, $.post(
url,
{ format: "json", dir: chosen, element: "storageFolder" }, { format: "json", dir: chosen, element: "storageFolder" },
function (json) { function (json) {
$("#watched-folder-section").empty(); $("#watched-folder-section").empty();
$("#watched-folder-section").append(json.subform); $("#watched-folder-section").append(json.subform);
setWatchedDirEvents(); setWatchedDirEvents();
});
} }
else { );
$('#storageFolder').val(""); } else {
$("#storageFolder").val("");
} }
}); });
$('#watchedFolder-ok').click(function(){ $("#watchedFolder-ok").click(function () {
var url, chosen; var url, chosen;
url = baseUrl + "Preference/reload-watch-directory"; url = baseUrl + "Preference/reload-watch-directory";
chosen = $('#watchedFolder').val(); chosen = $("#watchedFolder").val();
$.post(url, $.post(
url,
{ format: "json", dir: chosen, element: "watchedFolder" }, { format: "json", dir: chosen, element: "watchedFolder" },
function (json) { function (json) {
$("#watched-folder-section").empty(); $("#watched-folder-section").empty();
$("#watched-folder-section").append("<h2>"+$.i18n._("Manage Media Folders")+"</h2>"); $("#watched-folder-section").append(
"<h2>" + $.i18n._("Manage Media Folders") + "</h2>"
);
$("#watched-folder-section").append(json.subform); $("#watched-folder-section").append(json.subform);
setWatchedDirEvents(); setWatchedDirEvents();
}); }
);
}); });
$('.selected-item').find('.ui-icon-refresh').click(function(){ $(".selected-item")
.find(".ui-icon-refresh")
.click(function () {
var folder = $(this).prev().text(); var folder = $(this).prev().text();
$.get(baseUrl+"Preference/rescan-watch-directory", {format: "json", dir: folder}); $.get(baseUrl + "Preference/rescan-watch-directory", {
format: "json",
dir: folder,
});
}); });
$('.selected-item').find('.ui-icon-close').click(function(){ $(".selected-item")
if(confirm($.i18n._("Are you sure you want to remove the watched folder?"))){ .find(".ui-icon-close")
.click(function () {
if (
confirm($.i18n._("Are you sure you want to remove the watched folder?"))
) {
var row = $(this).parent(); var row = $(this).parent();
var folder = row.find('#folderPath').text(); var folder = row.find("#folderPath").text();
url = baseUrl + "Preference/remove-watch-directory"; url = baseUrl + "Preference/remove-watch-directory";
$.post(url, $.post(
url,
{ format: "json", dir: folder }, { format: "json", dir: folder },
function (json) { function (json) {
$("#watched-folder-section").empty(); $("#watched-folder-section").empty();
$("#watched-folder-section").append("<h2>"+$.i18n._("Manage Media Folders")+"</h2>"); $("#watched-folder-section").append(
"<h2>" + $.i18n._("Manage Media Folders") + "</h2>"
);
$("#watched-folder-section").append(json.subform); $("#watched-folder-section").append(json.subform);
setWatchedDirEvents(); setWatchedDirEvents();
}); }
);
} }
}); });
} }
$(document).ready(function () { $(document).ready(function () {
setWatchedDirEvents(); setWatchedDirEvents();
$(".ui-icon-alert").qtip({ $(".ui-icon-alert").qtip({
content: { content: {
text: $.i18n._("This path is currently not accessible.") text: $.i18n._("This path is currently not accessible."),
}, },
position: { position: {
adjust: { adjust: {
resize: true, resize: true,
method: "flip flip" method: "flip flip",
}, },
at: "right center", at: "right center",
my: "left top", my: "left top",
viewport: $(window) viewport: $(window),
}, },
style: { style: {
classes: "ui-tooltip-dark" classes: "ui-tooltip-dark",
}, },
show: 'mouseover', show: "mouseover",
hide: 'mouseout' hide: "mouseout",
}); });
}); });

View File

@ -33,7 +33,7 @@ function setPodcastAutoSmartblockReadonly() {
var disablePodcastAutomSmartblock = $("#podcastAutoSmartblock-0"); var disablePodcastAutomSmartblock = $("#podcastAutoSmartblock-0");
var enablePodcastAutomSmartblock = $("#podcastAutoSmartblock-1"); var enablePodcastAutomSmartblock = $("#podcastAutoSmartblock-1");
var podcastOverride = $("#podcastAlbumOverride-1"); var podcastOverride = $("#podcastAlbumOverride-1");
if ($(podcastOverride).is(':checked')) { if ($(podcastOverride).is(":checked")) {
enablePodcastAutomSmartblock.removeAttr("readonly"); enablePodcastAutomSmartblock.removeAttr("readonly");
} else { } else {
disablePodcastAutomSmartblock.prop("checked", true); disablePodcastAutomSmartblock.prop("checked", true);
@ -45,7 +45,7 @@ function setPodcastAutoSmartblockReadonly() {
function setSystemFromEmailReadonly() { function setSystemFromEmailReadonly() {
var enableSystemEmails = $("#enableSystemEmail"); var enableSystemEmails = $("#enableSystemEmail");
var systemFromEmail = $("#systemEmail"); var systemFromEmail = $("#systemEmail");
if ($(enableSystemEmails).is(':checked')) { if ($(enableSystemEmails).is(":checked")) {
systemFromEmail.removeAttr("readonly"); systemFromEmail.removeAttr("readonly");
} else { } else {
systemFromEmail.attr("readonly", "readonly"); systemFromEmail.attr("readonly", "readonly");
@ -58,7 +58,7 @@ function setMailServerInputReadonly() {
var port = $("#port"); var port = $("#port");
var requiresAuthCB = $("#msRequiresAuth"); var requiresAuthCB = $("#msRequiresAuth");
if (configMailServer.is(':checked')) { if (configMailServer.is(":checked")) {
mailServer.removeAttr("readonly"); mailServer.removeAttr("readonly");
port.removeAttr("readonly"); port.removeAttr("readonly");
requiresAuthCB.parent().show(); requiresAuthCB.parent().show();
@ -84,7 +84,7 @@ function setTuneInSettingsReadonly() {
var partnerKey = $("#tunein_partner_key"); var partnerKey = $("#tunein_partner_key");
var partnerId = $("#tunein_partner_id"); var partnerId = $("#tunein_partner_id");
if (enableTunein.is(':checked')) { if (enableTunein.is(":checked")) {
stationId.removeAttr("readonly"); stationId.removeAttr("readonly");
partnerKey.removeAttr("readonly"); partnerKey.removeAttr("readonly");
partnerId.removeAttr("readonly"); partnerId.removeAttr("readonly");
@ -103,35 +103,44 @@ function setMsAuthenticationFieldsReadonly(ele) {
var password = $("#ms_password"); var password = $("#ms_password");
var configureMailServer = $("#configureMailServer"); var configureMailServer = $("#configureMailServer");
if (ele.is(':checked') && configureMailServer.is(':checked')) { if (ele.is(":checked") && configureMailServer.is(":checked")) {
email.removeAttr("readonly"); email.removeAttr("readonly");
password.removeAttr("readonly"); password.removeAttr("readonly");
} else if (ele.not(':checked') || configureMailServer.not(':checked')) { } else if (ele.not(":checked") || configureMailServer.not(":checked")) {
email.attr("readonly", "readonly"); email.attr("readonly", "readonly");
password.attr("readonly", "readonly"); password.attr("readonly", "readonly");
} }
} }
function removeLogo() { function removeLogo() {
$.post(baseUrl+'preference/remove-logo', {'csrf_token' : $('#csrf').val()}, function(json){ $.post(
baseUrl + "preference/remove-logo",
{ csrf_token: $("#csrf").val() },
function (json) {
// Reload without resubmitting the form // Reload without resubmitting the form
location.href = location.href.replace(location.hash, ""); location.href = location.href.replace(location.hash, "");
}); }
);
} }
function deleteAllFiles() { function deleteAllFiles() {
var resp = confirm($.i18n._("Are you sure you want to delete all the tracks in your library?")) var resp = confirm(
$.i18n._("Are you sure you want to delete all the tracks in your library?")
);
if (resp) { if (resp) {
$.post(baseUrl+'preference/delete-all-files', {'csrf_token' : $('#csrf').val()}, function(json){ $.post(
baseUrl + "preference/delete-all-files",
{ csrf_token: $("#csrf").val() },
function (json) {
location.reload(); location.reload();
}); }
);
} }
} }
$(document).ready(function () { $(document).ready(function () {
$(".collapsible-header").live("click", function () {
$('.collapsible-header').live('click',function() { $(this).next().toggle("fast");
$(this).next().toggle('fast');
$(this).toggleClass("closed"); $(this).toggleClass("closed");
return false; return false;
}); });
@ -164,7 +173,7 @@ $(document).ready(function() {
var reader = new FileReader(); // browser compatibility? var reader = new FileReader(); // browser compatibility?
reader.onload = function (e) { reader.onload = function (e) {
console.log("Reader loaded"); console.log("Reader loaded");
preview.attr('src', e.target.result); preview.attr("src", e.target.result);
}; };
// check image size so we don't crash the page trying to render // check image size so we don't crash the page trying to render
@ -173,7 +182,7 @@ $(document).ready(function() {
reader.readAsDataURL(this.files[0]); reader.readAsDataURL(this.files[0]);
} else { } else {
// remove the file element data // remove the file element data
$(this).val('').replaceWith($(this).clone(true)); $(this).val("").replaceWith($(this).clone(true));
preview.hide(); preview.hide();
} }
} else { } else {
@ -181,7 +190,7 @@ $(document).ready(function() {
} }
}); });
if (preview.attr('src').indexOf('images/') > -1) { if (preview.attr("src").indexOf("images/") > -1) {
$("#logo-remove-btn").hide(); $("#logo-remove-btn").hide();
} }

View File

@ -1,83 +1,116 @@
function showErrorSections() { function showErrorSections() {
$(".errors").each(function (i) { $(".errors").each(function (i) {
if ($(this).length > 0) { if ($(this).length > 0) {
var div = $(this).closest("div") var div = $(this).closest("div");
if(div.attr('class') == "stream-setting-content"){ if (div.attr("class") == "stream-setting-content") {
$(this).closest("div").show(); $(this).closest("div").show();
$(this).closest("fieldset").removeClass('closed'); $(this).closest("fieldset").removeClass("closed");
$(window).scrollTop($(this).closest("div").position().top); $(window).scrollTop($(this).closest("div").position().top);
} }
} }
}); });
} }
function rebuildStreamURL(ele) { function rebuildStreamURL(ele) {
var div = ele.closest("div") var div = ele.closest("div");
host = div.find("input[id$=-host]").val() host = div.find("input[id$=-host]").val();
port = div.find("input[id$=-port]").val() port = div.find("input[id$=-port]").val();
mount = div.find("input[id$=-mount]").val() mount = div.find("input[id$=-mount]").val();
streamurl = "" streamurl = "";
if (div.find("select[id$=-output]").val() == "icecast") { if (div.find("select[id$=-output]").val() == "icecast") {
streamurl = "http://"+host streamurl = "http://" + host;
if ($.trim(port) != "") { if ($.trim(port) != "") {
streamurl += ":"+port streamurl += ":" + port;
} }
if ($.trim(mount) != "") { if ($.trim(mount) != "") {
streamurl += "/"+mount streamurl += "/" + mount;
} }
} else { } else {
streamurl = "http://"+host+":"+port+"/" streamurl = "http://" + host + ":" + port + "/";
} }
div.find("#stream_url").html('<a href="' + streamurl + '" target="_blank">' + streamurl + '</a>') div
.find("#stream_url")
.html('<a href="' + streamurl + '" target="_blank">' + streamurl + "</a>");
} }
function restrictOggBitrate(ele, on) { function restrictOggBitrate(ele, on) {
var div = ele.closest("div") var div = ele.closest("div");
if (on) { if (on) {
if (parseInt(div.find("select[id$=data-bitrate]").val(), 10) < 48) { if (parseInt(div.find("select[id$=data-bitrate]").val(), 10) < 48) {
div.find("select[id$=data-bitrate]").find("option[value='48']").attr("selected","selected"); div
.find("select[id$=data-bitrate]")
.find("option[value='48']")
.attr("selected", "selected");
} }
div.find("select[id$=data-bitrate]").find("option[value='24']").attr("disabled","disabled"); div
div.find("select[id$=data-bitrate]").find("option[value='32']").attr("disabled","disabled"); .find("select[id$=data-bitrate]")
.find("option[value='24']")
.attr("disabled", "disabled");
div
.find("select[id$=data-bitrate]")
.find("option[value='32']")
.attr("disabled", "disabled");
} else { } else {
div.find("select[id$=data-bitrate]").find("option[value='24']").removeAttr("disabled"); div
div.find("select[id$=data-bitrate]").find("option[value='32']").removeAttr("disabled"); .find("select[id$=data-bitrate]")
.find("option[value='24']")
.removeAttr("disabled");
div
.find("select[id$=data-bitrate]")
.find("option[value='32']")
.removeAttr("disabled");
} }
} }
function hideForShoutcast(ele) { function hideForShoutcast(ele) {
var div = ele.closest("div") var div = ele.closest("div");
div.find("#outputMountpoint-label").hide() div.find("#outputMountpoint-label").hide();
div.find("#outputMountpoint-element").hide() div.find("#outputMountpoint-element").hide();
div.find("#outputUser-label").hide() div.find("#outputUser-label").hide();
div.find("#outputUser-element").hide() div.find("#outputUser-element").hide();
div.find("select[id$=data-type]").find("option[value='mp3']").attr('selected','selected'); div
div.find("select[id$=data-type]").find("option[value='ogg']").attr("disabled","disabled"); .find("select[id$=data-type]")
div.find("select[id$=data-type]").find("option[value='opus']").attr("disabled","disabled"); .find("option[value='mp3']")
.attr("selected", "selected");
div
.find("select[id$=data-type]")
.find("option[value='ogg']")
.attr("disabled", "disabled");
div
.find("select[id$=data-type]")
.find("option[value='opus']")
.attr("disabled", "disabled");
restrictOggBitrate(ele, false) restrictOggBitrate(ele, false);
} }
function validate(ele, evt) { function validate(ele, evt) {
var theEvent = evt || window.event; var theEvent = evt || window.event;
var key = theEvent.keyCode || theEvent.which; var key = theEvent.keyCode || theEvent.which;
if ((ele.val().length >= 5 || (key < 48 || key > 57)) && !(key == 8 || key == 9 || key == 13 || key == 37 || key == 39 || key == 46)) { if (
(ele.val().length >= 5 || key < 48 || key > 57) &&
!(key == 8 || key == 9 || key == 13 || key == 37 || key == 39 || key == 46)
) {
theEvent.returnValue = false; theEvent.returnValue = false;
if (theEvent.preventDefault) theEvent.preventDefault(); if (theEvent.preventDefault) theEvent.preventDefault();
} }
} }
function showForIcecast(ele) { function showForIcecast(ele) {
var div = ele.closest("div"); var div = ele.closest("div");
div.find("#outputMountpoint-label").show(); div.find("#outputMountpoint-label").show();
div.find("#outputMountpoint-element").show(); div.find("#outputMountpoint-element").show();
div.find("#outputUser-label").show(); div.find("#outputUser-label").show();
div.find("#outputUser-element").show(); div.find("#outputUser-element").show();
div.find("select[id$=data-type]").find("option[value='ogg']").removeAttr("disabled"); div
div.find("select[id$=data-type]").find("option[value='opus']").removeAttr("disabled"); .find("select[id$=data-type]")
.find("option[value='ogg']")
.removeAttr("disabled");
div
.find("select[id$=data-type]")
.find("option[value='opus']")
.removeAttr("disabled");
} }
function checkLiquidsoapStatus() { function checkLiquidsoapStatus() {
var url = baseUrl+'Preference/get-liquidsoap-status/format/json'; var url = baseUrl + "Preference/get-liquidsoap-status/format/json";
var id = $(this).attr("id"); var id = $(this).attr("id");
$.post(url, function (json_obj) { $.post(url, function (json_obj) {
for (var i = 0; i < json_obj.length; i++) { for (var i = 0; i < json_obj.length; i++) {
@ -94,13 +127,27 @@ function checkLiquidsoapStatus(){
} }
var html; var html;
if (status == "OK") { if (status == "OK") {
html = '<div class="stream-status status-good"><p>'+$.i18n._("Connected to the streaming server")+'</p></div>'; html =
'<div class="stream-status status-good"><p>' +
$.i18n._("Connected to the streaming server") +
"</p></div>";
} else if (status == "N/A") { } else if (status == "N/A") {
html = '<div class="stream-status status-disabled"><p>'+$.i18n._("The stream is disabled")+'</p></div>'; html =
'<div class="stream-status status-disabled"><p>' +
$.i18n._("The stream is disabled") +
"</p></div>";
} else if (status == "waiting") { } else if (status == "waiting") {
html = '<div class="stream-status status-info"><p>'+$.i18n._("Getting information from the server...")+'</p></div>'; html =
'<div class="stream-status status-info"><p>' +
$.i18n._("Getting information from the server...") +
"</p></div>";
} else { } else {
html = '<div class="stream-status status-error"><p>'+$.i18n._("Can not connect to the streaming server")+'</p><p>'+status+'</p></div>'; html =
'<div class="stream-status status-error"><p>' +
$.i18n._("Can not connect to the streaming server") +
"</p><p>" +
status +
"</p></div>";
} }
$("#s" + id + "Liquidsoap-error-msg-element").html(html); $("#s" + id + "Liquidsoap-error-msg-element").html(html);
} }
@ -111,7 +158,10 @@ function checkLiquidsoapStatus(){
function setLiveSourceConnectionOverrideListener() { function setLiveSourceConnectionOverrideListener() {
$("[id=connection_url_override]").click(function (event) { $("[id=connection_url_override]").click(function (event) {
var url_input = $(this).parent().find("dd[id$='_source_host-element']").children(); var url_input = $(this)
.parent()
.find("dd[id$='_source_host-element']")
.children();
url_input.removeAttr("readonly"); url_input.removeAttr("readonly");
$(this).parent().find("div[id$='_dj_connection_url_actions']").show(); $(this).parent().find("div[id$='_dj_connection_url_actions']").show();
event.preventDefault(); event.preventDefault();
@ -119,9 +169,15 @@ function setLiveSourceConnectionOverrideListener(){
// set action for "OK" and "X" // set action for "OK" and "X"
var live_dj_actions = $("#live_dj_connection_url_actions"); var live_dj_actions = $("#live_dj_connection_url_actions");
var live_dj_input = live_dj_actions.parent().find("dd[id$='_source_host-element']").children(); var live_dj_input = live_dj_actions
.parent()
.find("dd[id$='_source_host-element']")
.children();
var master_dj_actions = $("#master_dj_connection_url_actions"); var master_dj_actions = $("#master_dj_connection_url_actions");
var master_dj_input = master_dj_actions.parent().find("dd[id$='_source_host-element']").children(); var master_dj_input = master_dj_actions
.parent()
.find("dd[id$='_source_host-element']")
.children();
live_dj_actions.find("#ok").click(function (event) { live_dj_actions.find("#ok").click(function (event) {
event.preventDefault(); event.preventDefault();
@ -129,7 +185,12 @@ function setLiveSourceConnectionOverrideListener(){
live_dj_input.val(url); live_dj_input.val(url);
live_dj_input.attr("readonly", "readonly"); live_dj_input.attr("readonly", "readonly");
live_dj_actions.hide(); live_dj_actions.hide();
$.get(baseUrl+"Preference/set-source-connection-url", {format: "json", type: "livedj", url:encodeURIComponent(url), override: 1}); $.get(baseUrl + "Preference/set-source-connection-url", {
format: "json",
type: "livedj",
url: encodeURIComponent(url),
override: 1,
});
event.preventDefault(); event.preventDefault();
}); });
@ -137,14 +198,19 @@ function setLiveSourceConnectionOverrideListener(){
event.preventDefault(); event.preventDefault();
var port = $("#show_source_port").val(); var port = $("#show_source_port").val();
var mount = $("#show_source_mount").val(); var mount = $("#show_source_mount").val();
if (mount.charAt(0) != '/') { if (mount.charAt(0) != "/") {
mount = ('/').concat(mount); mount = "/".concat(mount);
} }
var url = "http://" + location.hostname + ":" + port + mount; var url = "http://" + location.hostname + ":" + port + mount;
live_dj_input.val(url); live_dj_input.val(url);
live_dj_input.attr("readonly", "readonly"); live_dj_input.attr("readonly", "readonly");
live_dj_actions.hide(); live_dj_actions.hide();
$.get(baseUrl+"Preference/set-source-connection-url", {format: "json", type: "livedj", url:encodeURIComponent(url), override: 0}); $.get(baseUrl + "Preference/set-source-connection-url", {
format: "json",
type: "livedj",
url: encodeURIComponent(url),
override: 0,
});
event.preventDefault(); event.preventDefault();
}); });
@ -153,31 +219,40 @@ function setLiveSourceConnectionOverrideListener(){
master_dj_input.val(url); master_dj_input.val(url);
master_dj_input.attr("readonly", "readonly"); master_dj_input.attr("readonly", "readonly");
master_dj_actions.hide(); master_dj_actions.hide();
$.get(baseUrl+"Preference/set-source-connection-url", {format: "json", type: "masterdj", url:encodeURIComponent(url), override: 1}); $.get(baseUrl + "Preference/set-source-connection-url", {
format: "json",
type: "masterdj",
url: encodeURIComponent(url),
override: 1,
});
event.preventDefault(); event.preventDefault();
}); });
master_dj_actions.find("#reset").click(function (event) { master_dj_actions.find("#reset").click(function (event) {
var port = $("#master_source_port").val(); var port = $("#master_source_port").val();
var mount = $("#master_source_mount").val(); var mount = $("#master_source_mount").val();
if (mount.charAt(0) != '/') { if (mount.charAt(0) != "/") {
mount = ('/').concat(mount); mount = "/".concat(mount);
} }
var url = "http://" + location.hostname + ":" + port + mount; var url = "http://" + location.hostname + ":" + port + mount;
master_dj_input.val(url); master_dj_input.val(url);
master_dj_input.attr("readonly", "readonly"); master_dj_input.attr("readonly", "readonly");
master_dj_actions.hide(); master_dj_actions.hide();
$.get(baseUrl+"Preference/set-source-connection-url", {format: "json", type: "masterdj", url:encodeURIComponent(url), override: 0}); $.get(baseUrl + "Preference/set-source-connection-url", {
format: "json",
type: "masterdj",
url: encodeURIComponent(url),
override: 0,
});
event.preventDefault(); event.preventDefault();
}); });
} }
function setupEventListeners() { function setupEventListeners() {
// initial stream url // initial stream url
$("dd[id=outputStreamURL-element]").each(function () { $("dd[id=outputStreamURL-element]").each(function () {
rebuildStreamURL($(this)); rebuildStreamURL($(this));
}) });
$("input[id$=-host], input[id$=-port], input[id$=-mount]").keyup(function () { $("input[id$=-host], input[id$=-port], input[id$=-mount]").keyup(function () {
rebuildStreamURL($(this)); rebuildStreamURL($(this));
@ -191,22 +266,22 @@ function setupEventListeners() {
rebuildStreamURL($(this)); rebuildStreamURL($(this));
}); });
if(!$("#output_sound_device").is(':checked')){ if (!$("#output_sound_device").is(":checked")) {
$("select[id=output_sound_device_type]").attr('disabled', 'disabled'); $("select[id=output_sound_device_type]").attr("disabled", "disabled");
} else { } else {
$("select[id=output_sound_device_type]").removeAttr('disabled'); $("select[id=output_sound_device_type]").removeAttr("disabled");
} }
$("#output_sound_device").change(function () { $("#output_sound_device").change(function () {
if($(this).is(':checked')){ if ($(this).is(":checked")) {
$("select[id=output_sound_device_type]").removeAttr('disabled'); $("select[id=output_sound_device_type]").removeAttr("disabled");
} else { } else {
$("select[id=output_sound_device_type]").attr('disabled', 'disabled'); $("select[id=output_sound_device_type]").attr("disabled", "disabled");
} }
}); });
$("select[id$=data-type]").change(function () { $("select[id$=data-type]").change(function () {
if($(this).val() == 'ogg'){ if ($(this).val() == "ogg") {
restrictOggBitrate($(this), true); restrictOggBitrate($(this), true);
} else { } else {
restrictOggBitrate($(this), false); restrictOggBitrate($(this), false);
@ -214,13 +289,13 @@ function setupEventListeners() {
}); });
$("select[id$=data-type]").each(function () { $("select[id$=data-type]").each(function () {
if($(this).val() == 'ogg'){ if ($(this).val() == "ogg") {
restrictOggBitrate($(this), true); restrictOggBitrate($(this), true);
} }
}); });
$("select[id$=data-output]").change(function () { $("select[id$=data-output]").change(function () {
if($(this).val() == 'shoutcast'){ if ($(this).val() == "shoutcast") {
hideForShoutcast($(this)); hideForShoutcast($(this));
} else { } else {
showForIcecast($(this)); showForIcecast($(this));
@ -228,18 +303,18 @@ function setupEventListeners() {
}); });
$("select[id$=data-output]").each(function () { $("select[id$=data-output]").each(function () {
if($(this).val() == 'shoutcast'){ if ($(this).val() == "shoutcast") {
hideForShoutcast($(this)); hideForShoutcast($(this));
} }
}); });
$('.toggle legend').click(function() { $(".toggle legend").click(function () {
$(this).parent().toggleClass('closed'); $(this).parent().toggleClass("closed");
return false; return false;
}); });
$('.collapsible-header').click(function() { $(".collapsible-header").click(function () {
$(this).next().toggle('fast'); $(this).next().toggle("fast");
$(this).toggleClass("closed"); $(this).toggleClass("closed");
return false; return false;
}); });
@ -249,181 +324,208 @@ function setupEventListeners() {
showErrorSections(); showErrorSections();
checkLiquidsoapStatus(); checkLiquidsoapStatus();
var userManualAnchorOpen = "<a target='_blank' href='" + USER_MANUAL_URL + "'>"; var userManualAnchorOpen =
"<a target='_blank' href='" + USER_MANUAL_URL + "'>";
// qtip for help text // qtip for help text
$(".override_help_icon").qtip({ $(".override_help_icon").qtip({
content: { content: {
text: sprintf($.i18n._("If %s is behind a router or firewall, you may need to configure port forwarding and this field information will be incorrect. In this case you will need to manually update this field so it shows the correct host/port/mount that your DJ's need to connect to. The allowed range is between 1024 and 49151."), PRODUCT_NAME)+" "+ text:
sprintf($.i18n._( sprintf(
"For more details, please read the %s%s Manual%s"), userManualAnchorOpen, PRODUCT_NAME, "</a>") $.i18n._(
"If %s is behind a router or firewall, you may need to configure port forwarding and this field information will be incorrect. In this case you will need to manually update this field so it shows the correct host/port/mount that your DJ's need to connect to. The allowed range is between 1024 and 49151."
),
PRODUCT_NAME
) +
" " +
sprintf(
$.i18n._("For more details, please read the %s%s Manual%s"),
userManualAnchorOpen,
PRODUCT_NAME,
"</a>"
),
}, },
hide: { hide: {
delay: 500, delay: 500,
fixed: true fixed: true,
}, },
style: { style: {
border: { border: {
width: 0, width: 0,
radius: 4 radius: 4,
}, },
classes: "ui-tooltip-dark ui-tooltip-rounded" classes: "ui-tooltip-dark ui-tooltip-rounded",
}, },
position: { position: {
my: "left bottom", my: "left bottom",
at: "right center" at: "right center",
}, },
}); });
$(".icecast_metadata_help_icon").qtip({ $(".icecast_metadata_help_icon").qtip({
content: { content: {
text: $.i18n._("Check this option to enable metadata for OGG streams (stream metadata is the track title, artist, and show name that is displayed in an audio player). VLC and mplayer have a serious bug when playing an OGG/VORBIS stream that has metadata information enabled: they will disconnect from the stream after every song. If you are using an OGG stream and your listeners do not require support for these audio players, then feel free to enable this option.") text: $.i18n._(
"Check this option to enable metadata for OGG streams (stream metadata is the track title, artist, and show name that is displayed in an audio player). VLC and mplayer have a serious bug when playing an OGG/VORBIS stream that has metadata information enabled: they will disconnect from the stream after every song. If you are using an OGG stream and your listeners do not require support for these audio players, then feel free to enable this option."
),
}, },
hide: { hide: {
delay: 500, delay: 500,
fixed: true fixed: true,
}, },
style: { style: {
border: { border: {
width: 0, width: 0,
radius: 4 radius: 4,
}, },
classes: "ui-tooltip-dark ui-tooltip-rounded" classes: "ui-tooltip-dark ui-tooltip-rounded",
}, },
position: { position: {
my: "left bottom", my: "left bottom",
at: "right center" at: "right center",
}, },
}); });
$("#auto_transition_help").qtip({ $("#auto_transition_help").qtip({
content: { content: {
text: $.i18n._("Check this box to automatically switch off Master/Show source upon source disconnection.") text: $.i18n._(
"Check this box to automatically switch off Master/Show source upon source disconnection."
),
}, },
hide: { hide: {
delay: 500, delay: 500,
fixed: true fixed: true,
}, },
style: { style: {
border: { border: {
width: 0, width: 0,
radius: 4 radius: 4,
}, },
classes: "ui-tooltip-dark ui-tooltip-rounded" classes: "ui-tooltip-dark ui-tooltip-rounded",
}, },
position: { position: {
my: "left bottom", my: "left bottom",
at: "right center" at: "right center",
}, },
}); });
$("#auto_switch_help").qtip({ $("#auto_switch_help").qtip({
content: { content: {
text: $.i18n._("Check this box to automatically switch on Master/Show source upon source connection.") text: $.i18n._(
"Check this box to automatically switch on Master/Show source upon source connection."
),
}, },
hide: { hide: {
delay: 500, delay: 500,
fixed: true fixed: true,
}, },
style: { style: {
border: { border: {
width: 0, width: 0,
radius: 4 radius: 4,
}, },
classes: "ui-tooltip-dark ui-tooltip-rounded" classes: "ui-tooltip-dark ui-tooltip-rounded",
}, },
position: { position: {
my: "left bottom", my: "left bottom",
at: "right center" at: "right center",
}, },
}); });
$(".stream_username_help_icon").qtip({ $(".stream_username_help_icon").qtip({
content: { content: {
text: $.i18n._("If your Icecast server expects a username of 'source', this field can be left blank.") text: $.i18n._(
"If your Icecast server expects a username of 'source', this field can be left blank."
),
}, },
hide: { hide: {
delay: 500, delay: 500,
fixed: true fixed: true,
}, },
style: { style: {
border: { border: {
width: 0, width: 0,
radius: 4 radius: 4,
}, },
classes: "ui-tooltip-dark ui-tooltip-rounded" classes: "ui-tooltip-dark ui-tooltip-rounded",
}, },
position: { position: {
my: "left bottom", my: "left bottom",
at: "right center" at: "right center",
}, },
}); });
$(".admin_username_help_icon").qtip({ $(".admin_username_help_icon").qtip({
content: { content: {
text: $.i18n._("This is the admin username and password for Icecast/SHOUTcast to get listener statistics.") text: $.i18n._(
"This is the admin username and password for Icecast/SHOUTcast to get listener statistics."
),
}, },
hide: { hide: {
delay: 500, delay: 500,
fixed: true fixed: true,
}, },
style: { style: {
border: { border: {
width: 0, width: 0,
radius: 4 radius: 4,
}, },
classes: "ui-tooltip-dark ui-tooltip-rounded" classes: "ui-tooltip-dark ui-tooltip-rounded",
}, },
position: { position: {
my: "left bottom", my: "left bottom",
at: "right center" at: "right center",
}, },
}); });
$(".master_username_help_icon").qtip({ $(".master_username_help_icon").qtip({
content: { content: {
text: $.i18n._("If your live streaming client does not ask for a username, this field should be 'source'.") text: $.i18n._(
"If your live streaming client does not ask for a username, this field should be 'source'."
),
}, },
hide: { hide: {
delay: 500, delay: 500,
fixed: true fixed: true,
}, },
style: { style: {
border: { border: {
width: 0, width: 0,
radius: 4 radius: 4,
}, },
classes: "ui-tooltip-dark ui-tooltip-rounded" classes: "ui-tooltip-dark ui-tooltip-rounded",
}, },
position: { position: {
my: "left bottom", my: "left bottom",
at: "right center" at: "right center",
}, },
}); });
$(".stream_type_help_icon").qtip({ $(".stream_type_help_icon").qtip({
content: { content: {
text: sprintf( text: sprintf(
$.i18n._("Some stream types require extra configuration. Details about enabling %sAAC+ Support%s or %sOpus Support%s are provided."), $.i18n._(
"Some stream types require extra configuration. Details about enabling %sAAC+ Support%s or %sOpus Support%s are provided."
),
"<a target='_blank' href='https://wiki.sourcefabric.org/x/NgPQ'>", "<a target='_blank' href='https://wiki.sourcefabric.org/x/NgPQ'>",
"</a>", "</a>",
"<a target='_blank' href='https://wiki.sourcefabric.org/x/KgPQ'>", "<a target='_blank' href='https://wiki.sourcefabric.org/x/KgPQ'>",
"</a>") "</a>"
),
}, },
hide: { hide: {
delay: 500, delay: 500,
fixed: true fixed: true,
}, },
style: { style: {
border: { border: {
width: 0, width: 0,
radius: 4 radius: 4,
}, },
classes: "ui-tooltip-dark ui-tooltip-rounded" classes: "ui-tooltip-dark ui-tooltip-rounded",
}, },
position: { position: {
my: "left bottom", my: "left bottom",
at: "right center" at: "right center",
}, },
}); });
} }
@ -437,30 +539,34 @@ function setSliderForReplayGain(){
slide: function (event, ui) { slide: function (event, ui) {
$("#replayGainModifier").val(ui.value); $("#replayGainModifier").val(ui.value);
$("#rg_modifier_value").html(ui.value); $("#rg_modifier_value").html(ui.value);
} },
}); });
$("#replayGainModifier").val($("#slider-range-max").slider("value")); $("#replayGainModifier").val($("#slider-range-max").slider("value"));
} }
function setPseudoAdminPassword(s1, s2, s3, s4) { function setPseudoAdminPassword(s1, s2, s3, s4) {
if (s1) { if (s1) {
$('#s1_data-admin_pass').val('xxxxxx'); $("#s1_data-admin_pass").val("xxxxxx");
} }
if (s2) { if (s2) {
$('#s2_data-admin_pass').val('xxxxxx'); $("#s2_data-admin_pass").val("xxxxxx");
} }
if (s3) { if (s3) {
$('#s3_data-admin_pass').val('xxxxxx'); $("#s3_data-admin_pass").val("xxxxxx");
} }
if (s4) { if (s4) {
$('#s4_data-admin_pass').val('xxxxxx'); $("#s4_data-admin_pass").val("xxxxxx");
} }
} }
function getAdminPasswordStatus() { function getAdminPasswordStatus() {
$.ajax({ url: baseUrl+'Preference/get-admin-password-status/format/json', dataType:"json", success:function(data){ $.ajax({
url: baseUrl + "Preference/get-admin-password-status/format/json",
dataType: "json",
success: function (data) {
setPseudoAdminPassword(data.s1, data.s2, data.s3, data.s4); setPseudoAdminPassword(data.s1, data.s2, data.s3, data.s4);
}}); },
});
} }
$(document).ready(function () { $(document).ready(function () {
@ -469,16 +575,22 @@ $(document).ready(function() {
getAdminPasswordStatus(); getAdminPasswordStatus();
var s = $("[name^='customStreamSettings']:checked"); var s = $("[name^='customStreamSettings']:checked");
$("[id^='stream_save'], [name^='customStreamSettings']").live('click', function() { $("[id^='stream_save'], [name^='customStreamSettings']").live(
"click",
function () {
var e = $(this); var e = $(this);
if (e[0] == s[0]) { return; } if (e[0] == s[0]) {
var confirm_pypo_restart_text = $.i18n._("WARNING: This will restart your stream and may cause a short dropout for your listeners!"); return;
}
var confirm_pypo_restart_text = $.i18n._(
"WARNING: This will restart your stream and may cause a short dropout for your listeners!"
);
if (confirm(confirm_pypo_restart_text)) { if (confirm(confirm_pypo_restart_text)) {
var data = $('#stream_form').serialize(); var data = $("#stream_form").serialize();
var url = baseUrl+'Preference/stream-setting'; var url = baseUrl + "Preference/stream-setting";
$.post(url, { format: "json", data: data }, function (json) { $.post(url, { format: "json", data: data }, function (json) {
$('#content').empty().append(json.html); $("#content").empty().append(json.html);
if (json.valid) { if (json.valid) {
window.location.reload(); window.location.reload();
} }
@ -487,12 +599,13 @@ $(document).ready(function() {
getAdminPasswordStatus(); getAdminPasswordStatus();
}); });
} else { } else {
if (e.prop('checked')) { if (e.prop("checked")) {
if (e[0] != s[0]) { if (e[0] != s[0]) {
e.prop('checked', false); e.prop("checked", false);
s.prop('checked', true); s.prop("checked", true);
} }
} }
} }
}); }
);
}); });

File diff suppressed because it is too large Load Diff

View File

@ -16,7 +16,7 @@ function scheduleRefetchEvents(json) {
$("#add-show-close").click(); $("#add-show-close").click();
} }
} }
$("#schedule_calendar").fullCalendar('refetchEvents'); $("#schedule_calendar").fullCalendar("refetchEvents");
} }
function makeTimeStamp(date) { function makeTimeStamp(date) {
@ -28,7 +28,18 @@ function makeTimeStamp(date) {
m = date.getMinutes(); m = date.getMinutes();
s = date.getSeconds(); s = date.getSeconds();
timestamp = sy + "-" + pad(sm, 2) + "-" + pad(sd, 2) + " " + pad(h, 2) + ":" + pad(m, 2) + ":" + pad(s, 2); timestamp =
sy +
"-" +
pad(sm, 2) +
"-" +
pad(sd, 2) +
" " +
pad(h, 2) +
":" +
pad(m, 2) +
":" +
pad(s, 2);
return timestamp; return timestamp;
} }
@ -43,14 +54,25 @@ function dayClick(date, allDay, jsEvent, view) {
if (view.name === "month") { if (view.name === "month") {
today = new Date(now.getFullYear(), now.getMonth(), now.getDate()); today = new Date(now.getFullYear(), now.getMonth(), now.getDate());
selected = new Date(date.getFullYear(), date.getMonth(), date.getDate()); selected = new Date(date.getFullYear(), date.getMonth(), date.getDate());
} } else {
else { today = new Date(
today = new Date(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), now.getMinutes()); now.getFullYear(),
selected = new Date(date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes()); now.getMonth(),
now.getDate(),
now.getHours(),
now.getMinutes()
);
selected = new Date(
date.getFullYear(),
date.getMonth(),
date.getDate(),
date.getHours(),
date.getMinutes()
);
} }
if (selected >= today) { if (selected >= today) {
var addShow = $('.add-button'); var addShow = $(".add-button");
//remove the +show button if it exists. //remove the +show button if it exists.
if (addShow.length == 1) { if (addShow.length == 1) {
@ -72,17 +94,18 @@ function dayClick(date, allDay, jsEvent, view) {
duration_m = parseInt(duration_info[1], 10); duration_m = parseInt(duration_info[1], 10);
} }
// duration in milisec // duration in milisec
var duration = (duration_h * 60 * 60 * 1000) + (duration_m * 60 * 1000); var duration = duration_h * 60 * 60 * 1000 + duration_m * 60 * 1000;
var startTime_string; var startTime_string;
var startTime = 0; var startTime = 0;
// get start time value on the form // get start time value on the form
if (view.name === "month") { if (view.name === "month") {
startTime_string = $("#add_show_start_time").val(); startTime_string = $("#add_show_start_time").val();
var startTime_info = startTime_string.split(':'); var startTime_info = startTime_string.split(":");
if (startTime_info.length == 2) { if (startTime_info.length == 2) {
var start_time_temp = (parseInt(startTime_info[0], 10) * 60 * 60 * 1000) var start_time_temp =
+ (parseInt(startTime_info[1], 10) * 60 * 1000); parseInt(startTime_info[0], 10) * 60 * 60 * 1000 +
parseInt(startTime_info[1], 10) * 60 * 1000;
if (!isNaN(start_time_temp)) { if (!isNaN(start_time_temp)) {
startTime = start_time_temp; startTime = start_time_temp;
} }
@ -90,28 +113,41 @@ function dayClick(date, allDay, jsEvent, view) {
} else { } else {
// if in day or week view, selected has all the time info as well // if in day or week view, selected has all the time info as well
// so we don't ahve to calculate it explicitly // so we don't ahve to calculate it explicitly
startTime_string = pad(selected.getHours(), 2) + ":" + pad(selected.getMinutes(), 2) startTime_string =
startTime = 0 pad(selected.getHours(), 2) + ":" + pad(selected.getMinutes(), 2);
startTime = 0;
} }
// calculate endDateTime // calculate endDateTime
var endDateTime = new Date(selected.getTime() + startTime + duration); var endDateTime = new Date(selected.getTime() + startTime + duration);
chosenDate = selected.getFullYear() + '-' + pad(selected.getMonth() + 1, 2) + '-' + pad(selected.getDate(), 2); chosenDate =
var endDateFormat = endDateTime.getFullYear() + '-' + pad(endDateTime.getMonth() + 1, 2) + '-' + pad(endDateTime.getDate(), 2); selected.getFullYear() +
"-" +
pad(selected.getMonth() + 1, 2) +
"-" +
pad(selected.getDate(), 2);
var endDateFormat =
endDateTime.getFullYear() +
"-" +
pad(endDateTime.getMonth() + 1, 2) +
"-" +
pad(endDateTime.getDate(), 2);
//TODO: This should all be refactored into a proper initialize() function for the show form. //TODO: This should all be refactored into a proper initialize() function for the show form.
$("#add_show_start_now-future").attr('checked', 'checked'); $("#add_show_start_now-future").attr("checked", "checked");
$("#add_show_start_now-now").removeProp('disabled'); $("#add_show_start_now-now").removeProp("disabled");
setupStartTimeWidgets(); //add-show.js setupStartTimeWidgets(); //add-show.js
$("#add_show_start_date").val(chosenDate); $("#add_show_start_date").val(chosenDate);
$("#add_show_end_date_no_repeat").val(endDateFormat); $("#add_show_end_date_no_repeat").val(endDateFormat);
$("#add_show_end_date").val(endDateFormat); $("#add_show_end_date").val(endDateFormat);
if (view.name !== "month") { if (view.name !== "month") {
var endTimeString = pad(endDateTime.getHours(), 2) + ":" + pad(endDateTime.getMinutes(), 2); var endTimeString =
$("#add_show_start_time").val(startTime_string) pad(endDateTime.getHours(), 2) +
$("#add_show_end_time").val(endTimeString) ":" +
pad(endDateTime.getMinutes(), 2);
$("#add_show_start_time").val(startTime_string);
$("#add_show_end_time").val(endTimeString);
} }
calculateShowColor(); calculateShowColor();
$("#schedule-show-when").show(); $("#schedule-show-when").show();
@ -126,21 +162,20 @@ function dayClick(date, allDay, jsEvent, view) {
function viewDisplay(view) { function viewDisplay(view) {
view_name = view.name; view_name = view.name;
if (view.name === 'agendaDay' || view.name === 'agendaWeek') { if (view.name === "agendaDay" || view.name === "agendaWeek") {
var calendarEl = this; var calendarEl = this;
var select = $('<select class="schedule_change_slots input_select"/>') var select = $('<select class="schedule_change_slots input_select"/>')
.append('<option value="1">' + $.i18n._("1m") + '</option>') .append('<option value="1">' + $.i18n._("1m") + "</option>")
.append('<option value="5">' + $.i18n._("5m") + '</option>') .append('<option value="5">' + $.i18n._("5m") + "</option>")
.append('<option value="10">' + $.i18n._("10m") + '</option>') .append('<option value="10">' + $.i18n._("10m") + "</option>")
.append('<option value="15">' + $.i18n._("15m") + '</option>') .append('<option value="15">' + $.i18n._("15m") + "</option>")
.append('<option value="30">' + $.i18n._("30m") + '</option>') .append('<option value="30">' + $.i18n._("30m") + "</option>")
.append('<option value="60">' + $.i18n._("60m") + '</option>') .append('<option value="60">' + $.i18n._("60m") + "</option>")
.change(function () { .change(function () {
var slotMin = $(this).val(); var slotMin = $(this).val();
var opt = view.calendar.options; var opt = view.calendar.options;
var date = $(calendarEl).fullCalendar('getDate'); var date = $(calendarEl).fullCalendar("getDate");
opt.slotMinutes = parseInt(slotMin); opt.slotMinutes = parseInt(slotMin);
opt.events = getFullCalendarEvents; opt.events = getFullCalendarEvents;
@ -148,12 +183,12 @@ function viewDisplay(view) {
//re-initialize calendar with new slotmin options //re-initialize calendar with new slotmin options
$(calendarEl) $(calendarEl)
.fullCalendar('destroy') .fullCalendar("destroy")
.fullCalendar(opt) .fullCalendar(opt)
.fullCalendar('gotoDate', date); .fullCalendar("gotoDate", date);
//save slotMin value to db //save slotMin value to db
var url = baseUrl + 'Schedule/set-time-interval/format/json'; var url = baseUrl + "Schedule/set-time-interval/format/json";
$.post(url, { timeInterval: slotMin }); $.post(url, { timeInterval: slotMin });
}); });
@ -162,15 +197,20 @@ function viewDisplay(view) {
//select.width(topLeft.width()) //select.width(topLeft.width())
// .height(topLeft.height()); // .height(topLeft.height());
topLeft.empty() topLeft.empty().append(select);
.append(select);
var slotMin = view.calendar.options.slotMinutes; var slotMin = view.calendar.options.slotMinutes;
$('.schedule_change_slots option[value="' + slotMin + '"]').attr('selected', 'selected'); $('.schedule_change_slots option[value="' + slotMin + '"]').attr(
"selected",
"selected"
);
} }
if (($("#add-show-form").length == 1) && ($("#add-show-form").css('display') == 'none') && ($('.fc-header-left > span').length == 5)) { if (
$("#add-show-form").length == 1 &&
$("#add-show-form").css("display") == "none" &&
$(".fc-header-left > span").length == 5
) {
//userType is defined in bootstrap.php, and is derived from the currently logged in user. //userType is defined in bootstrap.php, and is derived from the currently logged in user.
if (userType == "S" || userType == "A" || userType == "P") { if (userType == "S" || userType == "A" || userType == "P") {
makeAddShowButton(); makeAddShowButton();
@ -179,7 +219,7 @@ function viewDisplay(view) {
//save view name to db if it was changed //save view name to db if it was changed
if (calendarPref.timeScale !== view.name) { if (calendarPref.timeScale !== view.name) {
var url = baseUrl + 'Schedule/set-time-scale/format/json'; var url = baseUrl + "Schedule/set-time-scale/format/json";
$.post(url, { timeScale: view.name }); $.post(url, { timeScale: view.name });
calendarPref.timeScale = view.name; calendarPref.timeScale = view.name;
} }
@ -192,35 +232,39 @@ function eventRender(event, element, view) {
$(element).data("event", event); $(element).data("event", event);
//only put progress bar on shows that aren't being recorded. //only put progress bar on shows that aren't being recorded.
if ((view.name === 'agendaDay' || view.name === 'agendaWeek') && event.record === 0) { if (
var div = $('<div/>'); (view.name === "agendaDay" || view.name === "agendaWeek") &&
event.record === 0
) {
var div = $("<div/>");
div div
.height('5px') .height("5px")
.width('95%') .width("95%")
.css('margin-top', '1px') .css("margin-top", "1px")
.css('margin-left', 'auto') .css("margin-left", "auto")
.css('margin-right', 'auto') .css("margin-right", "auto")
.progressbar({ .progressbar({
value: event.percent value: event.percent,
}); });
$(element).find(".fc-event-content").append(div); $(element).find(".fc-event-content").append(div);
} }
if (event.record === 0 && event.rebroadcast === 0) { if (event.record === 0 && event.rebroadcast === 0) {
if (view.name === 'agendaDay' || view.name === 'agendaWeek') { if (view.name === "agendaDay" || view.name === "agendaWeek") {
if (event.show_empty === 1) { if (event.show_empty === 1) {
if (event.linked) { if (event.linked) {
$(element) $(element)
.find(".fc-event-time") .find(".fc-event-time")
.before('<span class="small-icon linked"></span><span class="small-icon show-empty"></span>'); .before(
'<span class="small-icon linked"></span><span class="small-icon show-empty"></span>'
);
// in theory a linked show shouldn't have an automatic playlist so adding this here // in theory a linked show shouldn't have an automatic playlist so adding this here
} else if (event.show_has_auto_playlist === true) { } else if (event.show_has_auto_playlist === true) {
$(element) $(element)
.find(".fc-event-time") .find(".fc-event-time")
.before('<span class="small-icon autoplaylist"></span>'); .before('<span class="small-icon autoplaylist"></span>');
} } else {
else {
$(element) $(element)
.find(".fc-event-time") .find(".fc-event-time")
.before('<span class="small-icon show-empty"></span>'); .before('<span class="small-icon show-empty"></span>');
@ -229,7 +273,9 @@ function eventRender(event, element, view) {
if (event.linked) { if (event.linked) {
$(element) $(element)
.find(".fc-event-time") .find(".fc-event-time")
.before('<span class="small-icon linked"></span><span class="small-icon show-partial-filled"></span>'); .before(
'<span class="small-icon linked"></span><span class="small-icon show-partial-filled"></span>'
);
} else if (event.show_has_auto_playlist === true) { } else if (event.show_has_auto_playlist === true) {
$(element) $(element)
.find(".fc-event-time") .find(".fc-event-time")
@ -243,7 +289,9 @@ function eventRender(event, element, view) {
if (event.linked) { if (event.linked) {
$(element) $(element)
.find(".fc-event-time") .find(".fc-event-time")
.before('<span class="small-icon linked"></span><span class="small-icon show-overbooked"></span>'); .before(
'<span class="small-icon linked"></span><span class="small-icon show-overbooked"></span>'
);
} else if (event.show_has_auto_playlist === true) { } else if (event.show_has_auto_playlist === true) {
$(element) $(element)
.find(".fc-event-time") .find(".fc-event-time")
@ -253,7 +301,6 @@ function eventRender(event, element, view) {
.find(".fc-event-time") .find(".fc-event-time")
.before('<span class="small-icon show-overbooked"></span>'); .before('<span class="small-icon show-overbooked"></span>');
} }
} else { } else {
if (event.linked) { if (event.linked) {
$(element) $(element)
@ -265,48 +312,88 @@ function eventRender(event, element, view) {
.before('<span class="small-icon autoplaylist"></span>'); .before('<span class="small-icon autoplaylist"></span>');
} }
} }
} else if (view.name === 'month') { } else if (view.name === "month") {
if (event.show_empty === 1) { if (event.show_empty === 1) {
if (event.linked) { if (event.linked) {
$(element) $(element)
.find(".fc-event-title") .find(".fc-event-title")
.after('<span class="small-icon linked"></span><span title="' + $.i18n._("Show is empty") + '" class="small-icon show-empty"></span>'); .after(
'<span class="small-icon linked"></span><span title="' +
$.i18n._("Show is empty") +
'" class="small-icon show-empty"></span>'
);
} else if (event.show_has_auto_playlist === true) { } else if (event.show_has_auto_playlist === true) {
$(element) $(element)
.find(".fc-event-title") .find(".fc-event-title")
.after('<span title="' + $.i18n._("Show has an automatic playlist") + '"class="small-icon autoplaylist"></span>'); .after(
'<span title="' +
$.i18n._("Show has an automatic playlist") +
'"class="small-icon autoplaylist"></span>'
);
} else { } else {
$(element) $(element)
.find(".fc-event-title") .find(".fc-event-title")
.after('<span title="' + $.i18n._("Show is empty") + '" class="small-icon show-empty"></span>'); .after(
'<span title="' +
$.i18n._("Show is empty") +
'" class="small-icon show-empty"></span>'
);
} }
} else if (event.show_partial_filled === true) { } else if (event.show_partial_filled === true) {
if (event.linked) { if (event.linked) {
$(element) $(element)
.find(".fc-event-title") .find(".fc-event-title")
.after('<span class="small-icon linked"></span><span title="' + $.i18n._("Show is partially filled") + '" class="small-icon show-partial-filled"></span>'); .after(
'<span class="small-icon linked"></span><span title="' +
$.i18n._("Show is partially filled") +
'" class="small-icon show-partial-filled"></span>'
);
} else if (event.show_has_auto_playlist === true) { } else if (event.show_has_auto_playlist === true) {
$(element) $(element)
.find(".fc-event-title") .find(".fc-event-title")
.after('<span title="' + $.i18n._("Show has an automatic playlist") + '"class="small-icon autoplaylist"></span>'); .after(
'<span title="' +
$.i18n._("Show has an automatic playlist") +
'"class="small-icon autoplaylist"></span>'
);
} else { } else {
$(element) $(element)
.find(".fc-event-title") .find(".fc-event-title")
.after('<span title="' + $.i18n._("Show is partially filled") + '" class="small-icon show-partial-filled"></span>'); .after(
'<span title="' +
$.i18n._("Show is partially filled") +
'" class="small-icon show-partial-filled"></span>'
);
} }
} else if (event.percent > 100) { } else if (event.percent > 100) {
if (event.linked) { if (event.linked) {
$(element) $(element)
.find(".fc-event-title") .find(".fc-event-title")
.after('<span class="small-icon linked"></span><span title="' + $.i18n._("Shows longer than their scheduled time will be cut off by a following show.") + '" class="small-icon show-overbooked"></span>'); .after(
'<span class="small-icon linked"></span><span title="' +
$.i18n._(
"Shows longer than their scheduled time will be cut off by a following show."
) +
'" class="small-icon show-overbooked"></span>'
);
} else if (event.show_has_auto_playlist === true) { } else if (event.show_has_auto_playlist === true) {
$(element) $(element)
.find(".fc-event-title") .find(".fc-event-title")
.after('<span title="' + $.i18n._("Show has an automatic playlist") + '"class="small-icon autoplaylist"></span>'); .after(
'<span title="' +
$.i18n._("Show has an automatic playlist") +
'"class="small-icon autoplaylist"></span>'
);
} else { } else {
$(element) $(element)
.find(".fc-event-title") .find(".fc-event-title")
.after('<span title="' + $.i18n._("Shows longer than their scheduled time will be cut off by a following show.") + '" class="small-icon show-overbooked"></span>'); .after(
'<span title="' +
$.i18n._(
"Shows longer than their scheduled time will be cut off by a following show."
) +
'" class="small-icon show-overbooked"></span>'
);
} }
} else { } else {
if (event.linked) { if (event.linked) {
@ -324,10 +411,14 @@ function eventRender(event, element, view) {
//rebroadcast icon //rebroadcast icon
if (event.rebroadcast === 1) { if (event.rebroadcast === 1) {
if (view.name === 'agendaDay' || view.name === 'agendaWeek') { if (view.name === "agendaDay" || view.name === "agendaWeek") {
$(element).find(".fc-event-time").before('<span class="small-icon rebroadcast"></span>'); $(element)
} else if (view.name === 'month') { .find(".fc-event-time")
$(element).find(".fc-event-title").after('<span class="small-icon rebroadcast"></span>'); .before('<span class="small-icon rebroadcast"></span>');
} else if (view.name === "month") {
$(element)
.find(".fc-event-title")
.after('<span class="small-icon rebroadcast"></span>');
} }
} }
@ -335,29 +426,36 @@ function eventRender(event, element, view) {
var span = '<span class="small-icon now-playing"></span>'; var span = '<span class="small-icon now-playing"></span>';
if (event.nowPlaying === true) { if (event.nowPlaying === true) {
if (view_name === "agendaDay" || view_name === "agendaWeek") {
if (view_name === 'agendaDay' || view_name === 'agendaWeek') {
$(element).find(".fc-event-time").before(span); $(element).find(".fc-event-time").before(span);
} } else if (view_name === "month") {
else if (view_name === 'month') {
$(element).find(".fc-event-title").after(span); $(element).find(".fc-event-title").after(span);
} }
} }
} }
function eventAfterRender(event, element, view) { function eventAfterRender(event, element, view) {
$(element)
$(element).find(".small-icon").live('mouseover', function () { .find(".small-icon")
.live("mouseover", function () {
addQtipsToIcons($(this), event.id); addQtipsToIcons($(this), event.id);
}); });
} }
function eventDrop(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui, view) { function eventDrop(
var url = baseUrl + 'Schedule/move-show/format/json'; event,
dayDelta,
minuteDelta,
allDay,
revertFunc,
jsEvent,
ui,
view
) {
var url = baseUrl + "Schedule/move-show/format/json";
$.post(url, $.post(
url,
{ day: dayDelta, min: minuteDelta, showInstanceId: event.id }, { day: dayDelta, min: minuteDelta, showInstanceId: event.id },
function (json) { function (json) {
if (json.show_error == true) { if (json.show_error == true) {
@ -372,15 +470,29 @@ function eventDrop(event, dayDelta, minuteDelta, allDay, revertFunc, jsEvent, ui
//time changes in a different way than Airtime does. //time changes in a different way than Airtime does.
//(Airtime preserves show duration, FullCalendar doesn't.) //(Airtime preserves show duration, FullCalendar doesn't.)
scheduleRefetchEvents(json); scheduleRefetchEvents(json);
}
}); );
} }
function eventResize(event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, view) { function eventResize(
var url = baseUrl + 'Schedule/resize-show/format/json'; event,
dayDelta,
minuteDelta,
revertFunc,
jsEvent,
ui,
view
) {
var url = baseUrl + "Schedule/resize-show/format/json";
$.post(url, $.post(
{ day: dayDelta, min: minuteDelta, showId: event.showId, instanceId: event.id }, url,
{
day: dayDelta,
min: minuteDelta,
showId: event.showId,
instanceId: event.id,
},
function (json) { function (json) {
if (json.show_error == true) { if (json.show_error == true) {
alertShowErrorAndReload(); alertShowErrorAndReload();
@ -391,14 +503,15 @@ function eventResize(event, dayDelta, minuteDelta, revertFunc, jsEvent, ui, view
} }
scheduleRefetchEvents(json); scheduleRefetchEvents(json);
}); }
);
} }
function windowResize() { function windowResize() {
// 200 px for top dashboard and 50 for padding on main content // 200 px for top dashboard and 50 for padding on main content
// this calculation was copied from schedule.js line 326 // this calculation was copied from schedule.js line 326
var mainHeight = $(window).height() - 200 - 24; var mainHeight = $(window).height() - 200 - 24;
$('#schedule_calendar').fullCalendar('option', 'contentHeight', mainHeight); $("#schedule_calendar").fullCalendar("option", "contentHeight", mainHeight);
} }
function preloadEventFeed() { function preloadEventFeed() {
@ -407,7 +520,6 @@ function preloadEventFeed() {
var initialLoad = true; var initialLoad = true;
function getFullCalendarEvents(start, end, callback) { function getFullCalendarEvents(start, end, callback) {
if (initialLoad) { if (initialLoad) {
initialLoad = false; initialLoad = false;
callback(calendarEvents); callback(calendarEvents);
@ -416,13 +528,17 @@ function getFullCalendarEvents(start, end, callback) {
start_date = makeTimeStamp(start); start_date = makeTimeStamp(start);
end_date = makeTimeStamp(end); end_date = makeTimeStamp(end);
url = baseUrl + 'Schedule/event-feed'; url = baseUrl + "Schedule/event-feed";
var d = new Date(); var d = new Date();
$.post(url, { format: "json", start: start_date, end: end_date, cachep: d.getTime() }, function (json) { $.post(
url,
{ format: "json", start: start_date, end: end_date, cachep: d.getTime() },
function (json) {
callback(json.events); callback(json.events);
getUsabilityHint(); getUsabilityHint();
}); }
);
} }
$(".fc-button").addClass("btn").addClass("btn-small"); $(".fc-button").addClass("btn").addClass("btn-small");
@ -433,26 +549,20 @@ function getFullCalendarEvents(start, end, callback) {
* show icon * show icon
*/ */
function getCurrentShow() { function getCurrentShow() {
var url = baseUrl + "Schedule/get-current-show/format/json";
var url = baseUrl + 'Schedule/get-current-show/format/json';
function addNowPlaying(json) { function addNowPlaying(json) {
var $el, var $el,
span = '<span class="small-icon now-playing"></span>'; span = '<span class="small-icon now-playing"></span>';
$(".now-playing").remove(); $(".now-playing").remove();
if (json.current_show === true) { if (json.current_show === true) {
$el = $(".fc-show-instance-" + json.si_id); $el = $(".fc-show-instance-" + json.si_id);
if (view_name === 'agendaDay' || view_name === 'agendaWeek') { if (view_name === "agendaDay" || view_name === "agendaWeek") {
$el.find(".fc-event-time").before(span); $el.find(".fc-event-time").before(span);
} } else if (view_name === "month") {
else if (view_name === 'month') {
$el.find(".fc-event-title").after(span); $el.find(".fc-event-title").after(span);
} }
} }
@ -464,90 +574,91 @@ function getCurrentShow() {
} }
function addQtipsToIcons(ele, id) { function addQtipsToIcons(ele, id) {
if ($(ele).hasClass("progress")) { if ($(ele).hasClass("progress")) {
$(ele).qtip({ $(ele).qtip({
content: { content: {
text: $.i18n._("Uploading in progress...") text: $.i18n._("Uploading in progress..."),
}, },
position: { position: {
adjust: { adjust: {
resize: true, resize: true,
method: "flip flip" method: "flip flip",
}, },
at: "right center", at: "right center",
my: "left top", my: "left top",
viewport: $(window) viewport: $(window),
}, },
style: { style: {
classes: "ui-tooltip-dark file-md-long" classes: "ui-tooltip-dark file-md-long",
}, },
show: { show: {
ready: true // Needed to make it show on first mouseover event ready: true, // Needed to make it show on first mouseover event
} },
}); });
} else if ($(ele).hasClass("show-empty")) { } else if ($(ele).hasClass("show-empty")) {
$(ele).qtip({ $(ele).qtip({
content: { content: {
text: $.i18n._("This show has no scheduled content.") text: $.i18n._("This show has no scheduled content."),
}, },
position: { position: {
adjust: { adjust: {
resize: true, resize: true,
method: "flip flip" method: "flip flip",
}, },
at: "right center", at: "right center",
my: "left top", my: "left top",
viewport: $(window) viewport: $(window),
}, },
style: { style: {
classes: "ui-tooltip-dark file-md-long" classes: "ui-tooltip-dark file-md-long",
}, },
show: { show: {
ready: true // Needed to make it show on first mouseover event ready: true, // Needed to make it show on first mouseover event
} },
}); });
} else if ($(ele).hasClass("show-partial-filled")) { } else if ($(ele).hasClass("show-partial-filled")) {
$(ele).qtip({ $(ele).qtip({
content: { content: {
text: $.i18n._("This show is not completely filled with content.") text: $.i18n._("This show is not completely filled with content."),
}, },
position: { position: {
adjust: { adjust: {
resize: true, resize: true,
method: "flip flip" method: "flip flip",
}, },
at: "right center", at: "right center",
my: "left top", my: "left top",
viewport: $(window) viewport: $(window),
}, },
style: { style: {
classes: "ui-tooltip-dark file-md-long" classes: "ui-tooltip-dark file-md-long",
}, },
show: { show: {
ready: true // Needed to make it show on first mouseover event ready: true, // Needed to make it show on first mouseover event
} },
}); });
} else if ($(ele).hasClass("show-overbooked")) { } else if ($(ele).hasClass("show-overbooked")) {
$(ele).qtip({ $(ele).qtip({
content: { content: {
text: $.i18n._("Shows longer than their scheduled time will be cut off by a following show.") text: $.i18n._(
"Shows longer than their scheduled time will be cut off by a following show."
),
}, },
position: { position: {
adjust: { adjust: {
resize: true, resize: true,
method: "flip flip" method: "flip flip",
}, },
at: "right center", at: "right center",
my: "left top", my: "left top",
viewport: $(window) viewport: $(window),
}, },
style: { style: {
classes: "ui-tooltip-dark file-md-long" classes: "ui-tooltip-dark file-md-long",
}, },
show: { show: {
ready: true // Needed to make it show on first mouseover event ready: true, // Needed to make it show on first mouseover event
} },
}); });
} }
} }

View File

@ -7,73 +7,72 @@ var AIRTIME = (function(AIRTIME){
mod = AIRTIME.schedule; mod = AIRTIME.schedule;
return AIRTIME; return AIRTIME;
})(AIRTIME || {});
}(AIRTIME || {}));
var serverTimezoneOffset = 0; var serverTimezoneOffset = 0;
function closeDialogCalendar(event, ui) { function closeDialogCalendar(event, ui) {
$el = $(this); $el = $(this);
$el.dialog('destroy'); $el.dialog("destroy");
$el.remove(); $el.remove();
//need to refetch the events to update scheduled status. //need to refetch the events to update scheduled status.
$("#schedule_calendar").fullCalendar( 'refetchEvents' ); $("#schedule_calendar").fullCalendar("refetchEvents");
} }
function confirmCancelShow(show_instance_id) { function confirmCancelShow(show_instance_id) {
if (confirm($.i18n._('Cancel Current Show?'))) { if (confirm($.i18n._("Cancel Current Show?"))) {
var url = baseUrl + "Schedule/cancel-current-show"; var url = baseUrl + "Schedule/cancel-current-show";
$.ajax({ $.ajax({
url: url, url: url,
data: { format: "json", id: show_instance_id }, data: { format: "json", id: show_instance_id },
success: function (data) { success: function (data) {
scheduleRefetchEvents(data); scheduleRefetchEvents(data);
} },
}); });
} }
} }
function confirmCancelRecordedShow(show_instance_id) { function confirmCancelRecordedShow(show_instance_id) {
if (confirm($.i18n._('Stop recording current show?'))) { if (confirm($.i18n._("Stop recording current show?"))) {
var url = baseUrl + "Schedule/cancel-current-show"; var url = baseUrl + "Schedule/cancel-current-show";
$.ajax({ $.ajax({
url: url, url: url,
data: { format: "json", id: show_instance_id }, data: { format: "json", id: show_instance_id },
success: function (data) { success: function (data) {
scheduleRefetchEvents(data); scheduleRefetchEvents(data);
} },
}); });
} }
} }
function findViewportDimensions() { function findViewportDimensions() {
var viewportwidth, var viewportwidth, viewportheight;
viewportheight;
// the more standards compliant browsers (mozilla/netscape/opera/IE7) use // the more standards compliant browsers (mozilla/netscape/opera/IE7) use
// window.innerWidth and window.innerHeight // window.innerWidth and window.innerHeight
if (typeof window.innerWidth != 'undefined') { if (typeof window.innerWidth != "undefined") {
viewportwidth = window.innerWidth, viewportheight = window.innerHeight; (viewportwidth = window.innerWidth), (viewportheight = window.innerHeight);
} }
// IE6 in standards compliant mode (i.e. with a valid doctype as the first // IE6 in standards compliant mode (i.e. with a valid doctype as the first
// line in the document) // line in the document)
else if (typeof document.documentElement != 'undefined' else if (
&& typeof document.documentElement.clientWidth != 'undefined' typeof document.documentElement != "undefined" &&
&& document.documentElement.clientWidth != 0) { typeof document.documentElement.clientWidth != "undefined" &&
document.documentElement.clientWidth != 0
) {
viewportwidth = document.documentElement.clientWidth; viewportwidth = document.documentElement.clientWidth;
viewportheight = document.documentElement.clientHeight; viewportheight = document.documentElement.clientHeight;
} }
// older versions of IE // older versions of IE
else { else {
viewportwidth = document.getElementsByTagName('body')[0].clientWidth; viewportwidth = document.getElementsByTagName("body")[0].clientWidth;
viewportheight = document.getElementsByTagName('body')[0].clientHeight; viewportheight = document.getElementsByTagName("body")[0].clientHeight;
} }
return { return {
width: viewportwidth, width: viewportwidth,
height: viewportheight-45 height: viewportheight - 45,
}; };
} }
@ -82,7 +81,7 @@ function highlightMediaTypeSelector(dialog) {
if (location.hash === "") { if (location.hash === "") {
selected = dialog.find("a[href$='#tracks']"); selected = dialog.find("a[href$='#tracks']");
} else { } else {
selected = dialog.find("a[href$='"+location.hash+"']") selected = dialog.find("a[href$='" + location.hash + "']");
} }
selected.parent().addClass("selected"); selected.parent().addClass("selected");
@ -94,7 +93,7 @@ function highlightMediaTypeSelector(dialog) {
$(this).find("a").get(0).click(); $(this).find("a").get(0).click();
}); });
$(window).on('hashchange', function() { $(window).on("hashchange", function () {
var selected = dialog.find("a[href$='" + location.hash + "']"); var selected = dialog.find("a[href$='" + location.hash + "']");
AIRTIME.library.selectNone(); AIRTIME.library.selectNone();
dialog.find(".media_type_selector").each(function () { dialog.find(".media_type_selector").each(function () {
@ -109,24 +108,24 @@ function highlightMediaTypeSelector(dialog) {
function buildTimerange(dialog) { function buildTimerange(dialog) {
var builder = dialog.find("#show_builder"), var builder = dialog.find("#show_builder"),
oBaseDatePickerSettings = { oBaseDatePickerSettings = {
dateFormat: 'yy-mm-dd', dateFormat: "yy-mm-dd",
//i18n_months, i18n_days_short are in common.js //i18n_months, i18n_days_short are in common.js
monthNames: i18n_months, monthNames: i18n_months,
dayNamesMin: i18n_days_short, dayNamesMin: i18n_days_short,
onClick: function (sDate, oDatePicker) { onClick: function (sDate, oDatePicker) {
$(this).datepicker("setDate", sDate); $(this).datepicker("setDate", sDate);
}, },
onClose: validateTimeRange onClose: validateTimeRange,
}, },
oBaseTimePickerSettings = { oBaseTimePickerSettings = {
showPeriodLabels: false, showPeriodLabels: false,
showCloseButton: true, showCloseButton: true,
closeButtonText: $.i18n._("Done"), closeButtonText: $.i18n._("Done"),
showLeadingZero: false, showLeadingZero: false,
defaultTime: '0:00', defaultTime: "0:00",
hourText: $.i18n._("Hour"), hourText: $.i18n._("Hour"),
minuteText: $.i18n._("Minute"), minuteText: $.i18n._("Minute"),
onClose: validateTimeRange onClose: validateTimeRange,
}; };
/* /*
@ -139,17 +138,17 @@ function buildTimerange(dialog) {
$(this).removeClass("ui-state-hover"); $(this).removeClass("ui-state-hover");
}); });
builder.find(dateStartId) builder.find(dateStartId).datepicker(oBaseDatePickerSettings);
.datepicker(oBaseDatePickerSettings); builder.find(timeStartId).timepicker(oBaseTimePickerSettings);
builder.find(timeStartId) builder.find(dateEndId).datepicker(oBaseDatePickerSettings);
.timepicker(oBaseTimePickerSettings); builder.find(timeEndId).timepicker(oBaseTimePickerSettings);
builder.find(dateEndId)
.datepicker(oBaseDatePickerSettings);
builder.find(timeEndId)
.timepicker(oBaseTimePickerSettings);
var oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, var oRange = AIRTIME.utilities.fnGetScheduleRange(
dateEndId, timeEndId); dateStartId,
timeStartId,
dateEndId,
timeEndId
);
AIRTIME.showbuilder.fnServerData.start = oRange.start; AIRTIME.showbuilder.fnServerData.start = oRange.start;
AIRTIME.showbuilder.fnServerData.end = oRange.end; AIRTIME.showbuilder.fnServerData.end = oRange.end;
} }
@ -177,9 +176,9 @@ function buildScheduleDialog (json, instance_id) {
click: function () { click: function () {
$(this).dialog("close"); $(this).dialog("close");
//getUsabilityHint(); //getUsabilityHint();
} },
} },
] ],
}); });
//set the start end times so the builder datatables knows its time range. //set the start end times so the builder datatables knows its time range.
@ -193,7 +192,7 @@ function buildScheduleDialog (json, instance_id) {
AIRTIME.library.libraryInit(); AIRTIME.library.libraryInit();
AIRTIME.showbuilder.builderDataTable(); AIRTIME.showbuilder.builderDataTable();
dialog.dialog('open'); dialog.dialog("open");
highlightMediaTypeSelector(dialog); highlightMediaTypeSelector(dialog);
buildTimerange(dialog); buildTimerange(dialog);
} }
@ -201,15 +200,15 @@ function buildScheduleDialog (json, instance_id) {
function buildContentDialog(json) { function buildContentDialog(json) {
var dialog = $(json.dialog), var dialog = $(json.dialog),
viewport = findViewportDimensions(), viewport = findViewportDimensions(),
height = viewport.height * 2/3, height = (viewport.height * 2) / 3,
width = viewport.width * 4/5; width = (viewport.width * 4) / 5;
if (json.show_error == true) { if (json.show_error == true) {
alertShowErrorAndReload(); alertShowErrorAndReload();
} }
dialog.find("#show_progressbar").progressbar({ dialog.find("#show_progressbar").progressbar({
value: json.percentFilled value: json.percentFilled,
}); });
dialog.dialog({ dialog.dialog({
@ -222,15 +221,15 @@ function buildContentDialog (json){
buttons: [ buttons: [
{ {
text: $.i18n._("Ok"), text: $.i18n._("Ok"),
"class": "btn", class: "btn",
click: function () { click: function () {
dialog.remove(); dialog.remove();
} },
} },
] ],
}); });
dialog.dialog('open'); dialog.dialog("open");
} }
/** /**
@ -248,66 +247,65 @@ function getTimeIntervalPreference(data) {
} }
function createFullCalendar(data) { function createFullCalendar(data) {
serverTimezoneOffset = data.calendarInit.timezoneOffset; serverTimezoneOffset = data.calendarInit.timezoneOffset;
var mainHeight = $(window).height() - 200 - 35; var mainHeight = $(window).height() - 200 - 35;
$('#schedule_calendar').fullCalendar({ $("#schedule_calendar").fullCalendar({
header: { header: {
left: 'prev, next, today', left: "prev, next, today",
center: 'title', center: "title",
right: 'agendaDay, agendaWeek, month' right: "agendaDay, agendaWeek, month",
}, },
defaultView: getTimeScalePreference(data), defaultView: getTimeScalePreference(data),
slotMinutes: getTimeIntervalPreference(data), slotMinutes: getTimeIntervalPreference(data),
firstDay: data.calendarInit.weekStartDay, firstDay: data.calendarInit.weekStartDay,
editable: false, editable: false,
allDaySlot: false, allDaySlot: false,
axisFormat: 'H:mm', axisFormat: "H:mm",
timeFormat: { timeFormat: {
agenda: 'H:mm{ - H:mm}', agenda: "H:mm{ - H:mm}",
month: 'H:mm{ - H:mm}' month: "H:mm{ - H:mm}",
}, },
//i18n_months is in common.js //i18n_months is in common.js
monthNames: i18n_months, monthNames: i18n_months,
monthNamesShort: [ monthNamesShort: [
$.i18n._('Jan'), $.i18n._("Jan"),
$.i18n._('Feb'), $.i18n._("Feb"),
$.i18n._('Mar'), $.i18n._("Mar"),
$.i18n._('Apr'), $.i18n._("Apr"),
$.i18n._('May'), $.i18n._("May"),
$.i18n._('Jun'), $.i18n._("Jun"),
$.i18n._('Jul'), $.i18n._("Jul"),
$.i18n._('Aug'), $.i18n._("Aug"),
$.i18n._('Sep'), $.i18n._("Sep"),
$.i18n._('Oct'), $.i18n._("Oct"),
$.i18n._('Nov'), $.i18n._("Nov"),
$.i18n._('Dec') $.i18n._("Dec"),
], ],
buttonText: { buttonText: {
today: $.i18n._('Today'), today: $.i18n._("Today"),
month: $.i18n._('Month'), month: $.i18n._("Month"),
week: $.i18n._('Week'), week: $.i18n._("Week"),
day: $.i18n._('Day') day: $.i18n._("Day"),
}, },
dayNames: [ dayNames: [
$.i18n._('Sunday'), $.i18n._("Sunday"),
$.i18n._('Monday'), $.i18n._("Monday"),
$.i18n._('Tuesday'), $.i18n._("Tuesday"),
$.i18n._('Wednesday'), $.i18n._("Wednesday"),
$.i18n._('Thursday'), $.i18n._("Thursday"),
$.i18n._('Friday'), $.i18n._("Friday"),
$.i18n._('Saturday') $.i18n._("Saturday"),
], ],
dayNamesShort: [ dayNamesShort: [
$.i18n._('Sun'), $.i18n._("Sun"),
$.i18n._('Mon'), $.i18n._("Mon"),
$.i18n._('Tue'), $.i18n._("Tue"),
$.i18n._('Wed'), $.i18n._("Wed"),
$.i18n._('Thu'), $.i18n._("Thu"),
$.i18n._('Fri'), $.i18n._("Fri"),
$.i18n._('Sat') $.i18n._("Sat"),
], ],
contentHeight: mainHeight, contentHeight: mainHeight,
theme: true, theme: true,
@ -324,7 +322,7 @@ function createFullCalendar(data){
eventAfterRender: eventAfterRender, eventAfterRender: eventAfterRender,
eventDrop: eventDrop, eventDrop: eventDrop,
eventResize: eventResize, eventResize: eventResize,
windowResize: windowResize windowResize: windowResize,
}); });
} }
@ -336,29 +334,28 @@ function alertShowErrorAndReload(){
} }
$(document).ready(function () { $(document).ready(function () {
$.contextMenu({ $.contextMenu({
selector: 'div.fc-event', selector: "div.fc-event",
trigger: "left", trigger: "left",
ignoreRightClick: true, ignoreRightClick: true,
className: 'calendar-context-menu', className: "calendar-context-menu",
build: function ($el, e) { build: function ($el, e) {
var data, var data, items, callback;
items,
callback;
data = $el.data("event"); data = $el.data("event");
function processMenuItems(oItems) { function processMenuItems(oItems) {
//define a schedule callback. //define a schedule callback.
if (oItems.schedule !== undefined) { if (oItems.schedule !== undefined) {
callback = function () { callback = function () {
$.post(oItems.schedule.url, {format: "json", id: data.id}, function(json){ $.post(
oItems.schedule.url,
{ format: "json", id: data.id },
function (json) {
buildScheduleDialog(json, data.id); buildScheduleDialog(json, data.id);
}); }
);
}; };
oItems.schedule.callback = callback; oItems.schedule.callback = callback;
@ -366,12 +363,15 @@ $(document).ready(function() {
//define a clear callback. //define a clear callback.
if (oItems.clear !== undefined) { if (oItems.clear !== undefined) {
callback = function () { callback = function () {
if (confirm($.i18n._("Remove all content?"))) { if (confirm($.i18n._("Remove all content?"))) {
$.post(oItems.clear.url, {format: "json", id: data.id}, function(json){ $.post(
oItems.clear.url,
{ format: "json", id: data.id },
function (json) {
scheduleRefetchEvents(json); scheduleRefetchEvents(json);
}); }
);
} }
}; };
oItems.clear.callback = callback; oItems.clear.callback = callback;
@ -382,27 +382,53 @@ $(document).ready(function() {
if (oItems.edit.items !== undefined) { if (oItems.edit.items !== undefined) {
var edit = oItems.edit.items; var edit = oItems.edit.items;
//edit a single instance //edit a single instance
callback = function () { callback = function () {
$.get(edit.instance.url, {format: "json", showId: data.showId, instanceId: data.id, type: "instance"}, function(json){ $.get(
edit.instance.url,
{
format: "json",
showId: data.showId,
instanceId: data.id,
type: "instance",
},
function (json) {
beginEditShow(json); beginEditShow(json);
}); }
);
}; };
edit.instance.callback = callback; edit.instance.callback = callback;
//edit this instance and all //edit this instance and all
callback = function () { callback = function () {
$.get(edit.all.url, {format: "json", showId: data.showId, instanceId: data.id, type: "all"}, function(json){ $.get(
edit.all.url,
{
format: "json",
showId: data.showId,
instanceId: data.id,
type: "all",
},
function (json) {
beginEditShow(json); beginEditShow(json);
}); }
);
}; };
edit.all.callback = callback; edit.all.callback = callback;
} else { } else {
callback = function () { callback = function () {
$.get(oItems.edit.url, {format: "json", showId: data.showId, instanceId: data.id, type: oItems.edit._type}, function(json){ $.get(
oItems.edit.url,
{
format: "json",
showId: data.showId,
instanceId: data.id,
type: oItems.edit._type,
},
function (json) {
beginEditShow(json); beginEditShow(json);
}); }
);
}; };
oItems.edit.callback = callback; oItems.edit.callback = callback;
} }
@ -410,18 +436,20 @@ $(document).ready(function() {
//define a content callback. //define a content callback.
if (oItems.content !== undefined) { if (oItems.content !== undefined) {
callback = function () { callback = function () {
$.get(oItems.content.url, {format: "json", id: data.id}, function(json){ $.get(
oItems.content.url,
{ format: "json", id: data.id },
function (json) {
buildContentDialog(json); buildContentDialog(json);
}); }
);
}; };
oItems.content.callback = callback; oItems.content.callback = callback;
} }
//define a cancel recorded show callback. //define a cancel recorded show callback.
if (oItems.cancel_recorded !== undefined) { if (oItems.cancel_recorded !== undefined) {
callback = function () { callback = function () {
confirmCancelRecordedShow(data.id); confirmCancelRecordedShow(data.id);
}; };
@ -431,17 +459,20 @@ $(document).ready(function() {
//define a view recorded callback. //define a view recorded callback.
if (oItems.view_recorded !== undefined) { if (oItems.view_recorded !== undefined) {
callback = function () { callback = function () {
$.get(oItems.view_recorded.url, {format: "json"}, function(json){ $.get(
oItems.view_recorded.url,
{ format: "json" },
function (json) {
//in library.js //in library.js
buildEditMetadataDialog(json); buildEditMetadataDialog(json);
}); }
);
}; };
oItems.view_recorded.callback = callback; oItems.view_recorded.callback = callback;
} }
//define a cancel callback. //define a cancel callback.
if (oItems.cancel !== undefined) { if (oItems.cancel !== undefined) {
callback = function () { callback = function () {
confirmCancelShow(data.id); confirmCancelShow(data.id);
}; };
@ -450,34 +481,44 @@ $(document).ready(function() {
//define a delete callback. //define a delete callback.
if (oItems.del !== undefined) { if (oItems.del !== undefined) {
//repeating show multiple delete options //repeating show multiple delete options
if (oItems.del.items !== undefined) { if (oItems.del.items !== undefined) {
var del = oItems.del.items; var del = oItems.del.items;
//delete a single instance //delete a single instance
callback = function () { callback = function () {
$.post(del.single.url, {format: "json", id: data.id}, function(json){ $.post(
del.single.url,
{ format: "json", id: data.id },
function (json) {
scheduleRefetchEvents(json); scheduleRefetchEvents(json);
}); }
);
}; };
del.single.callback = callback; del.single.callback = callback;
//delete this instance and all following instances. //delete this instance and all following instances.
callback = function () { callback = function () {
$.post(del.following.url, {format: "json", id: data.id}, function(json){ $.post(
del.following.url,
{ format: "json", id: data.id },
function (json) {
scheduleRefetchEvents(json); scheduleRefetchEvents(json);
}); }
);
}; };
del.following.callback = callback; del.following.callback = callback;
} }
//single show //single show
else { else {
callback = function () { callback = function () {
$.post(oItems.del.url, {format: "json", id: data.id}, function(json){ $.post(
oItems.del.url,
{ format: "json", id: data.id },
function (json) {
scheduleRefetchEvents(json); scheduleRefetchEvents(json);
}); }
);
}; };
oItems.del.callback = callback; oItems.del.callback = callback;
} }
@ -494,18 +535,25 @@ $(document).ready(function() {
async: false, async: false,
success: function (json) { success: function (json) {
processMenuItems(json.items); processMenuItems(json.items);
} },
}); });
return { return {
className: 'calendar-context-menu', className: "calendar-context-menu",
items: items, items: items,
determinePosition: function ($menu, x, y) { determinePosition: function ($menu, x, y) {
$menu.css('display', 'block') $menu
.position({ my: "left top", at: "right top", of: this, offset: "-20 10", collision: "fit"}) .css("display", "block")
.css('display', 'none'); .position({
} my: "left top",
at: "right top",
of: this,
offset: "-20 10",
collision: "fit",
})
.css("display", "none");
},
}; };
} },
}); });
}); });

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,4 @@
AIRTIME = (function (AIRTIME) { AIRTIME = (function (AIRTIME) {
var viewport, var viewport,
$lib, $lib,
$libWrapper, $libWrapper,
@ -23,14 +22,14 @@ AIRTIME = (function(AIRTIME) {
mod = AIRTIME.builderMain; mod = AIRTIME.builderMain;
oBaseDatePickerSettings = { oBaseDatePickerSettings = {
dateFormat: 'yy-mm-dd', dateFormat: "yy-mm-dd",
//i18n_months, i18n_days_short are in common.js //i18n_months, i18n_days_short are in common.js
monthNames: i18n_months, monthNames: i18n_months,
dayNamesMin: i18n_days_short, dayNamesMin: i18n_days_short,
onClick: function (sDate, oDatePicker) { onClick: function (sDate, oDatePicker) {
$(this).datepicker("setDate", sDate); $(this).datepicker("setDate", sDate);
}, },
onClose: validateTimeRange onClose: validateTimeRange,
}; };
oBaseTimePickerSettings = { oBaseTimePickerSettings = {
@ -38,10 +37,10 @@ AIRTIME = (function(AIRTIME) {
showCloseButton: true, showCloseButton: true,
closeButtonText: $.i18n._("Done"), closeButtonText: $.i18n._("Done"),
showLeadingZero: false, showLeadingZero: false,
defaultTime: '0:00', defaultTime: "0:00",
hourText: $.i18n._("Hour"), hourText: $.i18n._("Hour"),
minuteText: $.i18n._("Minute"), minuteText: $.i18n._("Minute"),
onClose: validateTimeRange onClose: validateTimeRange,
}; };
function setWidgetSize() { function setWidgetSize() {
@ -53,7 +52,7 @@ AIRTIME = (function(AIRTIME) {
builderTableHeight = widgetHeight - 95, builderTableHeight = widgetHeight - 95,
oTable; oTable;
if ($fs.is(':visible')) { if ($fs.is(":visible")) {
builderTableHeight = builderTableHeight - 40; builderTableHeight = builderTableHeight - 40;
} }
@ -69,8 +68,7 @@ AIRTIME = (function(AIRTIME) {
//.css("max-height", libTableHeight) //.css("max-height", libTableHeight)
.end(); .end();
if ($lib.filter(':visible').length > 0) { if ($lib.filter(":visible").length > 0) {
//$lib.width(Math.floor(screenWidth * 0.47)); //$lib.width(Math.floor(screenWidth * 0.47));
$builder //.width(Math.floor(screenWidth * 0.47)) $builder //.width(Math.floor(screenWidth * 0.47))
@ -81,7 +79,7 @@ AIRTIME = (function(AIRTIME) {
.css("margin-left", 0) .css("margin-left", 0)
.end(); .end();
oTable = $('#show_builder_table').dataTable(); oTable = $("#show_builder_table").dataTable();
//oTable.fnDraw(); //oTable.fnDraw();
} }
} }
@ -89,7 +87,7 @@ AIRTIME = (function(AIRTIME) {
function showSearchSubmit() { function showSearchSubmit() {
var fn, var fn,
op, op,
oTable = $('#show_builder_table').dataTable(), oTable = $("#show_builder_table").dataTable(),
check; check;
check = validateTimeRange(); check = validateTimeRange();
@ -104,21 +102,19 @@ AIRTIME = (function(AIRTIME) {
op = $("div.sb-options-form"); op = $("div.sb-options-form");
if (op.is(":visible")) { if (op.is(":visible")) {
if (fn.ops === undefined) { if (fn.ops === undefined) {
fn.ops = {}; fn.ops = {};
} }
fn.ops.showFilter = op.find("#sb_show_filter").val(); fn.ops.showFilter = op.find("#sb_show_filter").val();
// Hacky? // Hacky?
fn.ops.myShows = (fn.ops.showFilter == -1) ? 1 : 0; fn.ops.myShows = fn.ops.showFilter == -1 ? 1 : 0;
} }
oTable.fnDraw(); oTable.fnDraw();
} }
} }
function highlightMediaTypeSelector() function highlightMediaTypeSelector() {
{
$(".media_type_selector:first").addClass("highlight"); $(".media_type_selector:first").addClass("highlight");
var selected; var selected;
if (location.hash === "") { if (location.hash === "") {
@ -131,12 +127,15 @@ AIRTIME = (function(AIRTIME) {
selected.parent().addClass("selected"); selected.parent().addClass("selected");
$("#library_filter").text(selected.text()); $("#library_filter").text(selected.text());
$(window).on('hashchange', function() { $(window).on("hashchange", function () {
var selected = $("a[href$='" + location.hash + "']"), var selected = $("a[href$='" + location.hash + "']"),
dashboardLink = $(".media_type_selector:first"), dashboardLink = $(".media_type_selector:first"),
tableType; tableType;
if (selected.parent().data("selection-id") == AIRTIME.library.MediaTypeIntegerEnum.PODCAST) { if (
selected.parent().data("selection-id") ==
AIRTIME.library.MediaTypeIntegerEnum.PODCAST
) {
tableType = AIRTIME.library.DataTableTypeEnum.PODCAST; tableType = AIRTIME.library.DataTableTypeEnum.PODCAST;
} else { } else {
tableType = AIRTIME.library.DataTableTypeEnum.LIBRARY; tableType = AIRTIME.library.DataTableTypeEnum.LIBRARY;
@ -155,12 +154,11 @@ AIRTIME = (function(AIRTIME) {
}); });
} }
mod.onReady = function () { mod.onReady = function () {
// Normally we would just use audio/*, but it includes file types that we can't handle (like .m4a) // Normally we would just use audio/*, but it includes file types that we can't handle (like .m4a)
// We initialize the acceptedMimeTypes variable in Bootstrap so we don't have to duplicate the list // We initialize the acceptedMimeTypes variable in Bootstrap so we don't have to duplicate the list
Dropzone.options.content = { Dropzone.options.content = {
url:'/rest/media', url: "/rest/media",
clickable: false, clickable: false,
acceptedFiles: acceptedMimeTypes.join(), acceptedFiles: acceptedMimeTypes.join(),
init: function () { init: function () {
@ -168,21 +166,21 @@ AIRTIME = (function(AIRTIME) {
data.append("csrf_token", $("#csrf").val()); data.append("csrf_token", $("#csrf").val());
}); });
}, },
dictDefaultMessage: '', dictDefaultMessage: "",
createImageThumbnails: false, createImageThumbnails: false,
previewTemplate : '<div style="display:none"></div>' previewTemplate: '<div style="display:none"></div>',
}; };
// define module vars. // define module vars.
$lib = $("#library_content"); $lib = $("#library_content");
$builder = $("#show_builder"); $builder = $("#show_builder");
$fs = $builder.find('fieldset'); $fs = $builder.find("fieldset");
//Highlight the media type selector we're currently on. //Highlight the media type selector we're currently on.
highlightMediaTypeSelector(); highlightMediaTypeSelector();
// always re-show builder if dashboard button was clicked // always re-show builder if dashboard button was clicked
$('.media_type_selector:first').on('click', function() { $(".media_type_selector:first").on("click", function () {
$builder.show(); $builder.show();
AIRTIME.tabs.openScheduleTab(); AIRTIME.tabs.openScheduleTab();
}); });
@ -197,25 +195,32 @@ AIRTIME = (function(AIRTIME) {
$(this).removeClass("ui-state-hover"); $(this).removeClass("ui-state-hover");
}); });
$builder.find(dateStartId) $builder
.find(dateStartId)
.datepicker(oBaseDatePickerSettings) .datepicker(oBaseDatePickerSettings)
.blur(validateTimeRange); .blur(validateTimeRange);
$builder.find(timeStartId) $builder
.find(timeStartId)
.timepicker(oBaseTimePickerSettings) .timepicker(oBaseTimePickerSettings)
.blur(validateTimeRange); .blur(validateTimeRange);
$builder.find(dateEndId) $builder
.find(dateEndId)
.datepicker(oBaseDatePickerSettings) .datepicker(oBaseDatePickerSettings)
.blur(validateTimeRange); .blur(validateTimeRange);
$builder.find(timeEndId) $builder
.find(timeEndId)
.timepicker(oBaseTimePickerSettings) .timepicker(oBaseTimePickerSettings)
.blur(validateTimeRange); .blur(validateTimeRange);
oRange = AIRTIME.utilities.fnGetScheduleRange(
oRange = AIRTIME.utilities.fnGetScheduleRange(dateStartId, timeStartId, dateStartId,
dateEndId, timeEndId); timeStartId,
dateEndId,
timeEndId
);
AIRTIME.showbuilder.fnServerData.start = oRange.start; AIRTIME.showbuilder.fnServerData.start = oRange.start;
AIRTIME.showbuilder.fnServerData.end = oRange.end; AIRTIME.showbuilder.fnServerData.end = oRange.end;
@ -241,9 +246,14 @@ AIRTIME = (function(AIRTIME) {
$lib.show().width(Math.floor(screenWidth * 0.48)); $lib.show().width(Math.floor(screenWidth * 0.48));
$builder.width(Math.floor(screenWidth * 0.48)).find("#sb_edit") $builder
.remove().end().find("#sb_date_start") .width(Math.floor(screenWidth * 0.48))
.css("margin-left", 0).end(); .find("#sb_edit")
.remove()
.end()
.find("#sb_date_start")
.css("margin-left", 0)
.end();
schedTable.fnDraw(); schedTable.fnDraw();
@ -252,13 +262,12 @@ AIRTIME = (function(AIRTIME) {
type: "POST", type: "POST",
data: { data: {
settings: { settings: {
library : true library: true,
}, },
format : "json" format: "json",
}, },
dataType: "json", dataType: "json",
success : function() { success: function () {},
}
}); });
}); });
@ -266,8 +275,13 @@ AIRTIME = (function(AIRTIME) {
var schedTable = $("#show_builder_table").dataTable(); var schedTable = $("#show_builder_table").dataTable();
$lib.hide(); $lib.hide();
$builder.width(screenWidth).find(".sb-timerange").find("#sb_date_start").css("margin-left", 30) $builder
.end().end(); .width(screenWidth)
.find(".sb-timerange")
.find("#sb_date_start")
.css("margin-left", 30)
.end()
.end();
schedTable.fnDraw(); schedTable.fnDraw();
@ -276,21 +290,17 @@ AIRTIME = (function(AIRTIME) {
type: "POST", type: "POST",
data: { data: {
settings: { settings: {
library : false library: false,
}, },
format : "json" format: "json",
}, },
dataType: "json", dataType: "json",
success : function() { success: function () {},
}
}); });
}); });
$builder.find('legend').click( $builder.find("legend").click(function (ev, item) {
function(ev, item) {
if ($fs.hasClass("closed")) { if ($fs.hasClass("closed")) {
$fs.removeClass("closed"); $fs.removeClass("closed");
//$builder.find('.dataTables_scrolling').css( //$builder.find('.dataTables_scrolling').css(
// "max-height", widgetHeight - 150); // "max-height", widgetHeight - 150);
@ -298,9 +308,8 @@ AIRTIME = (function(AIRTIME) {
$fs.addClass("closed"); $fs.addClass("closed");
// set defaults for the options. // set defaults for the options.
$fs.find('select').val(0); $fs.find("select").val(0);
$fs.find('input[type="checkbox"]').attr("checked", $fs.find('input[type="checkbox"]').attr("checked", false);
false);
//$builder.find('.dataTables_scrolling').css( //$builder.find('.dataTables_scrolling').css(
// "max-height", widgetHeight - 110); // "max-height", widgetHeight - 110);
} }
@ -308,29 +317,28 @@ AIRTIME = (function(AIRTIME) {
// set click event for all my shows checkbox. // set click event for all my shows checkbox.
$builder.on("click", "#sb_my_shows", function (ev) { $builder.on("click", "#sb_my_shows", function (ev) {
if ($(this).is(":checked")) {
if ($(this).is(':checked')) { $(ev.delegateTarget).find("#sb_show_filter").val(0);
$(ev.delegateTarget).find('#sb_show_filter').val(0);
} }
showSearchSubmit(); showSearchSubmit();
}); });
//set select event for choosing a show. //set select event for choosing a show.
$builder.on("change", '#sb_show_filter', function(ev) { $builder.on("change", "#sb_show_filter", function (ev) {
if ($(this).val() !== 0) { if ($(this).val() !== 0) {
$(ev.delegateTarget).find('#sb_my_shows') $(ev.delegateTarget).find("#sb_my_shows").attr("checked", false);
.attr("checked", false);
} }
showSearchSubmit(); showSearchSubmit();
}); });
function checkScheduleUpdates() { function checkScheduleUpdates() {
var data = {}, oTable = $('#show_builder_table').dataTable(), fn = oTable var data = {},
.fnSettings().fnServerData, start = fn.start, end = fn.end; oTable = $("#show_builder_table").dataTable(),
fn = oTable.fnSettings().fnServerData,
start = fn.start,
end = fn.end;
data["format"] = "json"; data["format"] = "json";
data["start"] = start; data["start"] = start;
@ -345,16 +353,16 @@ AIRTIME = (function(AIRTIME) {
} }
$.ajax({ $.ajax({
"dataType" : "json", dataType: "json",
"type" : "GET", type: "GET",
"url" : baseUrl+"showbuilder/check-builder-feed", url: baseUrl + "showbuilder/check-builder-feed",
"data" : data, data: data,
"success" : function(json) { success: function (json) {
if (json.update === true) { if (json.update === true) {
oTable.fnDraw(); oTable.fnDraw();
} }
setTimeout(checkScheduleUpdates, 5000); setTimeout(checkScheduleUpdates, 5000);
} },
}); });
//check if the timeline view needs updating. //check if the timeline view needs updating.
@ -363,14 +371,12 @@ AIRTIME = (function(AIRTIME) {
}; };
mod.onResize = function () { mod.onResize = function () {
clearTimeout(resizeTimeout); clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(setWidgetSize, 100); resizeTimeout = setTimeout(setWidgetSize, 100);
}; };
return AIRTIME; return AIRTIME;
})(AIRTIME || {});
} (AIRTIME || {}));
$(document).ready(AIRTIME.builderMain.onReady); $(document).ready(AIRTIME.builderMain.onReady);
$(window).resize(AIRTIME.builderMain.onResize); $(window).resize(AIRTIME.builderMain.onResize);

View File

@ -70,15 +70,30 @@ var AIRTIME = (function(AIRTIME){
self.uid = uid; self.uid = uid;
// TODO: clean this up a bit and use js instead of strings to create elements // TODO: clean this up a bit and use js instead of strings to create elements
var wrapper = "<div data-tab-id='" + self.id + "' id='pl-tab-content-" + self.id + "' class='side_playlist pl-content'><div class='editor_pane_wrapper'></div></div>", var wrapper =
t = $("#show_builder").append(wrapper).find("#pl-tab-content-" + self.id), "<div data-tab-id='" +
self.id +
"' id='pl-tab-content-" +
self.id +
"' class='side_playlist pl-content'><div class='editor_pane_wrapper'></div></div>",
t = $("#show_builder")
.append(wrapper)
.find("#pl-tab-content-" + self.id),
pane = $(".editor_pane_wrapper:last").append(html), pane = $(".editor_pane_wrapper:last").append(html),
name = pane.find("#track_title").length > 0 ? pane.find("#track_title").val() + $.i18n._(" - Metadata Editor") name =
pane.find("#track_title").length > 0
? pane.find("#track_title").val() + $.i18n._(" - Metadata Editor")
: pane.find(".playlist_name_display").val(), : pane.find(".playlist_name_display").val(),
tab = tab =
"<li data-tab-id='" + self.id + "' id='pl-tab-" + self.id + "' role='presentation' class='active'>" + "<li data-tab-id='" +
self.id +
"' id='pl-tab-" +
self.id +
"' role='presentation' class='active'>" +
"<a href='javascript:void(0)'>" + "<a href='javascript:void(0)'>" +
"<span class='tab-name'>" + name + "</span>" + "<span class='tab-name'>" +
name +
"</span>" +
"<span href='#' class='lib_pl_close icon-remove'></span>" + "<span href='#' class='lib_pl_close icon-remove'></span>" +
"</a>" + "</a>" +
"</li>", "</li>",
@ -111,7 +126,7 @@ var AIRTIME = (function(AIRTIME){
Tab.prototype._init = function () { Tab.prototype._init = function () {
var self = this; var self = this;
self.assignTabClickHandler(function (e) { self.assignTabClickHandler(function (e) {
if (!$(this).hasClass('active')) { if (!$(this).hasClass("active")) {
self.switchTo(); self.switchTo();
} }
}); });
@ -130,9 +145,9 @@ var AIRTIME = (function(AIRTIME){
self.contents.on("click", ".toggle-editor-form", function (event) { self.contents.on("click", ".toggle-editor-form", function (event) {
self.contents.find(".inner_editor_wrapper").slideToggle(200); self.contents.find(".inner_editor_wrapper").slideToggle(200);
var buttonIcon = $(this).find('.icon-white'); var buttonIcon = $(this).find(".icon-white");
buttonIcon.toggleClass('icon-chevron-up'); buttonIcon.toggleClass("icon-chevron-up");
buttonIcon.toggleClass('icon-chevron-down'); buttonIcon.toggleClass("icon-chevron-down");
}); });
}; };
@ -206,9 +221,14 @@ var AIRTIME = (function(AIRTIME){
Tab.prototype.close = function () { Tab.prototype.close = function () {
var self = this; var self = this;
var ascTabs = Object.keys($openTabs).sort(function(a, b){return a-b}), var ascTabs = Object.keys($openTabs).sort(function (a, b) {
return a - b;
}),
pos = ascTabs.indexOf(self.uid), pos = ascTabs.indexOf(self.uid),
toTab = pos < ascTabs.length-1 ? $openTabs[ascTabs[++pos]] : $openTabs[ascTabs[--pos]]; toTab =
pos < ascTabs.length - 1
? $openTabs[ascTabs[++pos]]
: $openTabs[ascTabs[--pos]];
delete $openTabs[self.uid]; // Remove this tab from the open tab array delete $openTabs[self.uid]; // Remove this tab from the open tab array
delete $tabMap[self.id]; // Remove this tab from the internal tab mapping delete $tabMap[self.id]; // Remove this tab from the internal tab mapping
@ -222,15 +242,15 @@ var AIRTIME = (function(AIRTIME){
self.contents.hide(); self.contents.hide();
} }
if (self.isActive() && toTab) {
if (self.isActive() && toTab) { // Closing the current tab, otherwise we don't need to switch tabs // Closing the current tab, otherwise we don't need to switch tabs
toTab.switchTo(); toTab.switchTo();
} else { } else {
mod.onResize(); mod.onResize();
} }
if (Object.keys($openTabs).length < 1) { if (Object.keys($openTabs).length < 1) {
$('#show_builder').hide(); $("#show_builder").hide();
} }
self._destroy(); self._destroy();
@ -265,7 +285,8 @@ var AIRTIME = (function(AIRTIME){
* @constructor * @constructor
*/ */
var ScheduleTab = function () { var ScheduleTab = function () {
var self = this, uid = 0, var self = this,
uid = 0,
tab = $("#schedule-tab"), tab = $("#schedule-tab"),
pane = $("#show_builder"), pane = $("#show_builder"),
contents = pane.find(".outer-datatable-wrapper"); contents = pane.find(".outer-datatable-wrapper");
@ -321,7 +342,7 @@ var AIRTIME = (function(AIRTIME){
* @returns {Tab} the created Tab object * @returns {Tab} the created Tab object
*/ */
mod.openTab = function (html, uid, callback) { mod.openTab = function (html, uid, callback) {
$('#show_builder').show(); $("#show_builder").show();
var newTab = new Tab(html, uid); var newTab = new Tab(html, uid);
if (callback) callback(newTab); if (callback) callback(newTab);
return newTab; return newTab;
@ -334,7 +355,7 @@ var AIRTIME = (function(AIRTIME){
*/ */
mod.openScheduleTab = function () { mod.openScheduleTab = function () {
var $scheduleTab = this.getScheduleTab(); var $scheduleTab = this.getScheduleTab();
$('#show_builder').show(); $("#show_builder").show();
$openTabs[0] = $scheduleTab; $openTabs[0] = $scheduleTab;
$scheduleTab.tab.show(); $scheduleTab.tab.show();
$scheduleTab.contents.show(); $scheduleTab.contents.show();
@ -409,8 +430,7 @@ var AIRTIME = (function(AIRTIME){
mod.Tab = Tab; mod.Tab = Tab;
return AIRTIME; return AIRTIME;
})(AIRTIME || {});
}(AIRTIME || {}));
$(document).ready(function () { $(document).ready(function () {
var sb = $("#show_builder"); var sb = $("#show_builder");
@ -418,7 +438,7 @@ $(document).ready(function() {
sb.addTitles(".tab-name"); sb.addTitles(".tab-name");
sb.find(".nav.nav-tabs").sortable({ sb.find(".nav.nav-tabs").sortable({
containment: "parent", containment: "parent",
distance: 25 distance: 25,
}); });
// Initialize the ScheduleTab // Initialize the ScheduleTab
AIRTIME.tabs.initScheduleTab(); AIRTIME.tabs.initScheduleTab();

View File

@ -1,44 +1,54 @@
function generatePartitions(partitions) { function generatePartitions(partitions) {
var rowTemplate = var rowTemplate =
'<tr class="partition-info">' + '<tr class="partition-info">' +
'<td><span class="strong">'+$.i18n._("Disk")+' #%s</span>'+ '<td><span class="strong">' +
$.i18n._("Disk") +
" #%s</span>" +
'<ul id="watched-dir-list-%s">' + '<ul id="watched-dir-list-%s">' +
'</ul>'+ "</ul>" +
'</td>'+ "</td>" +
'<td>%sGB of %sGB</td>'+ "<td>%sGB of %sGB</td>" +
'<td colspan="3">' + '<td colspan="3">' +
'<div class="big">' + '<div class="big">' +
'<div class="diskspace" style="width:%s%%;">' + '<div class="diskspace" style="width:%s%%;">' +
'</div>'+ "</div>" +
'</div>'+ "</div>" +
'<div>%s%% '+$.i18n._("in use")+'</div>'+ "<div>%s%% " +
'</td>'+ $.i18n._("in use") +
'</tr>'; "</div>" +
"</td>" +
"</tr>";
$(".partition-info").remove(); $(".partition-info").remove();
var lastElement = $('#partitions'); var lastElement = $("#partitions");
for (var i = 0; i < partitions.length; i++) { for (var i = 0; i < partitions.length; i++) {
var spaceUsed = partitions[i].totalSpace - partitions[i].totalFreeSpace; var spaceUsed = partitions[i].totalSpace - partitions[i].totalFreeSpace;
var totalSpace = partitions[i].totalSpace; var totalSpace = partitions[i].totalSpace;
var percUsed = sprintf("%01.1f", spaceUsed/totalSpace*100); var percUsed = sprintf("%01.1f", (spaceUsed / totalSpace) * 100);
var spaceUsedGb = sprintf("%01.1f", spaceUsed / Math.pow(2, 30)); var spaceUsedGb = sprintf("%01.1f", spaceUsed / Math.pow(2, 30));
var totalSpaceGb = sprintf("%01.1f", totalSpace / Math.pow(2, 30)); var totalSpaceGb = sprintf("%01.1f", totalSpace / Math.pow(2, 30));
var row = sprintf(rowTemplate, i+1, i, spaceUsedGb, totalSpaceGb, percUsed, percUsed); var row = sprintf(
rowTemplate,
i + 1,
i,
spaceUsedGb,
totalSpaceGb,
percUsed,
percUsed
);
var tr = $(row); var tr = $(row);
lastElement.after(tr); lastElement.after(tr);
if (partitions[i].dirs) { if (partitions[i].dirs) {
var watched_dirs_ul = $('#watched-dir-list-'+i); var watched_dirs_ul = $("#watched-dir-list-" + i);
for (var j = 0; j < partitions[i].dirs.length; j++) { for (var j = 0; j < partitions[i].dirs.length; j++) {
watched_dirs_ul.append('<li>'+partitions[i].dirs[j]+'</li>'); watched_dirs_ul.append("<li>" + partitions[i].dirs[j] + "</li>");
} }
} }
lastElement = tr; lastElement = tr;
} }
} }
function success(data, textStatus, jqXHR) { function success(data, textStatus, jqXHR) {
@ -58,20 +68,32 @@ function success(data, textStatus, jqXHR){
} }
$($(children[1]).children()[0]).attr("class", status_class); $($(children[1]).children()[0]).attr("class", status_class);
$(children[2]).text(sprintf('%(days)sd %(hours)sh %(minutes)sm %(seconds)ss', convertSecondsToDaysHoursMinutesSeconds(s.uptime_seconds))); $(children[2]).text(
sprintf(
"%(days)sd %(hours)sh %(minutes)sm %(seconds)ss",
convertSecondsToDaysHoursMinutesSeconds(s.uptime_seconds)
)
);
$(children[3]).text(s.cpu_perc); $(children[3]).text(s.cpu_perc);
$(children[4]).text(sprintf('%01.1fMB (%s)', parseInt(s.memory_kb)/1000, s.memory_perc)); $(children[4]).text(
sprintf("%01.1fMB (%s)", parseInt(s.memory_kb) / 1000, s.memory_perc)
);
} }
} }
if (data.status.partitions) { if (data.status.partitions) {
generatePartitions(data.status.partitions); generatePartitions(data.status.partitions);
} }
setTimeout(function(){updateStatus(false);}, 5000); setTimeout(function () {
updateStatus(false);
}, 5000);
} }
function updateStatus(getDiskInfo) { function updateStatus(getDiskInfo) {
$.getJSON( baseUrl+"api/status/format/json/diskinfo/"+getDiskInfo, null, success); $.getJSON(
baseUrl + "api/status/format/json/diskinfo/" + getDiskInfo,
null,
success
);
} }
$(document).ready(function () { $(document).ready(function () {

View File

@ -1,146 +1,185 @@
function populateForm(entries) { function populateForm(entries) {
$(".errors").remove();
$(".success").remove();
$('.errors').remove(); $("#tracktype_id").val(entries.id);
$('.success').remove(); $("#code").val(entries.code);
$("#type_name").val(entries.type_name);
$('#tracktype_id').val(entries.id); $("#description").val(entries.description);
$('#code').val(entries.code);
$('#type_name').val(entries.type_name);
$('#description').val(entries.description);
if (entries.visibility) { if (entries.visibility) {
var visibility_value = 1; var visibility_value = 1;
} else { } else {
var visibility_value = 0; var visibility_value = 0;
} }
$('#visibility').val(visibility_value); $("#visibility").val(visibility_value);
if (entries.id.length != 0) { if (entries.id.length != 0) {
$('#code').attr('readonly', 'readonly'); $("#code").attr("readonly", "readonly");
} else { } else {
$('#code').removeAttr('readonly'); $("#code").removeAttr("readonly");
} }
} }
function rowClickCallback(row_id) { function rowClickCallback(row_id) {
$.ajax({ url: baseUrl+'Tracktype/get-tracktype-data/id/'+ row_id +'/format/json', dataType:"json", success:function(data){ $.ajax({
url: baseUrl + "Tracktype/get-tracktype-data/id/" + row_id + "/format/json",
dataType: "json",
success: function (data) {
populateForm(data.entries); populateForm(data.entries);
$("#tracktype_details").css("visibility", "visible"); $("#tracktype_details").css("visibility", "visible");
}}); },
});
} }
function removeTracktypeCallback(row_id, nRow) { function removeTracktypeCallback(row_id, nRow) {
if (confirm($.i18n._("Are you sure you want to delete this tracktype?"))) { if (confirm($.i18n._("Are you sure you want to delete this tracktype?"))) {
$.ajax({ $.ajax({
url: baseUrl + 'Tracktype/remove-tracktype/id/' + row_id + '/format/json', url: baseUrl + "Tracktype/remove-tracktype/id/" + row_id + "/format/json",
dataType: "text", dataType: "text",
success: function (data) { success: function (data) {
var o = $('#tracktypes_datatable').dataTable().fnDeleteRow(nRow); var o = $("#tracktypes_datatable").dataTable().fnDeleteRow(nRow);
} },
}); });
} }
} }
function rowCallback(nRow, aData, iDisplayIndex) { function rowCallback(nRow, aData, iDisplayIndex) {
$(nRow).click(function(){rowClickCallback(aData['id'])}); $(nRow).click(function () {
if( aData['delete'] != "self"){ rowClickCallback(aData["id"]);
$('td:eq(4)', nRow).append( '<span class="ui-icon ui-icon-closethick"></span>').children('span').click(function(e){e.stopPropagation(); removeTracktypeCallback(aData['id'], nRow)}); });
if (aData["delete"] != "self") {
$("td:eq(4)", nRow)
.append('<span class="ui-icon ui-icon-closethick"></span>')
.children("span")
.click(function (e) {
e.stopPropagation();
removeTracktypeCallback(aData["id"], nRow);
});
} else { } else {
$('td:eq(4)', nRow).empty().append( '<span class="ui-icon ui-icon-closethick"></span>').children('span').click(function(e){e.stopPropagation(); alert("Can't delete yourself!")}); $("td:eq(4)", nRow)
.empty()
.append('<span class="ui-icon ui-icon-closethick"></span>')
.children("span")
.click(function (e) {
e.stopPropagation();
alert("Can't delete yourself!");
});
} }
if ( aData['visibility'] == "1" ) { if (aData["visibility"] == "1") {
$('td:eq(3)', nRow).html( $.i18n._('Enabled') ); $("td:eq(3)", nRow).html($.i18n._("Enabled"));
} else { } else {
$('td:eq(3)', nRow).html( $.i18n._('Disabled') ); $("td:eq(3)", nRow).html($.i18n._("Disabled"));
} }
return nRow; return nRow;
} }
function populateTracktypeTable() { function populateTracktypeTable() {
var dt = $('#tracktypes_datatable'); var dt = $("#tracktypes_datatable");
dt.dataTable({ dt.dataTable({
"bProcessing": true, bProcessing: true,
"bServerSide": true, bServerSide: true,
"sAjaxSource": baseUrl+"Tracktype/get-tracktype-data-table-info/format/json", sAjaxSource:
"fnServerData": function ( sSource, aoData, fnCallback ) { baseUrl + "Tracktype/get-tracktype-data-table-info/format/json",
fnServerData: function (sSource, aoData, fnCallback) {
$.ajax({ $.ajax({
"dataType": 'json', dataType: "json",
"type": "POST", type: "POST",
"url": sSource, url: sSource,
"data": aoData, data: aoData,
"success": fnCallback success: fnCallback,
}); });
}, },
"fnRowCallback": rowCallback, fnRowCallback: rowCallback,
"aoColumns": [ aoColumns: [
/* Id */ { "sName": "id", "bSearchable": false, "bVisible": false, "mDataProp": "id" }, /* Id */ {
/* code */ { "sName": "code", "mDataProp": "code" }, sName: "id",
/* type_name */ { "sName": "type_name", "mDataProp": "type_name" }, bSearchable: false,
/* description */ { "sName": "description", "mDataProp": "description" }, bVisible: false,
/* visibility */ { "sName": "visibility", "bSearchable": false, "mDataProp": "visibility" }, mDataProp: "id",
/* del button */ { "sName": "null as delete", "bSearchable": false, "bSortable": false, "mDataProp": "delete"} },
/* code */ { sName: "code", mDataProp: "code" },
/* type_name */ { sName: "type_name", mDataProp: "type_name" },
/* description */ { sName: "description", mDataProp: "description" },
/* visibility */ {
sName: "visibility",
bSearchable: false,
mDataProp: "visibility",
},
/* del button */ {
sName: "null as delete",
bSearchable: false,
bSortable: false,
mDataProp: "delete",
},
], ],
"bJQueryUI": true, bJQueryUI: true,
"bAutoWidth": false, bAutoWidth: false,
"bLengthChange": false, bLengthChange: false,
"oLanguage": getDatatablesStrings({ oLanguage: getDatatablesStrings({
"sEmptyTable": $.i18n._("No track types were found."), sEmptyTable: $.i18n._("No track types were found."),
"sEmptyTable": $.i18n._("No track types found"), sEmptyTable: $.i18n._("No track types found"),
"sZeroRecords": $.i18n._("No matching track types found"), sZeroRecords: $.i18n._("No matching track types found"),
"sInfo": $.i18n._("Showing _START_ to _END_ of _TOTAL_ track types"), sInfo: $.i18n._("Showing _START_ to _END_ of _TOTAL_ track types"),
"sInfoEmpty": $.i18n._("Showing 0 to 0 of 0 track types"), sInfoEmpty: $.i18n._("Showing 0 to 0 of 0 track types"),
"sInfoFiltered": $.i18n._("(filtered from _MAX_ total track types)"), sInfoFiltered: $.i18n._("(filtered from _MAX_ total track types)"),
}), }),
"sDom": '<"H"lf<"dt-process-rel"r>><"#tracktype_list_inner_wrapper"t><"F"ip>' sDom: '<"H"lf<"dt-process-rel"r>><"#tracktype_list_inner_wrapper"t><"F"ip>',
}); });
} }
function sizeFormElements() { function sizeFormElements() {
$("dt[id$='label']").addClass('tracktype-form-label'); $("dt[id$='label']").addClass("tracktype-form-label");
$("dd[id$='element']").addClass('tracktype-form-element'); $("dd[id$='element']").addClass("tracktype-form-element");
} }
function initTracktypeData() { function initTracktypeData() {
var visibility = $('#visibility'); var visibility = $("#visibility");
var table = $("#tracktypes_datable"); //.DataTable(); var table = $("#tracktypes_datable"); //.DataTable();
$('.datatable tbody').on( 'click', 'tr', function () { $(".datatable tbody").on("click", "tr", function () {
$(this).parent().find('tr.selected').removeClass('selected'); $(this).parent().find("tr.selected").removeClass("selected");
$(this).addClass('selected'); $(this).addClass("selected");
}); });
$('#button').click( function () { $("#button").click(function () {
table.row('.selected').remove().draw( false ); table.row(".selected").remove().draw(false);
}); });
var newTracktype = {code:"", type_name:"", description:"", visibility:"1", id:""}; var newTracktype = {
code: "",
type_name: "",
description: "",
visibility: "1",
id: "",
};
$('#add_tracktype_button').live('click', function(){ $("#add_tracktype_button").live("click", function () {
populateForm(newTracktype); populateForm(newTracktype);
$("#tracktype_details").css("visibility", "visible"); $("#tracktype_details").css("visibility", "visible");
}); });
} }
$(document).ready(function () { $(document).ready(function () {
populateTracktypeTable(); populateTracktypeTable();
initTracktypeData(); initTracktypeData();
$('#save_tracktype').live('click', function(){ $("#save_tracktype").live("click", function () {
var data = $('#tracktype_form').serialize(); var data = $("#tracktype_form").serialize();
var url = baseUrl+'Tracktype/add-tracktype'; var url = baseUrl + "Tracktype/add-tracktype";
$.post(url, { format: "json", data: data }, function (json) { $.post(url, { format: "json", data: data }, function (json) {
if (json.valid === "true") { if (json.valid === "true") {
$('#content').empty().append(json.html); $("#content").empty().append(json.html);
populateTracktypeTable(); populateTracktypeTable();
init(); // Reinitialize init(); // Reinitialize
} else { } else {
//if form is invalid we only need to redraw the form //if form is invalid we only need to redraw the form
$('#tracktype_form').empty().append($(json.html).find('#tracktype_form').children()); $("#tracktype_form")
.empty()
.append($(json.html).find("#tracktype_form").children());
} }
setTimeout(removeSuccessMsg, 5000); setTimeout(removeSuccessMsg, 5000);
sizeFormElements(); sizeFormElements();

View File

@ -1,187 +1,241 @@
function populateForm(entries) { function populateForm(entries) {
//$('#user_details').show(); //$('#user_details').show();
$('.errors').remove(); $(".errors").remove();
$('.success').remove(); $(".success").remove();
if (entries.type === 'S') if (entries.type === "S") {
{
$("#user_details").hide(); $("#user_details").hide();
$("#user_details_superadmin_message").show(); $("#user_details_superadmin_message").show();
$('#type').attr('disabled', '1'); $("#type").attr("disabled", "1");
} else { } else {
$("#user_details").show(); $("#user_details").show();
$("#user_details_superadmin_message").hide(); $("#user_details_superadmin_message").hide();
$('#type').removeAttr('disabled'); $("#type").removeAttr("disabled");
} }
$('#user_id').val(entries.id); $("#user_id").val(entries.id);
$('#login').val(entries.login); $("#login").val(entries.login);
$('#first_name').val(entries.first_name); $("#first_name").val(entries.first_name);
$('#last_name').val(entries.last_name); $("#last_name").val(entries.last_name);
$('#type').val(entries.type); $("#type").val(entries.type);
$('#email').val(entries.email); $("#email").val(entries.email);
$('#cell_phone').val(entries.cell_phone); $("#cell_phone").val(entries.cell_phone);
$('#skype').val(entries.skype_contact); $("#skype").val(entries.skype_contact);
$('#jabber').val(entries.jabber_contact); $("#jabber").val(entries.jabber_contact);
if (entries.id.length != 0) { if (entries.id.length != 0) {
$('#login').attr('readonly', 'readonly'); $("#login").attr("readonly", "readonly");
$('#password').val("xxxxxx"); $("#password").val("xxxxxx");
$('#passwordVerify').val("xxxxxx"); $("#passwordVerify").val("xxxxxx");
} else { } else {
$('#login').removeAttr('readonly'); $("#login").removeAttr("readonly");
$('#password').val(""); $("#password").val("");
$('#passwordVerify').val(""); $("#passwordVerify").val("");
} }
} }
function rowClickCallback(row_id) { function rowClickCallback(row_id) {
$.ajax({ url: baseUrl+'User/get-user-data/id/'+ row_id +'/format/json', dataType:"json", success:function(data){ $.ajax({
url: baseUrl + "User/get-user-data/id/" + row_id + "/format/json",
dataType: "json",
success: function (data) {
populateForm(data.entries); populateForm(data.entries);
$("#user_details").css("visibility", "visible"); $("#user_details").css("visibility", "visible");
}}); },
});
} }
function removeUserCallback(row_id, nRow) { function removeUserCallback(row_id, nRow) {
if (confirm($.i18n._("Are you sure you want to delete this user?"))) { if (confirm($.i18n._("Are you sure you want to delete this user?"))) {
$.ajax({ $.ajax({
url: baseUrl + 'User/remove-user/id/' + row_id + '/format/json', url: baseUrl + "User/remove-user/id/" + row_id + "/format/json",
dataType: "text", dataType: "text",
success: function (data) { success: function (data) {
var o = $('#users_datatable').dataTable().fnDeleteRow(nRow); var o = $("#users_datatable").dataTable().fnDeleteRow(nRow);
} },
}); });
} }
} }
function rowCallback(nRow, aData, iDisplayIndex) { function rowCallback(nRow, aData, iDisplayIndex) {
$(nRow).click(function(){rowClickCallback(aData['id'])}); $(nRow).click(function () {
if( aData['delete'] != "self"){ rowClickCallback(aData["id"]);
$('td:eq(4)', nRow).append( '<span class="ui-icon ui-icon-closethick"></span>').children('span').click(function(e){e.stopPropagation(); removeUserCallback(aData['id'], nRow)}); });
if (aData["delete"] != "self") {
$("td:eq(4)", nRow)
.append('<span class="ui-icon ui-icon-closethick"></span>')
.children("span")
.click(function (e) {
e.stopPropagation();
removeUserCallback(aData["id"], nRow);
});
} else { } else {
$('td:eq(4)', nRow).empty().append( '<span class="ui-icon ui-icon-closethick"></span>').children('span').click(function(e){e.stopPropagation(); alert($.i18n._("Can't delete yourself!"))}); $("td:eq(4)", nRow)
.empty()
.append('<span class="ui-icon ui-icon-closethick"></span>')
.children("span")
.click(function (e) {
e.stopPropagation();
alert($.i18n._("Can't delete yourself!"));
});
} }
if ( aData['type'] == "A" ) if (aData["type"] == "A") {
{ $("td:eq(3)", nRow).html($.i18n._("Admin"));
$('td:eq(3)', nRow).html( $.i18n._('Admin') ); } else if (aData["type"] == "H") {
} else if ( aData['type'] == "H" ) $("td:eq(3)", nRow).html($.i18n._("DJ"));
{ } else if (aData["type"] == "G") {
$('td:eq(3)', nRow).html( $.i18n._('DJ') ); $("td:eq(3)", nRow).html($.i18n._("Guest"));
} else if ( aData['type'] == "G" ) } else if (aData["type"] == "P") {
{ $("td:eq(3)", nRow).html($.i18n._("Program Manager"));
$('td:eq(3)', nRow).html( $.i18n._('Guest') ); } else if (aData["type"] == "S") {
} else if ( aData['type'] == "P" ) $("td:eq(3)", nRow).html($.i18n._("Super Admin"));
{ $("td:eq(4)", nRow).html(""); //Disable deleting the super admin
$('td:eq(3)', nRow).html( $.i18n._('Program Manager') );
} else if ( aData['type'] == "S" )
{
$('td:eq(3)', nRow).html( $.i18n._('Super Admin') );
$('td:eq(4)', nRow).html(""); //Disable deleting the super admin
} }
return nRow; return nRow;
} }
function populateUserTable() { function populateUserTable() {
var dt = $('#users_datatable'); var dt = $("#users_datatable");
dt.dataTable({ dt.dataTable({
"bProcessing": true, bProcessing: true,
"bServerSide": true, bServerSide: true,
"sAjaxSource": baseUrl+"User/get-user-data-table-info/format/json", sAjaxSource: baseUrl + "User/get-user-data-table-info/format/json",
"fnServerData": function ( sSource, aoData, fnCallback ) { fnServerData: function (sSource, aoData, fnCallback) {
$.ajax({ $.ajax({
"dataType": 'json', dataType: "json",
"type": "POST", type: "POST",
"url": sSource, url: sSource,
"data": aoData, data: aoData,
"success": fnCallback success: fnCallback,
}); });
}, },
"fnRowCallback": rowCallback, fnRowCallback: rowCallback,
"aoColumns": [ aoColumns: [
/* Id */ { "sName": "id", "bSearchable": false, "bVisible": false, "mDataProp": "id" }, /* Id */ {
/* user name */ { "sName": "login", "mDataProp": "login" }, sName: "id",
/* first name */ { "sName": "first_name", "mDataProp": "first_name" }, bSearchable: false,
/* last name */ { "sName": "last_name", "mDataProp": "last_name" }, bVisible: false,
/* user type */ { "sName": "type", "bSearchable": false, "mDataProp": "type" }, mDataProp: "id",
/* del button */ { "sName": "null as delete", "bSearchable": false, "bSortable": false, "mDataProp": "delete"} },
/* user name */ { sName: "login", mDataProp: "login" },
/* first name */ { sName: "first_name", mDataProp: "first_name" },
/* last name */ { sName: "last_name", mDataProp: "last_name" },
/* user type */ { sName: "type", bSearchable: false, mDataProp: "type" },
/* del button */ {
sName: "null as delete",
bSearchable: false,
bSortable: false,
mDataProp: "delete",
},
], ],
"bJQueryUI": true, bJQueryUI: true,
"bAutoWidth": false, bAutoWidth: false,
"bLengthChange": false, bLengthChange: false,
"oLanguage": getDatatablesStrings({ oLanguage: getDatatablesStrings({
"sEmptyTable": $.i18n._("No users were found."), sEmptyTable: $.i18n._("No users were found."),
"sEmptyTable": $.i18n._("No users found"), sEmptyTable: $.i18n._("No users found"),
"sZeroRecords": $.i18n._("No matching users found"), sZeroRecords: $.i18n._("No matching users found"),
"sInfo": $.i18n._("Showing _START_ to _END_ of _TOTAL_ users"), sInfo: $.i18n._("Showing _START_ to _END_ of _TOTAL_ users"),
"sInfoEmpty": $.i18n._("Showing 0 to 0 of 0 users"), sInfoEmpty: $.i18n._("Showing 0 to 0 of 0 users"),
"sInfoFiltered": $.i18n._("(filtered from _MAX_ total users)"), sInfoFiltered: $.i18n._("(filtered from _MAX_ total users)"),
}), }),
"sDom": '<"H"lf<"dt-process-rel"r>><"#user_list_inner_wrapper"t><"F"ip>' sDom: '<"H"lf<"dt-process-rel"r>><"#user_list_inner_wrapper"t><"F"ip>',
}); });
} }
function sizeFormElements() { function sizeFormElements() {
$("dt[id$='label']").addClass('user-form-label'); $("dt[id$='label']").addClass("user-form-label");
$("dd[id$='element']").addClass('user-form-element'); $("dd[id$='element']").addClass("user-form-element");
} }
function assignUserRightsToUserTypes() { function assignUserRightsToUserTypes() {
//assign user-rights and id to each user type option so we can //assign user-rights and id to each user type option so we can
//display user rights for each with tipsy tooltip //display user rights for each with tipsy tooltip
$.each($('#type').children(), function(i, opt) { $.each($("#type").children(), function (i, opt) {
switch ($(this).val()) { switch ($(this).val()) {
case 'G': case "G":
$(this).attr('id', 'user-type-G'); $(this).attr("id", "user-type-G");
$(this).attr('user-rights', $(this).attr(
$.i18n._('Guests can do the following:')+'<br><br>'+ "user-rights",
$.i18n._('View schedule')+'<br>'+ $.i18n._("Guests can do the following:") +
$.i18n._('View show content') "<br><br>" +
$.i18n._("View schedule") +
"<br>" +
$.i18n._("View show content")
); );
break; break;
case 'H': case "H":
$(this).attr('id', 'user-type-H'); $(this).attr("id", "user-type-H");
$(this).attr('user-rights', $(this).attr(
$.i18n._('DJs can do the following:')+'<br><br>'+ "user-rights",
$.i18n._('View schedule')+'<br>'+ $.i18n._("DJs can do the following:") +
$.i18n._('View show content')+'<br>'+ "<br><br>" +
$.i18n._('Manage assigned show content')+'<br>'+ $.i18n._("View schedule") +
$.i18n._('Import media files')+'<br>'+ "<br>" +
$.i18n._('Create playlists, smart blocks, and webstreams')+'<br>'+ $.i18n._("View show content") +
$.i18n._('Manage their own library content') "<br>" +
$.i18n._("Manage assigned show content") +
"<br>" +
$.i18n._("Import media files") +
"<br>" +
$.i18n._("Create playlists, smart blocks, and webstreams") +
"<br>" +
$.i18n._("Manage their own library content")
); );
break; break;
case 'P': case "P":
$(this).attr('id', 'user-type-P'); $(this).attr("id", "user-type-P");
$(this).attr('user-rights', $(this).attr(
$.i18n._('Program Managers can do the following:')+'<br><br>'+ "user-rights",
$.i18n._('View schedule')+'<br>'+ $.i18n._("Program Managers can do the following:") +
$.i18n._('View and manage show content')+'<br>'+ "<br><br>" +
$.i18n._('Schedule shows')+'<br>'+ $.i18n._("View schedule") +
$.i18n._('Import media files')+'<br>'+ "<br>" +
$.i18n._('Create playlists, smart blocks, and webstreams')+'<br>'+ $.i18n._("View and manage show content") +
$.i18n._('Manage all library content') "<br>" +
$.i18n._("Schedule shows") +
"<br>" +
$.i18n._("Import media files") +
"<br>" +
$.i18n._("Create playlists, smart blocks, and webstreams") +
"<br>" +
$.i18n._("Manage all library content")
); );
break; break;
case 'A': case "A":
$(this).attr('id', 'user-type-A'); $(this).attr("id", "user-type-A");
$(this).attr('user-rights', $(this).attr(
$.i18n._('Admins can do the following:')+'<br><br>'+ "user-rights",
$.i18n._('Manage preferences')+'<br>'+ $.i18n._("Admins can do the following:") +
$.i18n._('Manage users')+'<br>'+ "<br><br>" +
$.i18n._('Manage watched folders')+'<br>'+ $.i18n._("Manage preferences") +
$.i18n._('Send support feedback')+'<br>'+ "<br>" +
$.i18n._('View system status')+'<br>'+ $.i18n._("Manage users") +
$.i18n._('Access playout history')+'<br>'+ "<br>" +
$.i18n._('View listener stats')+'<br>'+ $.i18n._("Manage watched folders") +
$.i18n._('View schedule')+'<br>'+ "<br>" +
$.i18n._('View and manage show content')+'<br>'+ $.i18n._("Send support feedback") +
$.i18n._('Schedule shows')+'<br>'+ "<br>" +
$.i18n._('Import media files')+'<br>'+ $.i18n._("View system status") +
$.i18n._('Create playlists, smart blocks, and webstreams')+'<br>'+ "<br>" +
$.i18n._('Manage all library content') $.i18n._("Access playout history") +
"<br>" +
$.i18n._("View listener stats") +
"<br>" +
$.i18n._("View schedule") +
"<br>" +
$.i18n._("View and manage show content") +
"<br>" +
$.i18n._("Schedule shows") +
"<br>" +
$.i18n._("Import media files") +
"<br>" +
$.i18n._("Create playlists, smart blocks, and webstreams") +
"<br>" +
$.i18n._("Manage all library content")
); );
break; break;
} }
@ -189,40 +243,40 @@ function assignUserRightsToUserTypes() {
} }
function initUserData() { function initUserData() {
var type = $('#type'); var type = $("#type");
type.live("change", function () { type.live("change", function () {
//when the title changes on live tipsy tooltips the changes take //when the title changes on live tipsy tooltips the changes take
//affect the next time tipsy is shown so we need to hide and re-show it //affect the next time tipsy is shown so we need to hide and re-show it
$(this).tipsy('hide').tipsy('show'); $(this).tipsy("hide").tipsy("show");
}); });
type.tipsy({ type.tipsy({
gravity: 'w', gravity: "w",
html: true, html: true,
opacity: 0.9, opacity: 0.9,
trigger: 'manual', trigger: "manual",
live: true, live: true,
title: function () { title: function () {
return $('#user-type-'+$(this).val()).attr('user-rights'); return $("#user-type-" + $(this).val()).attr("user-rights");
} },
}); });
var table = $("#users_datable"); //.DataTable(); var table = $("#users_datable"); //.DataTable();
$('.datatable tbody').on( 'click', 'tr', function () { $(".datatable tbody").on("click", "tr", function () {
$(this).parent().find('tr.selected').removeClass('selected'); $(this).parent().find("tr.selected").removeClass("selected");
$(this).addClass('selected'); $(this).addClass("selected");
}); });
$('#button').click( function () { $("#button").click(function () {
table.row('.selected').remove().draw( false ); table.row(".selected").remove().draw(false);
}); });
type.tipsy('show'); type.tipsy("show");
var newUser = { login: "", first_name: "", last_name: "", type: "G", id: "" }; var newUser = { login: "", first_name: "", last_name: "", type: "G", id: "" };
$('#add_user_button').live('click', function(){ $("#add_user_button").live("click", function () {
populateForm(newUser); populateForm(newUser);
$("#user_details").css("visibility", "visible"); $("#user_details").css("visibility", "visible");
}); });
@ -233,21 +287,23 @@ $(document).ready(function() {
assignUserRightsToUserTypes(); assignUserRightsToUserTypes();
initUserData(); initUserData();
$('#save_user').live('click', function(){ $("#save_user").live("click", function () {
var data = $('#user_form').serialize(); var data = $("#user_form").serialize();
var url = baseUrl+'User/add-user'; var url = baseUrl + "User/add-user";
$.post(url, { format: "json", data: data }, function (json) { $.post(url, { format: "json", data: data }, function (json) {
if (json.valid === "true") { if (json.valid === "true") {
$('#content').empty().append(json.html); $("#content").empty().append(json.html);
populateUserTable(); populateUserTable();
assignUserRightsToUserTypes(); assignUserRightsToUserTypes();
init(); // Reinitialize init(); // Reinitialize
} else { } else {
//if form is invalid we only need to redraw the form //if form is invalid we only need to redraw the form
$('#user_form').empty().append($(json.html).find('#user_form').children()); $("#user_form")
$('#password').val(""); .empty()
$('#passwordVerify').val(""); .append($(json.html).find("#user_form").children());
$("#password").val("");
$("#passwordVerify").val("");
} }
setTimeout(removeSuccessMsg, 5000); setTimeout(removeSuccessMsg, 5000);
sizeFormElements(); sizeFormElements();

View File

@ -7,31 +7,33 @@ var AIRTIME = (function(AIRTIME){
mod = AIRTIME.utilities; mod = AIRTIME.utilities;
mod.findViewportDimensions = function () { mod.findViewportDimensions = function () {
var viewportwidth, var viewportwidth, viewportheight;
viewportheight;
// the more standards compliant browsers (mozilla/netscape/opera/IE7) use // the more standards compliant browsers (mozilla/netscape/opera/IE7) use
// window.innerWidth and window.innerHeight // window.innerWidth and window.innerHeight
if (typeof window.innerWidth != 'undefined') { if (typeof window.innerWidth != "undefined") {
viewportwidth = window.innerWidth, viewportheight = window.innerHeight; (viewportwidth = window.innerWidth),
(viewportheight = window.innerHeight);
} }
// IE6 in standards compliant mode (i.e. with a valid doctype as the first // IE6 in standards compliant mode (i.e. with a valid doctype as the first
// line in the document) // line in the document)
else if (typeof document.documentElement != 'undefined' else if (
&& typeof document.documentElement.clientWidth != 'undefined' typeof document.documentElement != "undefined" &&
&& document.documentElement.clientWidth != 0) { typeof document.documentElement.clientWidth != "undefined" &&
document.documentElement.clientWidth != 0
) {
viewportwidth = document.documentElement.clientWidth; viewportwidth = document.documentElement.clientWidth;
viewportheight = document.documentElement.clientHeight; viewportheight = document.documentElement.clientHeight;
} }
// older versions of IE // older versions of IE
else { else {
viewportwidth = document.getElementsByTagName('body')[0].clientWidth; viewportwidth = document.getElementsByTagName("body")[0].clientWidth;
viewportheight = document.getElementsByTagName('body')[0].clientHeight; viewportheight = document.getElementsByTagName("body")[0].clientHeight;
} }
return { return {
width: viewportwidth, width: viewportwidth,
height: viewportheight height: viewportheight,
}; };
}; };
@ -40,10 +42,13 @@ var AIRTIME = (function(AIRTIME){
* *
* @return Object {"start", "end", "range"} * @return Object {"start", "end", "range"}
*/ */
mod.fnGetScheduleRange = function(dateStartId, timeStartId, dateEndId, timeEndId) { mod.fnGetScheduleRange = function (
var start, dateStartId,
end, timeStartId,
time; dateEndId,
timeEndId
) {
var start, end, time;
start = $(dateStartId).val(); start = $(dateStartId).val();
start = start === "" ? null : start; start = start === "" ? null : start;
@ -67,10 +72,9 @@ var AIRTIME = (function(AIRTIME){
return { return {
start: start, start: start,
end: end end: end,
}; };
}; };
return AIRTIME; return AIRTIME;
})(AIRTIME || {});
}(AIRTIME || {}));

View File

@ -2,31 +2,77 @@
* Created by asantoni on 11/09/15. * Created by asantoni on 11/09/15.
*/ */
$(document).ready(function () { $(document).ready(function () {
var aoColumns = [ var aoColumns = [
/* Artwork */ { "sTitle" : $.i18n._("Artwork") , "mDataProp" : "artwork" , "bVisible" : false , "sClass" : "library_artwork" , "sWidth" : "150px" }, /* Artwork */ {
/* Title */ { "sTitle" : $.i18n._("Title") , "mDataProp" : "track_title" , "sClass" : "library_title" , "sWidth" : "170px" }, sTitle: $.i18n._("Artwork"),
/* Creator */ { "sTitle" : $.i18n._("Creator") , "mDataProp" : "artist_name" , "sClass" : "library_creator" , "sWidth" : "160px" }, mDataProp: "artwork",
/* Upload Time */ { "sTitle" : $.i18n._("Uploaded") , "mDataProp" : "utime" , "bVisible" : false , "sClass" : "library_upload_time" , "sWidth" : "155px" }, bVisible: false,
/* Website */ { "sTitle" : $.i18n._("Website") , "mDataProp" : "info_url" , "bVisible" : false , "sClass" : "library_url" , "sWidth" : "150px" }, sClass: "library_artwork",
/* Year */ { "sTitle" : $.i18n._("Year") , "mDataProp" : "year" , "bVisible" : false , "sClass" : "library_year" , "sWidth" : "60px" }, sWidth: "150px",
},
/* Title */ {
sTitle: $.i18n._("Title"),
mDataProp: "track_title",
sClass: "library_title",
sWidth: "170px",
},
/* Creator */ {
sTitle: $.i18n._("Creator"),
mDataProp: "artist_name",
sClass: "library_creator",
sWidth: "160px",
},
/* Upload Time */ {
sTitle: $.i18n._("Uploaded"),
mDataProp: "utime",
bVisible: false,
sClass: "library_upload_time",
sWidth: "155px",
},
/* Website */ {
sTitle: $.i18n._("Website"),
mDataProp: "info_url",
bVisible: false,
sClass: "library_url",
sWidth: "150px",
},
/* Year */ {
sTitle: $.i18n._("Year"),
mDataProp: "year",
bVisible: false,
sClass: "library_year",
sWidth: "60px",
},
]; ];
var ajaxSourceURL = baseUrl + "rest/media"; var ajaxSourceURL = baseUrl + "rest/media";
var myToolbarButtons = AIRTIME.widgets.Table.getStandardToolbarButtons(); var myToolbarButtons = AIRTIME.widgets.Table.getStandardToolbarButtons();
myToolbarButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.NEW].eventHandlers.click = function(e) { alert('New!'); }; myToolbarButtons[
myToolbarButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.EDIT].eventHandlers.click = function(e) { alert('Edit!'); }; AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.NEW
myToolbarButtons[AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.DELETE].eventHandlers.click = function(e) { alert('Delete!'); }; ].eventHandlers.click = function (e) {
alert("New!");
};
myToolbarButtons[
AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.EDIT
].eventHandlers.click = function (e) {
alert("Edit!");
};
myToolbarButtons[
AIRTIME.widgets.Table.TOOLBAR_BUTTON_ROLES.DELETE
].eventHandlers.click = function (e) {
alert("Delete!");
};
//Set up the div with id "example-table" as a datatable. //Set up the div with id "example-table" as a datatable.
var table = new AIRTIME.widgets.Table( var table = new AIRTIME.widgets.Table(
$('#example-table'), //DOM node to create the table inside. $("#example-table"), //DOM node to create the table inside.
true, //Enable item selection true, //Enable item selection
myToolbarButtons, //Toolbar buttons myToolbarButtons, //Toolbar buttons
{ //Datatables overrides. {
'aoColumns' : aoColumns, //Datatables overrides.
'sAjaxSource' : ajaxSourceURL aoColumns: aoColumns,
}); sAjaxSource: ajaxSourceURL,
}
);
}); });

View File

@ -3,7 +3,6 @@
*/ */
var AIRTIME = (function (AIRTIME) { var AIRTIME = (function (AIRTIME) {
//Module initialization //Module initialization
if (AIRTIME.widgets === undefined) { if (AIRTIME.widgets === undefined) {
AIRTIME.widgets = {}; AIRTIME.widgets = {};
@ -24,8 +23,13 @@ var AIRTIME = (function(AIRTIME) {
* @returns {Table} * @returns {Table}
* @constructor * @constructor
*/ */
var Table = function(wrapperDOMNode, bItemSelection, toolbarButtons, dataTablesOptions, emptyPlaceholder) { var Table = function (
wrapperDOMNode,
bItemSelection,
toolbarButtons,
dataTablesOptions,
emptyPlaceholder
) {
var self = this; var self = this;
self.HUGE_INT = Math.pow(2, 53) - 1; self.HUGE_INT = Math.pow(2, 53) - 1;
@ -34,7 +38,7 @@ var AIRTIME = (function(AIRTIME) {
self.SELECTION_MODE = { self.SELECTION_MODE = {
SINGLE: 0, SINGLE: 0,
MULTI_SHIFT: 1, MULTI_SHIFT: 1,
MULTI_CTRL : 2 MULTI_CTRL: 2,
}; };
//Member variables //Member variables
@ -58,52 +62,63 @@ var AIRTIME = (function(AIRTIME) {
// If selection is enabled, add in the checkbox column. // If selection is enabled, add in the checkbox column.
if (bItemSelection) { if (bItemSelection) {
dataTablesOptions["aoColumns"].unshift( dataTablesOptions["aoColumns"].unshift(
/* Checkbox */ { "sTitle" : "", "mData" : self._datatablesCheckboxDataDelegate.bind(this), "bSortable" : false , "bSearchable" : false , "sWidth" : "24px" , "sClass" : "airtime_table_checkbox" } /* Checkbox */ {
sTitle: "",
mData: self._datatablesCheckboxDataDelegate.bind(this),
bSortable: false,
bSearchable: false,
sWidth: "24px",
sClass: "airtime_table_checkbox",
}
); );
} }
var options = { var options = {
"aoColumns": [ aoColumns: [
/* Title */ { "sTitle" : $.i18n._("Make sure to override me") , "mDataProp" : "track_title" , "sClass" : "library_title" , "sWidth" : "170px" }, /* Title */ {
sTitle: $.i18n._("Make sure to override me"),
mDataProp: "track_title",
sClass: "library_title",
sWidth: "170px",
},
], ],
"bProcessing": true, bProcessing: true,
"bServerSide": true, bServerSide: true,
"sAjaxSource": baseUrl+"rest/media", //Override me sAjaxSource: baseUrl + "rest/media", //Override me
"sAjaxDataProp": "aaData", sAjaxDataProp: "aaData",
"bScrollCollapse": false, bScrollCollapse: false,
"deferLoading" : 1, //0 tells it there's zero elements loaded and disables the automatic AJAX. We don't want to load until after we bind all our event handlers, to prevent a race condition with the "init" event callback. deferLoading: 1, //0 tells it there's zero elements loaded and disables the automatic AJAX. We don't want to load until after we bind all our event handlers, to prevent a race condition with the "init" event callback.
"sPaginationType": "full_numbers", sPaginationType: "full_numbers",
"bJQueryUI": true, bJQueryUI: true,
"bAutoWidth": false, bAutoWidth: false,
"aaSorting": [], aaSorting: [],
"iDisplayLength": 25, iDisplayLength: 25,
"aLengthMenu": [25, 50, 100], aLengthMenu: [25, 50, 100],
"oLanguage" : getDatatablesStrings({ oLanguage: getDatatablesStrings({
"sEmptyTable": $.i18n._(""), sEmptyTable: $.i18n._(""),
"sZeroRecords": $.i18n._("No matching results found.") sZeroRecords: $.i18n._("No matching results found."),
}), }),
"oColVis": { oColVis: {
"sAlign": "right", sAlign: "right",
"aiExclude": self._colVisExcludeColumns, aiExclude: self._colVisExcludeColumns,
"buttonText": $.i18n._("Columns"), buttonText: $.i18n._("Columns"),
"iOverlayFade": 0 iOverlayFade: 0,
}, },
// z = ColResize, R = ColReorder, C = ColVis // z = ColResize, R = ColReorder, C = ColVis
"sDom": 'Rf<"dt-process-rel"r><"H"<"table_toolbar"C>><"dataTables_scrolling"t<".empty_placeholder"<".empty_placeholder_image"><".empty_placeholder_text">>><"F"lip>>', sDom: 'Rf<"dt-process-rel"r><"H"<"table_toolbar"C>><"dataTables_scrolling"t<".empty_placeholder"<".empty_placeholder_image"><".empty_placeholder_text">>><"F"lip>>',
"fnPreDrawCallback": function () { fnPreDrawCallback: function () {
$("#draggingContainer").remove(); $("#draggingContainer").remove();
}, },
"fnServerData": self._fetchData.bind(self), fnServerData: self._fetchData.bind(self),
//"fnInitComplete" : function() { self._setupEventHandlers(bItemSelection) } //"fnInitComplete" : function() { self._setupEventHandlers(bItemSelection) }
"fnDrawCallback": function () { fnDrawCallback: function () {
self.clearSelection(); self.clearSelection();
} },
}; };
//Override any options with those passed in as arguments to this constructor. //Override any options with those passed in as arguments to this constructor.
for (var key in dataTablesOptions) for (var key in dataTablesOptions) {
{
options[key] = dataTablesOptions[key]; options[key] = dataTablesOptions[key];
} }
@ -123,22 +138,27 @@ var AIRTIME = (function(AIRTIME) {
}; };
Table.prototype.assignDblClickHandler = function (fn) { Table.prototype.assignDblClickHandler = function (fn) {
$(this._datatable, 'tbody tr').on('dblclick', this._SELECTORS.SELECTION_TABLE_ROW, fn); $(this._datatable, "tbody tr").on(
"dblclick",
this._SELECTORS.SELECTION_TABLE_ROW,
fn
);
}; };
/* Set up global event handlers for the datatable. /* Set up global event handlers for the datatable.
* @param bItemSelection Whether or not row selection behaviour should be enabled for this widget. * @param bItemSelection Whether or not row selection behaviour should be enabled for this widget.
* */ * */
Table.prototype._setupEventHandlers = function (bItemSelection) { Table.prototype._setupEventHandlers = function (bItemSelection) {
var self = this; var self = this;
/** This table row event handler is created once and catches events for any row. (It's less resource intensive /** This table row event handler is created once and catches events for any row. (It's less resource intensive
* than having a per-row callback...) * than having a per-row callback...)
*/ */
if (bItemSelection) { if (bItemSelection) {
$(self._datatable, 'tbody tr').on('click contextmenu', self._SELECTORS.SELECTION_TABLE_ROW, function (e) { $(self._datatable, "tbody tr").on(
"click contextmenu",
self._SELECTORS.SELECTION_TABLE_ROW,
function (e) {
var aData = self._datatable.fnGetData(this); var aData = self._datatable.fnGetData(this);
var iDisplayIndex = $(this).index(); // The index of the row in the current page in the table. var iDisplayIndex = $(this).index(); // The index of the row in the current page in the table.
var nRow = this; var nRow = this;
@ -158,9 +178,13 @@ var AIRTIME = (function(AIRTIME) {
selectionMode = self.SELECTION_MODE.SINGLE; selectionMode = self.SELECTION_MODE.SINGLE;
} }
self.selectRow(nRow, aData, selectionMode, iDisplayIndex); self.selectRow(nRow, aData, selectionMode, iDisplayIndex);
}); }
);
$(self._datatable, 'tbody tr').on('click', self._SELECTORS.SELECTION_CHECKBOX, function(e) { $(self._datatable, "tbody tr").on(
"click",
self._SELECTORS.SELECTION_CHECKBOX,
function (e) {
$this = $(this); $this = $(this);
var iVisualRowIdx = $this.parent().index(); var iVisualRowIdx = $this.parent().index();
@ -172,34 +196,45 @@ var AIRTIME = (function(AIRTIME) {
self.selectRow($this.parent(), aData, selectionMode, iVisualRowIdx); //Always multiselect for checkboxes self.selectRow($this.parent(), aData, selectionMode, iVisualRowIdx); //Always multiselect for checkboxes
e.stopPropagation(); e.stopPropagation();
return true; return true;
}); }
);
// Clear selection when switching pages // Clear selection when switching pages
$(self._datatable).on('page', function () { $(self._datatable).on("page", function () {
self.clearSelection(); self.clearSelection();
}); });
} }
// On filter, display the number of total and filtered results in the search bar // On filter, display the number of total and filtered results in the search bar
$(self._datatable).on('filter', function() { $(self._datatable).on("filter", function () {
var dt = self._datatable, f = dt.closest(".dataTables_wrapper").find(".filter-message"), var dt = self._datatable,
f = dt.closest(".dataTables_wrapper").find(".filter-message"),
totalRecords = dt.fnSettings().fnRecordsTotal(), totalRecords = dt.fnSettings().fnRecordsTotal(),
totalDisplayRecords = dt.fnSettings().fnRecordsDisplay(); totalDisplayRecords = dt.fnSettings().fnRecordsDisplay();
if (f.length === 0) { if (f.length === 0) {
var el = document.createElement("span"); var el = document.createElement("span");
el.setAttribute("class", "filter-message"); el.setAttribute("class", "filter-message");
f = dt.closest(".dataTables_wrapper").find(".dataTables_filter").append(el).find(".filter-message"); f = dt
.closest(".dataTables_wrapper")
.find(".dataTables_filter")
.append(el)
.find(".filter-message");
} }
f.text(totalRecords > totalDisplayRecords ? f.text(
$.i18n._("Filtering out ") + (totalRecords - totalDisplayRecords) totalRecords > totalDisplayRecords
+ $.i18n._(" of ") + totalRecords ? $.i18n._("Filtering out ") +
+ $.i18n._(" records") : "" (totalRecords - totalDisplayRecords) +
$.i18n._(" of ") +
totalRecords +
$.i18n._(" records")
: ""
); );
dt.closest(".dataTables_wrapper").find('.dataTables_filter input[type="text"]') dt.closest(".dataTables_wrapper")
.css('padding-right', f.outerWidth()); .find('.dataTables_filter input[type="text"]')
.css("padding-right", f.outerWidth());
}); });
//Since this function is already called when the datatables initialization is complete, we know the DOM //Since this function is already called when the datatables initialization is complete, we know the DOM
@ -207,7 +242,6 @@ var AIRTIME = (function(AIRTIME) {
self._setupToolbarButtons(self._toolbarButtons); self._setupToolbarButtons(self._toolbarButtons);
}; };
/** /**
* Member functions * Member functions
* *
@ -220,18 +254,28 @@ var AIRTIME = (function(AIRTIME) {
*/ */
Table.prototype._setupToolbarButtons = function (buttons) { Table.prototype._setupToolbarButtons = function (buttons) {
var self = this; var self = this;
var $menu = self._$wrapperDOMNode.parent().parent().find("div.table_toolbar"); var $menu = self._$wrapperDOMNode
.parent()
.parent()
.find("div.table_toolbar");
$menu.addClass("btn-toolbar"); $menu.addClass("btn-toolbar");
//Create the toolbar buttons. //Create the toolbar buttons.
$.each(buttons, function (idx, btn) { $.each(buttons, function (idx, btn) {
var buttonElement = self._createToolbarButton(btn.title, btn.iconClass, btn.extraBtnClass, btn.elementId); var buttonElement = self._createToolbarButton(
btn.title,
btn.iconClass,
btn.extraBtnClass,
btn.elementId
);
$menu.append(buttonElement); $menu.append(buttonElement);
btn.element = buttonElement; //Save this guy in case you need it later. btn.element = buttonElement; //Save this guy in case you need it later.
//Bind event handlers to each button //Bind event handlers to each button
$.each(btn.eventHandlers, function (eventName, eventCallback) { $.each(btn.eventHandlers, function (eventName, eventCallback) {
$(buttonElement).on(eventName, function () { $(buttonElement).on(eventName, function () {
if ($(buttonElement).find("button").is(':disabled')) { return; } if ($(buttonElement).find("button").is(":disabled")) {
return;
}
eventCallback(); eventCallback();
}); });
}); });
@ -254,23 +298,27 @@ var AIRTIME = (function(AIRTIME) {
}; };
/** Create the DOM element for a toolbar button and return it. */ /** Create the DOM element for a toolbar button and return it. */
Table.prototype._createToolbarButton = function(title, iconClass, extraBtnClass, elementId) { Table.prototype._createToolbarButton = function (
title,
iconClass,
extraBtnClass,
elementId
) {
if (!iconClass) { if (!iconClass) {
iconClass = 'icon-plus'; iconClass = "icon-plus";
} }
// var title = $.i18n._('Delete'); // var title = $.i18n._('Delete');
var outerDiv = document.createElement("div"); var outerDiv = document.createElement("div");
outerDiv.className = 'btn-group'; outerDiv.className = "btn-group";
outerDiv.title = title; outerDiv.title = title;
var innerButton = document.createElement("button"); var innerButton = document.createElement("button");
//innerButton.className = 'btn btn-small ' + extraBtnClass; //innerButton.className = 'btn btn-small ' + extraBtnClass;
innerButton.className = 'btn ' + extraBtnClass; innerButton.className = "btn " + extraBtnClass;
innerButton.id = elementId; innerButton.id = elementId;
var innerIcon = document.createElement("i"); var innerIcon = document.createElement("i");
innerIcon.className = 'icon-white ' + iconClass; innerIcon.className = "icon-white " + iconClass;
var innerTextSpan = document.createElement('span'); var innerTextSpan = document.createElement("span");
var innerText = document.createTextNode(title); var innerText = document.createTextNode(title);
innerTextSpan.appendChild(innerText); innerTextSpan.appendChild(innerText);
innerButton.appendChild(innerIcon); innerButton.appendChild(innerIcon);
@ -292,8 +340,11 @@ var AIRTIME = (function(AIRTIME) {
//self._selectedRowVisualIdxMap = []; //self._selectedRowVisualIdxMap = [];
this._selectedRowVisualIdxMin = self.HUGE_INT; this._selectedRowVisualIdxMin = self.HUGE_INT;
this._selectedRowVisualIdxMax = -1; this._selectedRowVisualIdxMax = -1;
this._$wrapperDOMNode.find('.selected').removeClass('selected'); this._$wrapperDOMNode.find(".selected").removeClass("selected");
this._$wrapperDOMNode.find(this._SELECTORS.SELECTION_CHECKBOX).find('input').attr('checked', false); this._$wrapperDOMNode
.find(this._SELECTORS.SELECTION_CHECKBOX)
.find("input")
.attr("checked", false);
this._checkToolbarButtons(); this._checkToolbarButtons();
}; };
@ -303,8 +354,12 @@ var AIRTIME = (function(AIRTIME) {
* @param iVisualRowIdx is an integer which corresponds to the index of the clicked row, as it appears to the user. * @param iVisualRowIdx is an integer which corresponds to the index of the clicked row, as it appears to the user.
* eg. The 5th row in the table will have an iVisualRowIdx of 4 (0-based). * eg. The 5th row in the table will have an iVisualRowIdx of 4 (0-based).
*/ */
Table.prototype.selectRow = function(nRow, aData, selectionMode, iVisualRowIdx) { Table.prototype.selectRow = function (
nRow,
aData,
selectionMode,
iVisualRowIdx
) {
var self = this; var self = this;
//Default to single item selection. //Default to single item selection.
@ -323,12 +378,14 @@ var AIRTIME = (function(AIRTIME) {
self._selectedRowVisualIdxMax = iVisualRowIdx; self._selectedRowVisualIdxMax = iVisualRowIdx;
//self._selectedRowVisualIdxMap[iVisualRowIdx] = aData; //self._selectedRowVisualIdxMap[iVisualRowIdx] = aData;
$nRow.addClass('selected'); $nRow.addClass("selected");
$nRow.find(self._SELECTORS.SELECTION_CHECKBOX).find('input').attr('checked', true); $nRow
.find(self._SELECTORS.SELECTION_CHECKBOX)
.find("input")
.attr("checked", true);
} }
//Ctrl-click multi row selection mode //Ctrl-click multi row selection mode
else if (selectionMode == self.SELECTION_MODE.MULTI_CTRL) { else if (selectionMode == self.SELECTION_MODE.MULTI_CTRL) {
var foundAtIdx = $.inArray(aData, self._selectedRows); var foundAtIdx = $.inArray(aData, self._selectedRows);
//console.log('checkbox mouse', iVisualRowIdx, foundAtIdx); //console.log('checkbox mouse', iVisualRowIdx, foundAtIdx);
@ -336,25 +393,34 @@ var AIRTIME = (function(AIRTIME) {
//If the clicked row is already selected, deselect it. //If the clicked row is already selected, deselect it.
if (foundAtIdx >= 0 && self._selectedRows.length >= 1) { if (foundAtIdx >= 0 && self._selectedRows.length >= 1) {
self._selectedRows.splice(foundAtIdx, 1); self._selectedRows.splice(foundAtIdx, 1);
$nRow.removeClass('selected'); $nRow.removeClass("selected");
$nRow.find(self._SELECTORS.SELECTION_CHECKBOX).find('input').attr('checked', false); $nRow
} .find(self._SELECTORS.SELECTION_CHECKBOX)
else { .find("input")
.attr("checked", false);
} else {
self._selectedRows.push(aData); self._selectedRows.push(aData);
self._selectedRowVisualIdxMin = iVisualRowIdx; self._selectedRowVisualIdxMin = iVisualRowIdx;
self._selectedRowVisualIdxMax = iVisualRowIdx; self._selectedRowVisualIdxMax = iVisualRowIdx;
$nRow.addClass('selected'); $nRow.addClass("selected");
$nRow.find(self._SELECTORS.SELECTION_CHECKBOX).find('input').attr('checked', true); $nRow
.find(self._SELECTORS.SELECTION_CHECKBOX)
.find("input")
.attr("checked", true);
} }
} }
//Shift-click multi row selection mode //Shift-click multi row selection mode
else if (selectionMode == self.SELECTION_MODE.MULTI_SHIFT) { else if (selectionMode == self.SELECTION_MODE.MULTI_SHIFT) {
//If there's no rows selected, just behave like single selection. //If there's no rows selected, just behave like single selection.
if (self._selectedRows.length == 0) { if (self._selectedRows.length == 0) {
return self.selectRow(nRow, aData, self.SELECTION_MODE.SINGLE, iVisualRowIdx); return self.selectRow(
nRow,
aData,
self.SELECTION_MODE.SINGLE,
iVisualRowIdx
);
} }
if (iVisualRowIdx > self._selectedRowVisualIdxMax) { if (iVisualRowIdx > self._selectedRowVisualIdxMax) {
@ -364,24 +430,33 @@ var AIRTIME = (function(AIRTIME) {
self._selectedRowVisualIdxMin = iVisualRowIdx; self._selectedRowVisualIdxMin = iVisualRowIdx;
} }
var selectionStartRowIdx = Math.min(iVisualRowIdx, self._selectedRowVisualIdxMin); var selectionStartRowIdx = Math.min(
var selectionEndRowIdx = Math.min(iVisualRowIdx, self._selectedRowVisualIdxMax); iVisualRowIdx,
self._selectedRowVisualIdxMin
);
var selectionEndRowIdx = Math.min(
iVisualRowIdx,
self._selectedRowVisualIdxMax
);
//We can assume there's at least 1 row already selected now. //We can assume there's at least 1 row already selected now.
var allRows = self._datatable.fnGetData(); var allRows = self._datatable.fnGetData();
self._selectedRows = []; self._selectedRows = [];
for (var i = self._selectedRowVisualIdxMin; i <= self._selectedRowVisualIdxMax; i++) for (
{ var i = self._selectedRowVisualIdxMin;
i <= self._selectedRowVisualIdxMax;
i++
) {
self._selectedRows.push(allRows[i]); self._selectedRows.push(allRows[i]);
$row = $($nRow.parent().children()[i]); $row = $($nRow.parent().children()[i]);
$row.addClass('selected'); $row.addClass("selected");
$row.find(self._SELECTORS.SELECTION_CHECKBOX).find('input').attr('checked', true); $row
.find(self._SELECTORS.SELECTION_CHECKBOX)
.find("input")
.attr("checked", true);
} }
} else {
}
else {
console.log("Unimplemented selection mode"); console.log("Unimplemented selection mode");
} }
@ -400,22 +475,32 @@ var AIRTIME = (function(AIRTIME) {
// If the request was denied due to permissioning // If the request was denied due to permissioning
if (r.status === 403) { if (r.status === 403) {
$(".dt-process-rel").hide(); $(".dt-process-rel").hide();
$('.empty_placeholder_text').text($.i18n._("You don't have permission to view this resource.")); $(".empty_placeholder_text").text(
$('.empty_placeholder').show(); $.i18n._("You don't have permission to view this resource.")
);
$(".empty_placeholder").show();
} }
}; };
/** Grab data from a REST API and format so that DataTables can display it. /** Grab data from a REST API and format so that DataTables can display it.
* This is the DataTables REST adapter function, basically. * This is the DataTables REST adapter function, basically.
* */ * */
Table.prototype._fetchData = function ( sSource, aoData, fnCallback, oSettings ) Table.prototype._fetchData = function (
{ sSource,
aoData,
fnCallback,
oSettings
) {
var self = this; var self = this;
var echo = aoData[0].value; //Datatables state tracking. Must be included. var echo = aoData[0].value; //Datatables state tracking. Must be included.
var sortColName = ""; var sortColName = "";
var sortDir = ""; var sortDir = "";
var search = self._$wrapperDOMNode.closest(".dataTables_wrapper").find(".dataTables_filter").find("input").val(); var search = self._$wrapperDOMNode
.closest(".dataTables_wrapper")
.find(".dataTables_filter")
.find("input")
.val();
if (oSettings.aaSorting.length > 0) { if (oSettings.aaSorting.length > 0) {
var sortColIdx = oSettings.aaSorting[0][0]; var sortColIdx = oSettings.aaSorting[0][0];
sortColName = oSettings.aoColumns[sortColIdx].mDataProp; sortColName = oSettings.aoColumns[sortColIdx].mDataProp;
@ -424,46 +509,49 @@ var AIRTIME = (function(AIRTIME) {
// FIXME: We should probably just be sending aoData back here..? // FIXME: We should probably just be sending aoData back here..?
$.ajax({ $.ajax({
"dataType": 'json', dataType: "json",
"type": "GET", type: "GET",
"url": sSource, url: sSource,
"data": { data: {
"limit": oSettings._iDisplayLength, limit: oSettings._iDisplayLength,
"offset": oSettings._iDisplayStart, offset: oSettings._iDisplayStart,
"sort": sortColName, sort: sortColName,
"sort_dir": sortDir, sort_dir: sortDir,
"search": search search: search,
}, },
"success": function (json, textStatus, jqXHR) { success: function (json, textStatus, jqXHR) {
var rawResponseJSON = json; var rawResponseJSON = json;
json = []; json = [];
json.aaData = rawResponseJSON; json.aaData = rawResponseJSON;
json.iTotalRecords = jqXHR.getResponseHeader('X-TOTAL-COUNT'); json.iTotalRecords = jqXHR.getResponseHeader("X-TOTAL-COUNT");
json.iTotalDisplayRecords = json.iTotalRecords; json.iTotalDisplayRecords = json.iTotalRecords;
json.sEcho = echo; json.sEcho = echo;
//Pass it along to datatables. //Pass it along to datatables.
fnCallback(json); fnCallback(json);
}, },
"error": self._handleAjaxError error: self._handleAjaxError,
}); });
}; };
Table.prototype._datatablesCheckboxDataDelegate = function(rowData, callType, dataToSave) { Table.prototype._datatablesCheckboxDataDelegate = function (
rowData,
callType,
dataToSave
) {
if (callType == undefined) { if (callType == undefined) {
//Supposed to return the raw data for the type here. //Supposed to return the raw data for the type here.
return null; return null;
} else if (callType == 'display') { } else if (callType == "display") {
return "<input type='checkbox'>"; return "<input type='checkbox'>";
} else if (callType == 'sort') { } else if (callType == "sort") {
return null; return null;
} else if (callType == 'type') { } else if (callType == "type") {
return "input"; return "input";
} else if (callType == 'set') { } else if (callType == "set") {
//The data to set is in dataToSave. //The data to set is in dataToSave.
return; return;
} else if (callType == 'filter') { } else if (callType == "filter") {
return null; return null;
} }
@ -471,59 +559,60 @@ var AIRTIME = (function(AIRTIME) {
return "check"; return "check";
}; };
//Accessors / Mutators //Accessors / Mutators
Table.prototype.getDatatable = function () { Table.prototype.getDatatable = function () {
return this._datatable; return this._datatable;
}; };
//Static initializers / Class variables //Static initializers / Class variables
Table.prototype._SELECTORS = Object.freeze({ Table.prototype._SELECTORS = Object.freeze({
SELECTION_CHECKBOX: ".airtime_table_checkbox", SELECTION_CHECKBOX: ".airtime_table_checkbox",
SELECTION_TABLE_ROW: "tr" SELECTION_TABLE_ROW: "tr",
}); });
Table.TOOLBAR_BUTTON_ROLES = { Table.TOOLBAR_BUTTON_ROLES = {
NEW: 0, NEW: 0,
EDIT: 1, EDIT: 1,
DELETE : 2 DELETE: 2,
}; };
Object.freeze(Table.TOOLBAR_BUTTON_ROLES); Object.freeze(Table.TOOLBAR_BUTTON_ROLES);
//Set of standard buttons. Use getStandardToolbarButtons() to grab these and pass them to the init() function. //Set of standard buttons. Use getStandardToolbarButtons() to grab these and pass them to the init() function.
Table._STANDARD_TOOLBAR_BUTTONS = {}; Table._STANDARD_TOOLBAR_BUTTONS = {};
Table._STANDARD_TOOLBAR_BUTTONS[Table.TOOLBAR_BUTTON_ROLES.NEW] = { Table._STANDARD_TOOLBAR_BUTTONS[Table.TOOLBAR_BUTTON_ROLES.NEW] = {
title : $.i18n._('New'), title: $.i18n._("New"),
iconClass: "icon-plus", iconClass: "icon-plus",
extraBtnClass: "btn-small btn-new", extraBtnClass: "btn-small btn-new",
elementId : '', elementId: "",
eventHandlers: {}, eventHandlers: {},
validateConstraints: function () { return true; } validateConstraints: function () {
return true;
},
}; };
Table._STANDARD_TOOLBAR_BUTTONS[Table.TOOLBAR_BUTTON_ROLES.EDIT] = { Table._STANDARD_TOOLBAR_BUTTONS[Table.TOOLBAR_BUTTON_ROLES.EDIT] = {
title : $.i18n._('Edit'), title: $.i18n._("Edit"),
iconClass: "icon-pencil", iconClass: "icon-pencil",
extraBtnClass: "btn-small", extraBtnClass: "btn-small",
elementId : '', elementId: "",
eventHandlers: {}, eventHandlers: {},
validateConstraints: function () { return true; } validateConstraints: function () {
return true;
},
}; };
Table._STANDARD_TOOLBAR_BUTTONS[Table.TOOLBAR_BUTTON_ROLES.DELETE] = { Table._STANDARD_TOOLBAR_BUTTONS[Table.TOOLBAR_BUTTON_ROLES.DELETE] = {
title : $.i18n._('Delete'), title: $.i18n._("Delete"),
iconClass: "icon-trash", iconClass: "icon-trash",
extraBtnClass: "btn-small btn-danger", extraBtnClass: "btn-small btn-danger",
elementId : '', elementId: "",
eventHandlers: {}, eventHandlers: {},
validateConstraints: function () { return true; } validateConstraints: function () {
return true;
},
}; };
Object.freeze(Table._STANDARD_TOOLBAR_BUTTONS); Object.freeze(Table._STANDARD_TOOLBAR_BUTTONS);
//Static method //Static method
Table.getStandardToolbarButtons = function () { Table.getStandardToolbarButtons = function () {
//Return a deep copy //Return a deep copy
@ -533,7 +622,5 @@ var AIRTIME = (function(AIRTIME) {
//Add Table to the widgets namespace //Add Table to the widgets namespace
AIRTIME.widgets.Table = Table; AIRTIME.widgets.Table = Table;
return AIRTIME; return AIRTIME;
})(AIRTIME || {});
}(AIRTIME || {}));