Skip to content

Instantly share code, notes, and snippets.

@pedrofaria
Created October 1, 2010 14:00
Show Gist options
  • Save pedrofaria/606252 to your computer and use it in GitHub Desktop.
Save pedrofaria/606252 to your computer and use it in GitHub Desktop.
function map_refresh(map) {
if (map_plugin.alread_done) return true;
awPlus.API('map', 'GET', null, function(data) {
data.data.sids = [];
for (var sid in data.data.sys) {
data.data.sys[sid].id = parseInt(data.data.sys[sid].id);
data.data.sids.push(data.data.sys[sid]);
}
var store = new Ext.data.Store({
model: 'Map',
sorters: 'id',
getGroupString: function(record) {
return record.get('name')[0];
},
data: data.data.sids,
});
map.setStore(store);
map_plugin.alread_done = true;
});
}
var map_plugin = {
name: 'map',
weight: 1,
alread_done: false,
onReady: function() {
Ext.regModel('Map', {fields: ['name', 'x', 'y', 'id', 'level']});
var map = new Ext.List({
tpl: ['<tpl for="."><div class="awsystem">{id} - {name} ({x}/{y})</div></tpl>'],
emptyText: '<p style="padding: 10px">Loading maps...</p>',
itemSelector: 'div.awsystem',
layout: 'card',
title: 'map',
iconCls: 'favorites',
tbTitle: 'Map',
singleSelect: true,
grouped: false,
indexBar: false,
store: new Ext.data.Store({
model: 'Map',
sorters: 'name',
data: [],
}),
});
map.on('activate', map_refresh);
awPlus.addTabPanelItem(map);
}
}
awPlus.registerPlugin(map_plugin);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment