Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Major clean up of the TV section #76

Closed
wants to merge 11 commits into from
1 change: 1 addition & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ XWMM Change log
4.1.0
- Clean up jshint warnings (Issue #73)
- Remove unused code (Issue #68)
- Major clean up of the TV section

4.0.2
- XBMC expects rating to be a number not a string. (Issue #57)
Expand Down
5 changes: 0 additions & 5 deletions global.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ function mergeJson(object1, object2) {
object1[i]=object2[i];
}

function removeSpace(string) {
string = string.replace(/^\s*|\s*$/g,'');
return string;
}

var menuBar = new Ext.Toolbar({
region: 'north',
height: 30,
Expand Down
7 changes: 5 additions & 2 deletions include/ext.ux.xbmc.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ Ext.ux.XbmcStars = function(config) {
Ext.extend(Ext.ux.XbmcStars, Ext.Container, {
border: 0,
autoEl: {tag: 'img', src: '../images/stars/0.png'},
updateSrc :function(r){
var value = Math.round(r.data.rating);
updateSrc: function(r) {
var value = 0;
if (r.data.rating !== undefined) {
value = Math.round(r.data.rating);
}
this.el.dom.src = '../images/stars/'+value+'.png';
}
});
2 changes: 1 addition & 1 deletion include/genre.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var storegenre = new Ext.data.Store({
// var myArray = string.split('/');
// Genregrid.getSelectionModel().clearSelections(false);
// for (var i = 0; i < myArray.length; i++) {
// var index = storegenre.findExact('label',removeSpace(myArray[i]),0,false,false);
// var index = storegenre.findExact('label',myArray[i].trim(),0,false,false);
// Genregrid.getSelectionModel().selectRow(index, true)
// }
// }
Expand Down
85 changes: 85 additions & 0 deletions include/xbmc.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,3 +440,88 @@ Ext.extend(Ext.data.XBMCProxy, Ext.data.DataProxy, {
Ext.data.HttpProxy.superclass.destroy.call(this);
}
});

/**
* Add a quick search feature to a text box.
* @param {string} searchBoxId The id of the text box to add the quick search feature to.
* @param {Ext.data.Store} store The store to apply the filter to.
* @param {string} filterField The field to apply the filter to.
*/
function addQuickSearch(searchBoxId, store, filterField) {
var QueryRecord = Ext.data.Record.create([
{ name: 'query', type: 'string' }
]);

var searchStore = new Ext.data.ArrayStore({
fields: [
{ name: 'query', type: 'string' }
]
});

var beforeQuery = function(e) {
var query = e.query.trim();
if (query.length === 0) {
return;
}

var insertQuery = true;
searchStore.each(function(record) {
if (record.data.query.indexOf(query) === 0) {
// backspace
insertQuery = false;
return false;
}
else if (query.indexOf(record.data.query) === 0) {
// forward typing
searchStore.remove(record);
}
else if (query === record.data.query) {
insertQuery = false;
}
});

if (insertQuery === true) {
var record = new QueryRecord({query: query});
searchStore.insert(0, record);
}

var maxQueries = 5; // max 5 query history
if (searchStore.getCount() > maxQueries) {
var overflow = searchStore.getRange(maxQueries);
for (var i = 0, len = overflow.length; i < len; i++) {
searchStore.remove(overflow[i]);
}
}

};

var applyFilter = function(query) {
query = query.trim();
if (query.length === 0) {
store.clearFilter();
}
else {
store.filter(filterField, query, true, false);
}
};

new Ext.form.ComboBox({
id: 'searchBox',
store: searchStore,
displayField: 'query',
typeAhead: false,
mode: 'local',
triggerAction: 'all',
applyTo: searchBoxId,
hideTrigger: true,
listeners: {
beforequery: function(e) {
beforeQuery(e);
applyFilter(e.query);
},
select: function(combo, record, index) {
applyFilter(combo.getValue());
}
}
});
}
5 changes: 2 additions & 3 deletions movies/include.js
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,12 @@ function GetMovieGenres(record) {

function checkWatched(val) {
if ((val !== '' ) && (val !== 0))
return '<img src=../images/icons/checked.png>';

return '<img src="../images/icons/checked.png" width="16" height="16" alt="Watched">';
}

function checkSet(val) {
if (val !== '')
return '<img src=../images/icons/set.png>';
return '<img src="../images/icons/set.png" width="16" height="16" alt="In Set">';
}

var MoviecolModel = new Ext.grid.ColumnModel([
Expand Down
79 changes: 1 addition & 78 deletions movies/startapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,84 +95,7 @@ Ext.onReady(function() {

Ext.QuickTips.init();

// begin search config

var searchStore = new Ext.data.SimpleStore({
fields: ['query'],
data: []
});

var searchBox = new Ext.form.ComboBox({
id: 'searchBox',
store: searchStore,
displayField: 'query',
typeAhead: false,
mode: 'local',
triggerAction: 'all',
applyTo: 'quicksearch',
hideTrigger: true
});

var searchRec = Ext.data.Record.create([
{name: 'query', type: 'string'}
]);

var onFilteringBeforeQuery = function(e) {
//grid.getSelectionModel().clearSelections();
if (this.getValue().length===0) {
storeMovie.clearFilter();
} else {
var value = this.getValue().replace(/^\s+|\s+$/g, '');
if (value==='')
return;
storeMovie.filter('Movietitle', value, true, false);
}
};

var onQuickSearchBeforeQuery = function(e) {
if (this.getValue().length===0) {
} else {
var value = this.getValue().replace(/^\s+|\s+$/g, '');
if (value==='')
return;
searchStore.clearFilter();
var vr_insert = true;
searchStore.each(function(r) {
if (r.data.query.indexOf(value)===0) {
// backspace
vr_insert = false;
return false;
} else if (value.indexOf(r.data.query)===0) {
// forward typing
searchStore.remove(r);
}
});
if (vr_insert===true) {
searchStore.each(function(r) {
if (r.data.query===value) {
vr_insert = false;
}
});
}
if (vr_insert===true) {
var vr = new searchRec({query: value});
searchStore.insert(0, vr);
}
var ss_max = 4; // max 5 query history, starts counting from 0; 0==1,1==2,2==3,etc
if (searchStore.getCount()>ss_max) {
var ssc = searchStore.getCount();
var overflow = searchStore.getRange(ssc-(ssc-ss_max), ssc);
for (var i=0; i<overflow.length; i++) {
searchStore.remove(overflow[i]);
}
}
}
};

searchBox.on('beforequery', onQuickSearchBeforeQuery);
searchBox.on('beforequery', onFilteringBeforeQuery);
searchBox.on('select', onFilteringBeforeQuery);
// end search
addQuickSearch('quicksearch', storeMovie, 'Movietitle');
}

startMyApp();
Expand Down
2 changes: 1 addition & 1 deletion music/musiclist.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ function convertTime(val) {
}

function starRating(val) {
return '<img src=../images/small-stars/'+val+'.gif>';
return '<img src="../images/small-stars/' + val + '.gif" width="80" height="16" alt="' + val + ' Star(s)">';
}

var SongcolModel = new Ext.grid.ColumnModel([
Expand Down
28 changes: 0 additions & 28 deletions tvshows/actors.js

This file was deleted.

Loading