Changeset 386 for trunk/WordPress/plugin/transposh/js/transposhadmin.js
- Timestamp:
- 03/04/2010 02:12:58 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WordPress/plugin/transposh/js/transposhadmin.js
r362 r386 1 /* 2 * To change this template, choose Tools | Templates 3 * and open the template in the editor. 1 /* Copyright © 2009-2010 Transposh Team (website : http://transposh.org) 2 * 3 * This program is free software; you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation; either version 2 of the License, or 6 * (at your option) any later version. 7 * 8 * This program is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * GNU General Public License for more details. 12 * 13 * You should have received a copy of the GNU General Public License 14 * along with this program; if not, write to the Free Software 15 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 4 16 */ 5 17 … … 36 48 jQuery.ajax({ 37 49 type: "POST", 38 url: t ransposh_params.post_url,50 url: t_jp.post_url, 39 51 data: data, 40 52 success: function() { … … 50 62 }, 200); // wait 200 ms... 51 63 } 52 /*53 64 54 */ 55 //to run at start 56 jQuery.noConflict(); 57 google.load("language", "1"); 58 59 //read parameters 60 var transposh_params = new Array(); 61 var ext_langs = 'he|zh-tw|pt|fa|af|be|is|ga|mk|ms|sw|ws|cy|yi'; 62 jQuery("script[src*='transposhadmin.js']").each(function (j) { 63 var query_string = unescape(this.src.substring(this.src.indexOf('?')+1)); 64 var parms = query_string.split('&'); 65 for (var i=0; i<parms.length; i++) { 66 var pos = parms[i].indexOf('='); 67 if (pos > 0) { 68 var key = parms[i].substring(0,pos); 69 var val = parms[i].substring(pos+1); 70 transposh_params[key] = val; 71 } 72 } 73 }); 74 75 jQuery(document).ready(function() { 76 //var count = 0; 65 function translate_post(postid) { 66 // count = 0; 77 67 var p_count = 0; 78 68 var prev_name=''; 79 69 var l_count = 0; 80 81 jQuery.getJSON(t ransposh_params.post_url+"?tr_phrases_post=y&post="+transposh_params.post+"&random="+Math.random(), function(json) { // need to add random to avoid getting cached!70 jQuery("#tr_loading").data("done",false); 71 jQuery.getJSON(t_jp.post_url+"?tr_phrases_post=y&post="+postid+"&random="+Math.random(), function(json) { // need to add random to avoid getting cached! 82 72 // if we got no results than seems like we have nothing to translate 83 if (json == null) { 84 jQuery("#tr_loading").replaceWith('Nothing left to translate'); 73 jQuery("#tr_translate_title").html("Translating post: "+json.posttitle); 74 if (json.length === undefined) { 75 jQuery("#tr_loading").html('Nothing left to translate'); 76 jQuery("#tr_loading").data("done",true); 85 77 return; 86 78 } 87 79 // create progress bars 88 jQuery("#tr_loading"). replaceWith('Translating<br/>Phrase: <span id="p"></span><div id="progress_bar"/>Target lanaguage: <span id="l"></span><div id="progress_bar2"/><span id="r"></span>')80 jQuery("#tr_loading").html('Translating<br/>Phrase: <span id="p"></span><div id="progress_bar"/>Target lanaguage: <span id="l"></span><div id="progress_bar2"/><span id="r"></span>'); 89 81 jQuery("#progress_bar").progressbar({ 90 82 value:0 … … 97 89 jQuery.each(val.l, function(id,lang) { 98 90 // if (count <1000) { 99 google.language.translate(name, "", lang, function(result) { 100 if (!result.error) { 101 // No longer need because now included in the ajax translate 102 if (prev_name != name) { 103 prev_name = name; 104 l_count = 0; 105 p_count++; 106 } 107 jQuery("#progress_bar").progressbar('value' , p_count/json.length*100); 108 l_count++; 109 jQuery("#progress_bar2").progressbar('value' , l_count/val.l.length*100); 110 jQuery('#p').text(jQuery("<div>"+name+"</div>").text()); 111 jQuery('#l').text(lang); 112 jQuery('#r').text(jQuery("<div>"+result.translation+"</div>").text()); 113 ajax_translate_me(val.t,jQuery("<div>"+result.translation+"</div>").text(),lang); 91 google.language.translate(name, "", lang, function(result) { 92 if (!result.error) { 93 // No longer need because now included in the ajax translate 94 if (prev_name != name) { 95 prev_name = name; 96 l_count = 0; 97 p_count++; 114 98 } 115 }); 116 //count++; 117 //} 99 jQuery("#progress_bar").progressbar('value' , p_count/json.length*100); 100 l_count++; 101 jQuery("#progress_bar2").progressbar('value' , l_count/val.l.length*100); 102 jQuery('#p').text(jQuery("<div>"+name+"</div>").text()); 103 jQuery('#l').text(lang); 104 jQuery('#r').text(jQuery("<div>"+result.translation+"</div>").text()); 105 if (p_count === json.length && l_count === val.l.length) 106 jQuery("#tr_loading").data("done",true); 107 ajax_translate_me(val.t,jQuery("<div>"+result.translation+"</div>").text(),lang); 108 } 109 }); 110 //count++; 111 //} 118 112 }); 119 113 }); 120 114 }); 115 } 116 117 google.load("language", "1"); 118 119 jQuery(document).ready(function() { 120 if (t_jp.post) { 121 translate_post(t_jp.post); 122 } 121 123 });
Note: See TracChangeset
for help on using the changeset viewer.
