Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function($){
- var anime;
- var anidbvals;
- var en = 0;
- var xjat= 1;
- var ja = 2;
- var de = 3;
- var official = 0;
- var main = 1;
- var short= 2;
- var syn = 3;
- var title= 0;
- var language= 1;
- var type= 2;
- var titles= new Array();
- function _init(){
- $.jStorage.flush();
- if($.jStorage.get('cached')== true){
- anidbvals= $.jStorage.get('anidblist');
- }
- else if($.jStorage.get('cached')==false && $.jStorage.get('anidblist')){
- anidbvals= $.jStorage.get('anidblist');
- $.getJSON('anidbcache.php?updatelist='+anidbvals.length(), function(data) {
- anidbvals.push(data);
- $.jStorage.set('anidblist', anidbvals);
- $.jStorage.set('cached', true);
- $.jStorage.setTTL('cached', 172800000);
- });
- }
- else{
- $.getJSON('anidbcache.php?list=true', function(data) {
- $.jStorage.set('anidblist', data);
- $.jStorage.set('cached', true);
- $.jStorage.setTTL('cached', 172800000);
- anidbvals = data;
- });
- }
- };
- $.cache = {
- };
- $.anidb = {
- get_title: function(anidbid){
- titles[0] = 0;
- titles[1] = 0;
- if(!(anidbid < 1))
- if(anidbvals[anidbid] != undefined){
- $.each(anidbvals[anidbid-1], function(index, value){
- if(value[type] == 1){
- titles[0] = value[0];
- }
- else if(value[1]== 0 && value[2] == 0){
- titles[1] = value[0];
- }
- });
- if(titles[1]== 0){
- $.each(anidbvals[anidbid-1], function(index, value){
- if(value[1]== 2 && value[2] == 0){
- titles[1] = value[0];
- }
- });
- }
- if(titles[1]== 0){
- $.each(anidbvals[anidbid-1], function(index, value){
- if(value[language]== 1 && value[type] == 0){
- titles[1] = value[0];
- }
- });
- }
- return titles;
- }
- },
- search_title: function(search_string, limit){
- var results = new Array();
- var counter = 0;
- var regex = new RegExp(search_string + "[a-z0-9]*", "i");
- $.each(anidbvals, function( index,value){
- $.each(value, function(index2, value2){
- if(value2['language'] == 'en' || value2['language'] == 'ja'|| value2['language'] =='x-jat'){
- if(value2['title'].match(regex) != null){
- results[counter] = +index+1;
- counter++;
- return false;
- }
- }
- });
- if(limit == counter-1){
- return false;
- }
- });
- counter = 0;
- $.each(results, function(index,value){
- if($.anidb.get_title(value) == search_string){
- temp= results[counter];
- results[counter] = results[index];
- results[index] = temp;
- }
- });
- return results;
- },
- get_anime: function(anidbid){
- anime = new Array();
- }
- };
- _init();
- })(window.jQuery || window.$);
Add Comment
Please, Sign In to add comment