diff --git a/airtime_mvc/application/Bootstrap.php b/airtime_mvc/application/Bootstrap.php index f7804fa17..007208a17 100644 --- a/airtime_mvc/application/Bootstrap.php +++ b/airtime_mvc/application/Bootstrap.php @@ -86,9 +86,10 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap $baseUrl = Application_Common_OsPath::getBaseDir(); - //$view->headScript()->appendFile($baseUrl.'js/libs/jquery-1.7.2.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); - $view->headScript()->appendFile('http://code.jquery.com/jquery-1.10.1.js','text/javascript'); - $view->headScript()->appendFile('http://code.jquery.com/jquery-migrate-1.2.1.js','text/javascript'); + $view->headScript()->appendFile($baseUrl.'js/libs/jquery-1.8.3.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + + //$view->headScript()->appendFile('http://code.jquery.com/jquery-1.10.1.js','text/javascript'); + //$view->headScript()->appendFile('http://code.jquery.com/jquery-migrate-1.2.1.js','text/javascript'); //$view->headScript()->appendFile($baseUrl.'js/libs/jquery-ui-1.8.18.custom.min.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $view->headScript()->appendFile('http://code.jquery.com/ui/1.10.3/jquery-ui.js','text/javascript'); diff --git a/airtime_mvc/application/controllers/PlayouthistoryController.php b/airtime_mvc/application/controllers/PlayouthistoryController.php index 70cb80bba..d55df0cf6 100644 --- a/airtime_mvc/application/controllers/PlayouthistoryController.php +++ b/airtime_mvc/application/controllers/PlayouthistoryController.php @@ -15,7 +15,7 @@ class PlayouthistoryController extends Zend_Controller_Action ->addActionContext('update-list-item', 'json') ->addActionContext('update-aggregate-item', 'json') ->addActionContext('create-template', 'json') - ->addActionContext('edit-template', 'json') + ->addActionContext('update-template', 'json') ->addActionContext('delete-template', 'json') ->addActionContext('set-item-template-default', 'json') ->initContext(); @@ -197,7 +197,14 @@ class PlayouthistoryController extends Zend_Controller_Action public function templateAction() { + $CC_CONFIG = Config::getConfig(); + $baseUrl = Application_Common_OsPath::getBaseDir(); + + $this->view->headScript()->appendFile($baseUrl.'js/airtime/playouthistory/template.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + $historyService = new Application_Service_HistoryService(); + $this->view->template_list = $historyService->getListItemTemplates(); + $this->view->configured = $historyService->getConfiguredTemplateIds(); } public function configureItemTemplateAction() { @@ -210,7 +217,7 @@ class PlayouthistoryController extends Zend_Controller_Action $CC_CONFIG = Config::getConfig(); $baseUrl = Application_Common_OsPath::getBaseDir(); - $this->view->headScript()->appendFile($baseUrl.'js/airtime/playouthistory/template.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); + $this->view->headScript()->appendFile($baseUrl.'js/airtime/playouthistory/itemtemplate.js?'.$CC_CONFIG['airtime_version'],'text/javascript'); $template_id = $this->_getParam('id', null); @@ -225,6 +232,7 @@ class PlayouthistoryController extends Zend_Controller_Action $this->view->fileMD = $historyService->getFileMetadataTypes(); $this->view->fields = $historyService->getFieldTypes(); $this->view->required_fields = $mandatoryFields; + $this->view->configured = $historyService->getConfiguredTemplateIds(); } catch (Exception $e) { Logging::info($e); @@ -240,11 +248,15 @@ class PlayouthistoryController extends Zend_Controller_Action try { $historyService = new Application_Service_HistoryService(); - $historyService->createItemTemplate($params); + $id = $historyService->createItemTemplate($params); + + $this->view->url = $this->view->baseUrl("Playouthistory/configure-item-template/id/{$id}"); } catch (Exception $e) { Logging::info($e); Logging::info($e->getMessage()); + + $this->view->error = $e->getMessage(); } } @@ -270,13 +282,41 @@ class PlayouthistoryController extends Zend_Controller_Action } } - public function editTemplateAction() + public function updateTemplateAction() { - + $request = $this->getRequest(); + $params = $request->getPost(); + Logging::info($params); + + $template_id = $this->_getParam('id', null); + $name = $this->_getParam('name', null); + $fields = $this->_getParam('fields', array()); + + if (empty($template_id)) { + return; + } + + try { + $historyService = new Application_Service_HistoryService(); + $historyService->updateItemTemplate($template_id, $name, $fields); + } + catch (Exception $e) { + Logging::info($e); + Logging::info($e->getMessage()); + } } public function deleteTemplateAction() { - + $template_id = $this->_getParam('id'); + + try { + $historyService = new Application_Service_HistoryService(); + $historyService->deleteTemplate($template_id); + } + catch (Exception $e) { + Logging::info($e); + Logging::info($e->getMessage()); + } } } diff --git a/airtime_mvc/application/services/HistoryService.php b/airtime_mvc/application/services/HistoryService.php index bac08bec4..3c6a86f13 100644 --- a/airtime_mvc/application/services/HistoryService.php +++ b/airtime_mvc/application/services/HistoryService.php @@ -45,6 +45,7 @@ class Application_Service_HistoryService { $mainSqlQuery = ""; $paramMap = array(); + $sqlTypes = $this->getSqlTypes(); $start = $startDT->format("Y-m-d H:i:s"); $end = $endDT->format("Y-m-d H:i:s"); @@ -104,11 +105,12 @@ class Application_Service_HistoryService $field = $fields_filemd[$i]; $key = $field["name"]; + $type = $sqlTypes[$field["type"]]; - $fileSelect[] = "file_md.{$key}"; - $nonNullFileSelect[] = "file.{$key}"; - $nullFileSelect[] = "{$key}_filter.{$key}"; - $mainSelect[] = "file_info.{$key}"; + $fileSelect[] = "file_md.{$key}::{$type}"; + $nonNullFileSelect[] = "file.{$key}::{$type}"; + $nullFileSelect[] = "{$key}_filter.{$key}::{$type}"; + $mainSelect[] = "file_info.{$key}::{$type}"; $fileMdFilters[] = str_replace("%KEY%", $key, $manualMeta); $paramMap["meta_{$key}"] = $key; @@ -159,10 +161,11 @@ class Application_Service_HistoryService $field = $fields_general[$i]; $key = $field["name"]; + $type = $sqlTypes[$field["type"]]; $mdFilters[] = str_replace("%KEY%", $key, $manualMeta); $paramMap["meta_{$key}"] = $key; - $mainSelect[] = "{$key}_filter.{$key}"; + $mainSelect[] = "{$key}_filter.{$key}::{$type}"; } $mainSqlQuery.= @@ -228,50 +231,6 @@ class Application_Service_HistoryService "history" => $rows ); } - - - public function getListView($startDT, $endDT, $opts) - { - $this->translateColumns($opts); - - $select = array ( - "file.track_title as title", - "file.artist_name as artist", - "playout.starts", - "playout.ends", - "playout.history_id" - ); - - $start = $startDT->format("Y-m-d H:i:s"); - $end = $endDT->format("Y-m-d H:i:s"); - - $historyTable = "( - select history.starts as starts, history.ends as ends, - history.id as history_id, history.file_id as file_id - from cc_playout_history as history - where history.starts >= '{$start}' and history.starts < '{$end}' - ) AS playout - left join cc_files as file on (file.id = playout.file_id)"; - - $results = Application_Model_Datatables::findEntries($this->con, $select, $historyTable, $opts, "history"); - - $timezoneUTC = new DateTimeZone("UTC"); - $timezoneLocal = new DateTimeZone($this->timezone); - - //need to display the results in the station's timezone. - foreach ($results["history"] as $index => &$result) { - - $dateTime = new DateTime($result["starts"], $timezoneUTC); - $dateTime->setTimezone($timezoneLocal); - $result["starts"] = $dateTime->format("Y-m-d H:i:s"); - - $dateTime = new DateTime($result["ends"], $timezoneUTC); - $dateTime->setTimezone($timezoneLocal); - $result["ends"] = $dateTime->format("Y-m-d H:i:s"); - } - - return $results; - } public function getAggregateView($startDT, $endDT, $opts) { @@ -326,13 +285,7 @@ class Application_Service_HistoryService //don't add webstreams if (isset($fileId)) { - //$starts = $item->getDbStarts(null); - //$ends = $item->getDbEnds(null); - $metadata = array(); - //$metadata["date"] = $starts->format('Y-m-d'); - //$metadata["start"] = $starts->format('H:i:s'); - //$metadata["end"] = $ends->format('H:i:s'); $metadata["showname"] = $show->getDbName(); $history = new CcPlayoutHistory(); @@ -340,7 +293,6 @@ class Application_Service_HistoryService $history->setDbStarts($item->getDbStarts(null)); $history->setDbEnds($item->getDbEnds(null)); - /* foreach ($metadata as $key => $val) { $meta = new CcPlayoutHistoryMetaData(); $meta->setDbKey($key); @@ -348,7 +300,6 @@ class Application_Service_HistoryService $history->addCcPlayoutHistoryMetaData($meta); } - */ $history->save($this->con); } @@ -605,10 +556,25 @@ class Application_Service_HistoryService return $fields; } + private function getSqlTypes() { + + $fields = array( + TEMPLATE_DATE => "date", + TEMPLATE_TIME => "time", + TEMPLATE_DATETIME => "datetime", + TEMPLATE_STRING => "text", + TEMPLATE_BOOLEAN => "boolean", + TEMPLATE_INT => "integer", + TEMPLATE_FLOAT => "float", + ); + + return $fields; + } + public function getFileMetadataTypes() { $fileMD = array( - array("name"=> MDATA_KEY_TITLE, "type"=> TEMPLATE_STRING), + array("name"=> MDATA_KEY_TITLE, "type"=> TEMPLATE_STRING, "sql"), array("name"=> MDATA_KEY_CREATOR, "type"=> TEMPLATE_STRING), array("name"=> MDATA_KEY_SOURCE, "type"=> TEMPLATE_STRING), array("name"=> MDATA_KEY_DURATION, "type"=> TEMPLATE_STRING), @@ -644,7 +610,7 @@ class Application_Service_HistoryService $fields[] = array("name" => MDATA_KEY_TITLE, "type" => TEMPLATE_STRING, "isFileMd" => true); //these fields can be populated from an associated file. $fields[] = array("name" => MDATA_KEY_CREATOR, "type" => TEMPLATE_STRING, "isFileMd" => true); - $template["name"] = ""; + $template["name"] = "Template".date("Y-m-d H:i:s"); $template["fields"] = $fields; return $template; @@ -719,8 +685,6 @@ class Application_Service_HistoryService public function getDatatablesPlayedItemColumns() { try { - //{"sTitle": $.i18n._("Start"), "mDataProp": "starts", "sClass": "his_starts"} - $template = $this->getConfiguredItemTemplate(); $columns = array(); @@ -762,21 +726,38 @@ class Application_Service_HistoryService } } + public function getConfiguredTemplateIds() { + + try { + $id = Application_Model_Preference::GetHistoryItemTemplate(); + + return array($id); + } + catch (Exception $e) { + throw $e; + } + } + public function createItemTemplate($config) { $this->con->beginTransaction(); try { + + $default = $this->defaultItemTemplate(); + + $name = isset($config["name"]) ? $config["name"] : $default["name"]; + $fields = isset($config["fields"]) ? $config["fields"] : $default["fields"]; + + $doSetDefault = isset($config['setDefault']) ? $config['setDefault'] : false; $template = new CcPlayoutHistoryTemplate(); - $template->setDbName($config["name"]); + $template->setDbName($name); $template->setDbType(self::TEMPLATE_TYPE_ITEM); - - $fields = $config["fields"]; - + foreach ($fields as $index=>$field) { - $isMd = ($field["filemd"] == 'true') ? true : false; + $isMd = ($field["isFileMd"] == 'true') ? true : false; $templateField = new CcPlayoutHistoryTemplateField(); $templateField->setDbName($field["name"]); @@ -788,18 +769,78 @@ class Application_Service_HistoryService } $template->save($this->con); - - $doSetDefault = $config['setDefault']; - if (isset($doSetDefault) && $doSetDefault) { + + if ($doSetDefault) { $this->setConfiguredItemTemplate($template->getDbid()); } $this->con->commit(); + + return $template->getDbid(); } catch (Exception $e) { $this->con->rollback(); throw $e; } } - + + public function updateItemTemplate($id, $name, $fields, $doSetDefault=false) { + + $this->con->beginTransaction(); + + try { + + $template = CcPlayoutHistoryTemplateQuery::create()->findPk($id, $this->con); + $template->setDbName($name); + + if (count($fields) === 0) { + $t = $this->defaultItemTemplate(); + $fields = $t["fields"]; + } + + $template->getCcPlayoutHistoryTemplateFields()->delete($this->con); + + foreach ($fields as $index=>$field) { + + $isMd = ($field["isFileMd"] == 'true') ? true : false; + + $templateField = new CcPlayoutHistoryTemplateField(); + $templateField->setDbName($field["name"]); + $templateField->setDbType($field["type"]); + $templateField->setDbIsFileMD($isMd); + $templateField->setDbPosition($index); + + $template->addCcPlayoutHistoryTemplateField($templateField); + } + + $template->save($this->con); + + if ($doSetDefault) { + $this->setConfiguredItemTemplate($template->getDbid()); + } + + $this->con->commit(); + } + catch (Exception $e) { + $this->con->rollback(); + throw $e; + } + } + + public function deleteTemplate($id) { + + $this->con->beginTransaction(); + + try { + + $template = CcPlayoutHistoryTemplateQuery::create()->findPk($id, $this->con); + $template->delete($this->con); + + $this->con->commit(); + } + catch (Exception $e) { + $this->con->rollback(); + throw $e; + } + } } \ No newline at end of file diff --git a/airtime_mvc/application/views/scripts/playouthistory/configure-item-template.phtml b/airtime_mvc/application/views/scripts/playouthistory/configure-item-template.phtml index 99654fbbd..b19f0764e 100644 --- a/airtime_mvc/application/views/scripts/playouthistory/configure-item-template.phtml +++ b/airtime_mvc/application/views/scripts/playouthistory/configure-item-template.phtml @@ -1,14 +1,3 @@
- -
- -
- render('playouthistory/item-template.phtml'); ?> -
\ No newline at end of file diff --git a/airtime_mvc/application/views/scripts/playouthistory/item-template.phtml b/airtime_mvc/application/views/scripts/playouthistory/item-template.phtml index 2aa247ae6..d9c1473fd 100644 --- a/airtime_mvc/application/views/scripts/playouthistory/item-template.phtml +++ b/airtime_mvc/application/views/scripts/playouthistory/item-template.phtml @@ -1,5 +1,7 @@
+ template_id, $this->configured)): ?> +
diff --git a/airtime_mvc/application/views/scripts/playouthistory/template.phtml b/airtime_mvc/application/views/scripts/playouthistory/template.phtml index df7a899f7..334c26317 100644 --- a/airtime_mvc/application/views/scripts/playouthistory/template.phtml +++ b/airtime_mvc/application/views/scripts/playouthistory/template.phtml @@ -1,3 +1,21 @@
- ">Configure Item Template + +
+
Edit Existing
+ +
+
\ No newline at end of file diff --git a/airtime_mvc/public/js/airtime/library/library.js b/airtime_mvc/public/js/airtime/library/library.js index 5ec73ac5d..97a060e5e 100644 --- a/airtime_mvc/public/js/airtime/library/library.js +++ b/airtime_mvc/public/js/airtime/library/library.js @@ -1102,16 +1102,16 @@ function closeDialogLibrary(event, ui) { function checkImportStatus() { $.getJSON(baseUrl+'Preference/is-import-in-progress', function(data){ - var div = $('#import_status'); + var $div = $('#import_status'); var table = $('#library_display').dataTable(); if (data == true){ - div.show(); + $div.show(); } else{ - if ($(div).is(':visible')) { + if ($div.is(':visible')) { table.fnStandingRedraw(); } - div.hide(); + $div.hide(); } setTimeout(checkImportStatus, 5000); }); diff --git a/airtime_mvc/public/js/airtime/playouthistory/itemtemplate.js b/airtime_mvc/public/js/airtime/playouthistory/itemtemplate.js new file mode 100644 index 000000000..584f06282 --- /dev/null +++ b/airtime_mvc/public/js/airtime/playouthistory/itemtemplate.js @@ -0,0 +1,137 @@ +var AIRTIME = (function(AIRTIME) { + var mod; + var $templateDiv; + var $templateList; + var $fileMDList; + + if (AIRTIME.itemTemplate === undefined) { + AIRTIME.itemTemplate = {}; + } + mod = AIRTIME.itemTemplate; + + function createTemplateLi(name, type, filemd, required) { + + var templateRequired = + "
  • " + + "<%= name %>" + + "<%= type %>" + + "
  • "; + + var templateOptional = + "
  • " + + "<%= name %>" + + "<%= type %>" + + "Remove" + + "
  • "; + + var template = (required) === true ? templateRequired : templateOptional; + + var template = _.template(template); + var count = $templateList.find("li").length; + var id = "field_"+count; + var $li = $(template({id: id, name: name, type: type, filemd: filemd})); + + return $li; + } + + function addField(name, type, filemd, required) { + + $templateList.append(createTemplateLi(name, type, filemd, required)); + } + + function getFieldData($el) { + + return { + name: $el.data("name"), + type: $el.data("type"), + isFileMd: $el.data("filemd"), + id: $el.data("id") + }; + + } + + mod.onReady = function() { + + $templateDiv = $("#configure_item_template"); + $templateList = $(".template_item_list"); + $fileMDList = $(".template_file_md"); + + $fileMDList.on("dblclick", "li", function(){ + + var $li = $(this); + var name = $li.data("name"); + var type = $li.data("type"); + + $templateList.append(createTemplateLi(name, type, true, false)); + }); + + $templateList.sortable(); + + $templateDiv.on("click", ".template_item_remove", function() { + $(this).parents("li").remove(); + }); + + $templateDiv.on("click", ".template_item_add button", function() { + var $div = $(this).parents("div.template_item_add"); + + var name = $div.find("input").val(); + var type = $div.find("select").val(); + + addField(name, type, false, false); + }); + + function createUpdateTemplate(template_id, isDefault) { + var createUrl = baseUrl+"Playouthistory/create-template/format/json"; + var updateUrl = baseUrl+"Playouthistory/update-template/format/json"; + var url; + var data = {}; + var $lis, $li; + var i, len; + var templateName; + + url = (isNaN(parseInt(template_id, 10))) ? createUrl : updateUrl; + + templateName = $("#template_name").val(); + $lis = $templateList.children(); + + for (i = 0, len = $lis.length; i < len; i++) { + $li = $($lis[i]); + + data[i] = getFieldData($li); + } + + $.post(url, {'id': template_id, 'name': templateName, 'fields': data, 'setDefault': isDefault}, function(json) { + var x; + }); + } + + $templateDiv.on("click", "#template_item_save", function(){ + var template_id = $(this).data("template"); + + createUpdateTemplate(template_id, false); + }); + + $templateDiv.on("click", "#template_set_default", function(){ + var template_id = $(this).data("template"); + + if (isNaN(parseInt(template_id, 10))) { + + createUpdateTemplate(template_id, true); + } + else { + + var url = baseUrl+"Playouthistory/set-item-template-default/format/json"; + + $.post(url, {id: template_id}, function(json) { + var x; + }); + } + }); + + }; + +return AIRTIME; + +}(AIRTIME || {})); + +$(document).ready(AIRTIME.itemTemplate.onReady); \ No newline at end of file diff --git a/airtime_mvc/public/js/airtime/playouthistory/template.js b/airtime_mvc/public/js/airtime/playouthistory/template.js index d3466d859..5562dd371 100644 --- a/airtime_mvc/public/js/airtime/playouthistory/template.js +++ b/airtime_mvc/public/js/airtime/playouthistory/template.js @@ -1,181 +1,93 @@ var AIRTIME = (function(AIRTIME) { var mod; - var $templateDiv; - var $templateList; - var $fileMDList; + var $historyTemplate; - if (AIRTIME.historyTemplate === undefined) { - AIRTIME.historyTemplate = {}; + if (AIRTIME.template === undefined) { + AIRTIME.template = {}; } - mod = AIRTIME.historyTemplate; + mod = AIRTIME.template; - function createTemplateLi(name, type, filemd, required) { + function createItemLi(id, name, configured) { - var templateRequired = - "
  • " + - "<%= name %>" + - "<%= type %>" + + var editUrl = baseUrl+"Playouthistory/configure-item-template/id/"+id; + var defaultUrl = baseUrl+"Playouthistory/set-item-template-default/format/json/id/"+id; + var removeUrl = baseUrl+"Playouthistory/delete-template/format/json/id/"+id; + + var itemConfigured = + "
  • " + + "<%= name %>" + "
  • "; - var templateOptional = - "
  • " + - "<%= name %>" + - "<%= type %>" + - "Remove" + + var item = + "
  • " + + "<%= name %>" + + "Set Default" + + "Remove" + "
  • "; - var template = (required) === true ? templateRequired : templateOptional; + var template = (configured) === true ? itemConfigured : item; var template = _.template(template); - var count = $templateList.find("li").length; - var id = "field_"+count; - var $li = $(template({id: id, name: name, type: type, filemd: filemd})); + + var $li = $(template({id: id, name: name, editUrl: editUrl, defaultUrl: defaultUrl, removeUrl: removeUrl})); return $li; } - function addField(name, type, filemd, required) { - - $templateList.append(createTemplateLi(name, type, filemd, required)); - } - - function getFieldData($el) { - - return { - name: $el.data("name"), - type: $el.data("type"), - filemd: $el.data("filemd"), - id: $el.data("id") - }; - - } - - var fieldSortable = (function() { - - var $newLi; - - return { - receive: function( event, ui ) { - var name = $newLi.data("name"); - var type = $newLi.data("type"); - var $prev = $newLi.prev(); - - $newLi.remove(); - - var $li = createTemplateLi(name, type, true, false); - - if ($prev.length) { - $prev.after($li); - } - else { - $templateList.prepend($li); - } - }, - beforeStop: function( event, ui ) { - $newLi = ui.item; - } - }; - })(); - mod.onReady = function() { - $templateDiv = $("#configure_item_template"); - $templateList = $(".template_item_list"); - $fileMDList = $(".template_file_md"); + $historyTemplate = $("#history_template"); + $historyTemplate.on("click", ".template_remove", function(ev) { + + ev.preventDefault(); + + var $a = $(this); + var url = $a.attr("href"); + $a.parents("li").remove(); + + $.post(url, function(){ + var x; + }); + }); - $fileMDList.find("li").draggable({ - helper: function(event, ui) { - var $li = $(this); - var name = $li.data("name"); - var type = $li.data("type"); + $historyTemplate.on("click", ".template_default", function(ev) { + + ev.preventDefault(); + + var $a = $(this); + var url = $a.attr("href"); + var $oldLi, $newLi; + + $oldLi = $a.parents("ul").find("li.template_configured"); + $newLi = $a.parents("li"); + + $oldLi.replaceWith(createItemLi($oldLi.data('template'), $oldLi.data('name'), false)); + $newLi.replaceWith(createItemLi($newLi.data('template'), $newLi.data('name'), true)); + + $.post(url, function(){ + var x; + }); + }); + + $historyTemplate.on("click", "#new_item_template", function() { + var createUrl = baseUrl+"Playouthistory/create-template"; + + $.post(createUrl, {format: "json"}, function(json) { - return createTemplateLi(name, type, true, false); + if (json.error !== undefined) { + alert(json.error); + return; + } - }, - connectToSortable: ".template_item_list" + window.location.href = json.url; + }); }); - $templateList.sortable(fieldSortable); - - $templateDiv.on("click", ".template_item_remove", function() { - $(this).parents("li").remove(); - }); - - $templateDiv.on("click", ".template_item_add button", function() { - var $div = $(this).parents("div.template_item_add"); - - var name = $div.find("input").val(); - var type = $div.find("select").val(); - - addField(name, type, false, false); - }); - - function createUpdateTemplate(template_id, isDefault) { - var createUrl = baseUrl+"Playouthistory/create-template/format/json"; - var updateUrl = baseUrl+"Playouthistory/update-template/format/json"; - var url; - var data = {}; - var $lis, $li; - var i, len; - var templateName; - - url = (isNaN(parseInt(template_id, 10))) ? createUrl : updateUrl; - - templateName = $("#template_name").val(); - $lis = $templateList.children(); - - for (i = 0, len = $lis.length; i < len; i++) { - $li = $($lis[i]); - - data[i] = getFieldData($li); - } - - $.post(url, {'name': templateName, 'fields': data, 'setDefault': isDefault}, function(json) { - var x; - }); - } - - $templateDiv.on("click", "#template_item_save", function(){ - var template_id = $(this).data("template"); - - createUpdateTemplate(template_id, false); - }); - - $templateDiv.on("click", "#template_set_default", function(){ - var template_id = $(this).data("template"); - - if (isNaN(parseInt(template_id, 10))) { - - createUpdateTemplate(template_id, true); - } - else { - - var url = baseUrl+"Playouthistory/set-item-template-default/format/json"; - - $.post(url, {id: template_id}, function(json) { - var x; - }); - } - }); - - $("#template_list").change(function(){ - var template_id = $(this).find(":selected").val(), - url; - - if (!isNaN(parseInt(template_id, 10))) { - url = baseUrl+"Playouthistory/configure-item-template/id/"+template_id; - } - else { - url = baseUrl+"Playouthistory/configure-item-template"; - } - - window.location.href = url; - }); }; return AIRTIME; }(AIRTIME || {})); -$(document).ready(AIRTIME.historyTemplate.onReady); \ No newline at end of file +$(document).ready(AIRTIME.template.onReady); \ No newline at end of file