PluginProbe ʕ •ᴥ•ʔ
Loco Translate / 2.1.0
Loco Translate v2.1.0
2.8.5 2.8.4 2.5.8 2.6.0 2.6.1 2.6.10 2.6.11 2.6.12 2.6.13 2.6.14 2.6.2 2.6.3 2.6.4 2.6.5 2.6.6 2.6.7 2.6.8 2.6.9 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0 2.8.1 2.8.2 2.8.3 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2 1.2.1 1.2.2 1.3 1.3.1 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.17 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7
loco-translate / pub / js / setup.js
loco-translate / pub / js Last commit date
min 8 years ago config.js 9 years ago debug.js 9 years ago delete.js 9 years ago editor.js 8 years ago podiff.js 8 years ago poinit.js 8 years ago potinit.js 8 years ago poview.js 9 years ago setup.js 9 years ago
setup.js
129 lines
1 /**
2 * Script for bundle setup page
3 * TODO translations
4 */
5 !function( window, document, $ ){
6
7
8 /**
9 * Look up bundle configuration on remote server
10 */
11 function find( vendor, slug, version ){
12
13 function onFailure(){
14 if( timer ){
15 destroy();
16 onTimeout();
17 }
18 };
19
20 function onResponse( data, status, obj ){
21 if( timer ){
22 destroy();
23 var match = data && data.exact,
24 status = data && data.status
25 ;
26 if( match ){
27 setJson( match );
28 }
29 else if( 404 === status ){
30 unsetJson("Sorry, we don't know a bundle by this name");
31 }
32 else {
33 loco.notices.debug( data.error || 'Unknown server error' );
34 onTimeout();
35 }
36 }
37 };
38
39 function onTimeout(){
40 unsetJson('Failed to contact remote API');
41 timer = null;
42 }
43
44 function destroy(){
45 if( timer ){
46 clearTimeout( timer );
47 timer = null;
48 }
49 }
50
51 var timer = setTimeout( onTimeout, 3000 );
52
53 unsetJson('');
54
55 $.ajax( {
56 url: conf.apiUrl+'/'+vendor+'/'+slug+'.jsonp?version='+encodeURIComponent(version),
57 dataType: 'jsonp',
58 success: onResponse,
59 error: onFailure,
60 cache: true
61 } );
62
63 return {
64 abort: destroy
65 };
66 }
67
68
69 function setJson( json ){
70 elForm['json-content'].value = json;
71 $('#loco-remote-empty').hide();
72 //$('#loco-remote-query').hide();
73 $('#loco-remote-found').show();
74 }
75
76
77 function unsetJson( message ){
78 elForm['json-content'].value = '';
79 //$('#loco-remote-query').show();
80 $('#loco-remote-empty').show().find('span').text( message );
81 $('#loco-remote-found').hide().removeClass('jshide');
82 }
83
84
85 function onFindClick( event ){
86 event.preventDefault();
87 finder && finder.abort();
88 finder = find( elForm.vendor.value, elForm.slug.value, elForm.version.value );
89 return false;
90 }
91
92 function onCancelClick( event ){
93 event.preventDefault();
94 unsetJson('');
95 return false;
96 }
97
98 function setVendors( list ){
99 var i = -1,
100 value, label,
101 length = list.length,
102 $select = $(elForm.vendor).html('')
103 ;
104 while( ++i < length ){
105 value = list[i][0];
106 label = list[i][1];
107 $select.append( $('<option></option>').attr('value',value).text(label) );
108 }
109 }
110
111
112 var loco = window.locoScope,
113 conf = window.locoConf,
114
115 finder,
116 elForm = document.getElementById('loco-remote'),
117 $findButt = $(elForm).find('button[type="button"]').click( onFindClick ),
118 $resetButt = $(elForm).find('input[type="reset"]').click( onCancelClick );
119
120 // pull vendor list
121 $.ajax( {
122 url: conf.apiUrl+'/vendors.jsonp',
123 dataType: 'jsonp',
124 success: setVendors,
125 cache: true
126 } );
127
128
129 }( window, document, jQuery );