voca-application.js 108 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529
  1. var vocaConfig = {
  2. 'isLogin':false,
  3. 'loginPage' : 'my-library'
  4. };
  5. function urlConfig(link){
  6. return window.location.protocol+'//'+window.location.host+'/'+link;
  7. }
  8. // check rule email
  9. function checkEmail(email) {
  10. var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
  11. return re.test(email);
  12. };
  13. //get domain url
  14. function url($ajaxlink){
  15. return location.protocol+'//'+location.host+'/assets/assets-v2/js/'+$ajaxlink;
  16. }
  17. $( document ).ready(function(){
  18. $('#alert-message-success-default').fadeIn('slow');
  19. $('#alert-message-success-default').delay(2500).fadeOut('slow');
  20. $('#alert-message-error-default').fadeIn('slow');
  21. $('#alert-message-error-default').delay(2500).fadeOut('slow');
  22. $('.icon').click(function (a) {
  23. $('#side-nav').css({
  24. 'z-index': '-2'
  25. });
  26. a.preventDefault();
  27. var b = '260px';
  28. var c = '-280px';
  29. var d = '300px';
  30. var e = '-300px';
  31. var f = 200;
  32. if ($('body').hasClass('menu-open')) {
  33. var b = '0px';
  34. var c = '0px';
  35. var f = 100;
  36. } else $('#voca-wrap').css({
  37. 'position': 'fixed'
  38. });
  39. $("#side-nav").show();
  40. $("#side-nav").stop().animate({
  41. width: '600px'
  42. }, {
  43. duration: 150,
  44. queue: false,
  45. complete: function () {
  46. $(this).stop().animate({
  47. 'width': '275px','z-index':'1000'
  48. }, {
  49. duration: f,
  50. queue: false
  51. });
  52. $('body').addClass('menu-open');
  53. }
  54. });
  55. $("#top-nav, #voca-wrap").stop().animate({
  56. left: d,
  57. right: e
  58. }, {
  59. duration: 150,
  60. queue: false,
  61. complete: function () {
  62. $(this).stop().animate({
  63. left: b,
  64. right: c
  65. }, {
  66. duration: f,
  67. queue: false,
  68. complete: function () {
  69. if (b == '0px') {
  70. $('body').removeClass('menu-open');
  71. $('#voca-wrap').css({
  72. 'position': 'relative'
  73. });
  74. $('#side-nav').css({
  75. 'z-index': '-2'
  76. });
  77. $('#close-menu-overlay').remove();
  78. }
  79. }
  80. });
  81. if ($('#close-menu-overlay').length == 0) $('body').append('<a href="#" id="close-menu-overlay"></a>');
  82. }
  83. });
  84. $('.icon-menu').toggleClass('fa-bars').toggleClass('fa-chevron-left');
  85. });
  86. $(document).on("click", '#close-menu-overlay', function (a) {
  87. a.preventDefault();
  88. $('.intro-text-menu.icon').trigger('click');
  89. });
  90. });;
  91. $(document).ready(function(){
  92. console.log("Ready");
  93. /*if(vocaConfig.isLogin == false){
  94. $(function(){
  95. var dom = $('#modal-login-system');
  96. if(dom != undefined){
  97. $.ajax({
  98. url: urlConfig('auth/signin'),
  99. type: 'GET'
  100. }).success(function(data){
  101. $('#modal-login-system').html(data);
  102. });
  103. }
  104. });
  105. }*/
  106. $(document).on('keypress','#email-login, #password-login',function(e){
  107. if(e.keyCode == 13){
  108. $( "#btn-login-system" ).trigger( "click" );
  109. }
  110. });
  111. $('#content-login-loading').removeClass('fullwidth');
  112. $(document).on('click','#btn-login-system',function(){
  113. var email = $('#email-login').val();
  114. var password = $('#password-login').val();
  115. var curUrl = $('#current-url').val();
  116. if(curUrl == undefined){
  117. curUrl = "";
  118. }
  119. var rememberPass = 0;
  120. if(email == ""){
  121. $('.login-msg').html(emailNotEmpty);
  122. return false;
  123. }else{
  124. $('.login-msg').html('');
  125. }
  126. if(password == ""){
  127. $('.login-msg').html(passNotEmpty);
  128. return false;
  129. }else{
  130. $('.login-msg').html('');
  131. }
  132. if($('#login-remember-pass').is(':checked')){
  133. rememberPass = 1;
  134. }
  135. $('#content-login-loading').removeClass('fullwidth').queue(function(next){
  136. $(this).addClass('fullwidth');
  137. next();
  138. });
  139. $.ajax({
  140. url : urlConfig('auth/signin'),
  141. data : {
  142. email : email,
  143. password : password,
  144. rememberPass : rememberPass,
  145. curUrl: curUrl
  146. },
  147. headers: {
  148. 'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
  149. },
  150. type: 'POST'
  151. }).success(function(data){
  152. $('#content-login-loading').removeClass('fullwidth');
  153. $('.login-msg').html('');
  154. if(data.length > 2000){
  155. $('body').append(data);
  156. $('#modal-login-system').modal('hide');
  157. $('#register-msg-modal').modal();
  158. }else{
  159. if(data.email){
  160. $('.login-msg').html(data.email.toString());
  161. }else{
  162. $('.login-msg').html('');
  163. }
  164. if(data.password){
  165. $('.login-msg').html(data.password.toString());
  166. }else{
  167. $('.login-msg').html('');
  168. }
  169. if(!data.email && !data.password){
  170. if(data[0] != "success"){
  171. $('.login-msg').html(data);
  172. }else{
  173. $('#email-login').val('');
  174. $('#password-login').val('');
  175. $('#modal-login-system').modal('hide');
  176. window.location.href = urlConfig(data[1]);
  177. }
  178. }
  179. }
  180. });
  181. });
  182. $('#content-register-loading').removeClass('fullwidth');
  183. });
  184. function redirect()
  185. {
  186. fb_login.close();
  187. self.location = urlConfig(vocaConfig.loginPage);
  188. }
  189. /*function open_login_f(){
  190. var curUrl = $('#current-url').val();
  191. fb_login=window.open(urlConfig('auth/login-facebook/'+curUrl),'name');
  192. }
  193. function open_login_g(){
  194. var curUrl = $('#current-url').val();
  195. fb_login=window.open(urlConfig('auth/login-google/'+curUrl),'name');
  196. };*/
  197. $(document).ready(function(){
  198. //get link
  199. /*if(vocaConfig.isLogin == false){
  200. $(function(){
  201. var dom = $('#modal-signup-system');
  202. if(dom != undefined){
  203. $.ajax({
  204. url: urlConfig('auth/signup'),
  205. type: 'GET'
  206. }).success(function(data){
  207. $('#modal-signup-system').html(data);
  208. });
  209. }
  210. });
  211. }*/
  212. $('#slt-provinces').val(0);
  213. //when user select a any province system auto display districts of that province
  214. $('#slt-provinces').change(function(){
  215. var id = $(this).val();
  216. if(id!=0){
  217. //route into get-districts to get districts of a province when user select
  218. $.post(urlConfig('auth/get-districts'),{provinceId: id},function(data){
  219. $('#first-option').siblings().remove();
  220. for (var index = 0; index < data.length; ++index) {
  221. $("<option value='"+data[index]['id']+"'>"+data[index]['name']+"</option>").insertAfter("#first-option");
  222. }
  223. });
  224. }else{
  225. $('#first-option').siblings().remove();
  226. }
  227. });
  228. //verify format email
  229. $(document).on('blur','#email-register, #email-register-now',function(){
  230. /*var email = $(this).val();
  231. if(email == ""){
  232. $('.msg-email-register-error').html(emailNotEmpty);
  233. return false;
  234. }else{
  235. $('.msg-email-register-error').html('');
  236. }
  237. $.ajax({
  238. url: urlConfig('auth/verify-email-format'),
  239. data: {
  240. email:email
  241. },
  242. type:"POST",
  243. async: false
  244. }).success(function(data) {
  245. if(data == 0){
  246. $('.msg-email-register-error').html(emailWrongFormat);
  247. }else{
  248. $('.msg-email-register-error').html('');
  249. }
  250. });*/
  251. });
  252. //focus email input
  253. $(document).on('focus','#email-register, #email-register-now',function(){
  254. $('.msg-email-register-error').html(recommendEmailGoogle);
  255. });
  256. //refresh-register-captcha
  257. $(document).on('click','#refresh-register-captcha',function(){
  258. $.ajax({
  259. url: urlConfig("auth/get-captcha"),
  260. type:"POST"
  261. }).success(function( data) {
  262. $("#recaptcha-image").attr("src",data);
  263. });
  264. });
  265. //refresh-register-now-captcha
  266. $(document).on('click','#refresh-register-now-captcha',function(){
  267. $.ajax({
  268. url: urlConfig("auth/question-protect"),
  269. type:"POST"
  270. }).success(function( data) {
  271. $('#question-id-register-now-protect').val(data[0]);
  272. $('#question-register-now-protect').html(data[1]);
  273. });
  274. });
  275. $('#content-signup-loading').removeClass('fullwidth');
  276. //register system
  277. $(document).on('click','#btn-register-system',function(){
  278. if($('#agree-register-service').is(':checked')){
  279. $('.msg-agree-service-error').html('');
  280. var registerToken = $('input[name="register_token"]').val();
  281. var email = $('#email-register').val();
  282. var password = $('#password-register').val();
  283. var captcha = $('#captcha-register').val();
  284. var name = $('#full-name-register').val();
  285. var username = $('#username-register').val();
  286. var questionId = $('#question-register-protect').attr('question-id');
  287. var agree = 1;
  288. var curUrl = $('#current-url').val();
  289. if(curUrl == undefined){
  290. curUrl = "";
  291. }
  292. if(name == ""){
  293. $('.register-msg').html(fullNameNotEmpty);
  294. return false;
  295. }else{
  296. $('.register-msg').html('');
  297. }
  298. if(username == ""){
  299. $('.register-msg').html(userNameNotEmpty);
  300. return false;
  301. }else{
  302. $('.register-msg').html('');
  303. }
  304. if(email == ""){
  305. $('.register-msg').html(emailNotEmpty);
  306. return false;
  307. }else{
  308. $('.register-msg').html('');
  309. }
  310. if(password == ""){
  311. $('.register-msg').html(passNotEmpty);
  312. return false;
  313. }else{
  314. $('.register-msg').html('');
  315. }
  316. if(captcha == ""){
  317. $('.register-msg').html(captchaNotEmpty);
  318. return false;
  319. }else{
  320. $('.register-msg').html('');
  321. }
  322. $('#content-signup-loading').removeClass('fullwidth').queue(function(next){
  323. $(this).addClass('fullwidth');
  324. next();
  325. });
  326. $.blockUI({
  327. message:vocaLang.pleaseWaitVoca,
  328. css: {
  329. border: 'none',
  330. padding: '15px',
  331. backgroundColor: '#000',
  332. '-webkit-border-radius': '2px',
  333. '-moz-border-radius': '2px',
  334. 'z-index':'11000',
  335. opacity: .5,
  336. color: '#fff'}
  337. });
  338. $.ajax({
  339. url : urlConfig('auth/signup'),
  340. data : {
  341. email : email,
  342. password : password,
  343. captcha : captcha,
  344. full_name : name,
  345. username : username,
  346. agree : agree,
  347. register_token: registerToken,
  348. curUrl : curUrl
  349. },
  350. headers: {
  351. 'X-CSRF-Token': $('meta[name="csrf-token"]').attr('content')
  352. },
  353. type: 'POST'
  354. }).success(function(data){
  355. $.unblockUI();
  356. $('#content-signup-loading').removeClass('fullwidth');
  357. $('.register-msg').html('');
  358. $('#password-register').val('');
  359. $('#captcha-register').val('');
  360. jQuery('#refresh-register-captcha').click();
  361. if(data.email){
  362. $('.register-msg').html(data.email.toString());
  363. return false;
  364. }else{
  365. $('.register-msg').html('');
  366. }
  367. if(data.username){
  368. $('.register-msg').html(data.username.toString());
  369. return false;
  370. }else{
  371. $('.register-msg').html('');
  372. }
  373. if(data.password){
  374. $('.register-msg').html(data.password.toString());
  375. return false;
  376. }else{
  377. $('.register-msg').html('');
  378. }
  379. if(data.captcha){
  380. $('.register-msg').html(data.captcha.toString());
  381. return false;
  382. }else{
  383. $('.register-msg').html('');
  384. }
  385. if(data.full_name){
  386. $('.register-msg').html(data.full_name.toString());
  387. return false;
  388. }else{
  389. $('.register-msg').html('');
  390. }
  391. if(!data.email && !data.password && !data.captcha && !data.full_name){
  392. if(data[0] != "success"){
  393. $('.register-msg').html(data);
  394. $('#password-register').val('');
  395. $('#captcha-register').val('');
  396. jQuery('#refresh-register-captcha').click();
  397. }else{
  398. $('#email-register').val('');
  399. $('#password-register').val('');
  400. $('#captcha-register').val('');
  401. $('#full-name-register').val('');
  402. $('#username-register').val('');
  403. if(data[1] == ""){
  404. window.location.href = urlConfig('my-library');
  405. }else{
  406. window.location.href = urlConfig(data[1]);
  407. }
  408. }
  409. }else{
  410. $('#password-register').val('');
  411. $('#captcha-register').val('');
  412. jQuery('#refresh-register-captcha').click();
  413. }
  414. });
  415. }else{
  416. $('.msg-agree-service-error').html(selectAgreeService);
  417. }
  418. });
  419. $('#month-birth').change(function(){
  420. var month = $('#month-birth').val();
  421. var date = $('#date-birth').val();
  422. var year = $('#year-birth').val();
  423. var valueMonth = 1;
  424. var monthThirty = ["4","6","9","11"]
  425. if(month == 2){
  426. if((year % 400 == 0) || (year % 4 == 0 && year % 100 != 0)){
  427. valueMonth = 29;
  428. }else{
  429. valueMonth = 28;
  430. }
  431. }else if(monthThirty.indexOf(month) != -1){
  432. valueMonth = 30;
  433. }else{
  434. valueMonth = 31;
  435. }
  436. $('.flag-date').siblings().remove();
  437. for(var i = 1; i<= valueMonth; i++){
  438. if(date == i ){
  439. $('<option value="'+i+'" selected="selected">'+i+'</option>').insertBefore('.flag-date');
  440. }else{
  441. $('<option value="'+i+'">'+i+'</option>').insertBefore('.flag-date');
  442. }
  443. }
  444. });
  445. $('#year-birth').change(function(){
  446. var month = $('#month-birth').val();
  447. var date = $('#date-birth').val();
  448. var year = $('#year-birth').val();
  449. var valueMonth = 1;
  450. var monthThirty = ["4","6","9","11"]
  451. if(month == 2){
  452. if((year % 400 == 0) || (year % 4 == 0 && year % 100 != 0)){
  453. valueMonth = 29;
  454. }else{
  455. valueMonth = 28;
  456. }
  457. }else if(monthThirty.indexOf(month) != -1){
  458. valueMonth = 30;
  459. }else{
  460. valueMonth = 31;
  461. }
  462. $('.flag-date').siblings().remove();
  463. for(var i = 1; i<= valueMonth; i++){
  464. if(date == i ){
  465. $('<option value="'+i+'" selected="selected">'+i+'</option>').insertBefore('.flag-date');
  466. }else{
  467. $('<option value="'+i+'">'+i+'</option>').insertBefore('.flag-date');
  468. }
  469. }
  470. });
  471. $(document).on('change','.logon',function(){
  472. var value = $('input[name=logon]:checked').val();
  473. if(value == 1){
  474. $('.login-now').slideUp();
  475. $('.register-now').slideDown();
  476. }else{
  477. $('.register-now').slideUp();
  478. $('.login-now').slideDown();
  479. }
  480. });
  481. $(document).on('click','#register-by-voca',function(e){
  482. e.preventDefault();
  483. if($(this).hasClass('show-register')){
  484. $(this).html(vocaLang.useSocialAccount);
  485. $('.register-by-voca').slideDown();
  486. $(this).removeClass('show-register');
  487. $(this).addClass('hide-register');
  488. }else{
  489. $(this).html(vocaLang.useVocaAccount);
  490. $('.register-by-voca').slideUp();
  491. $(this).removeClass('hide-register');
  492. $(this).addClass('show-register');
  493. }
  494. });
  495. $(document).on('click','.modal-register-system',function(){
  496. $('#modal-login-system').modal('hide');
  497. });
  498. $('#content-register-loading').removeClass('fullwidth');
  499. });
  500. function redirect(url)
  501. {
  502. fb_login.close();
  503. if(url == ""){
  504. self.location=urlConfig(vocaConfig.loginPage);
  505. }else{
  506. self.location=urlConfig(url);
  507. }
  508. }
  509. function open_login_f(){
  510. var curUrl = $('#current-url').val();
  511. if(curUrl == undefined){
  512. curUrl = "";
  513. }
  514. fb_login=window.open(urlConfig("auth/login-facebook/"+curUrl),'name','width='+screen.width+',height='+screen.height+',top=0,left=0'+',fullscreen=yes');
  515. }
  516. function open_login_g(){
  517. var curUrl = $('#current-url').val();
  518. if(curUrl == undefined){
  519. curUrl = "";
  520. }
  521. fb_login=window.open(urlConfig("auth/login-google/"+curUrl),'name','width='+screen.width+',height='+screen.height+',top=0,left=0'+',fullscreen=yes');
  522. };
  523. /* USER VOICE API */
  524. /*(function(){var uv=document.createElement('script');uv.type='text/javascript';uv.async=true;uv.src='//widget.uservoice.com/ZRfBjfeBHZzNxDpNGWisA.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(uv,s)})()
  525. UserVoice = window.UserVoice || [];
  526. UserVoice.push(['showTab', 'classic_widget', {
  527. mode: 'full',
  528. primary_color: '#133F69',
  529. link_color: '#FFCE0F',
  530. default_mode: 'feedback',
  531. forum_id: 241081,
  532. support_tab_name: vocaLang.contact,
  533. feedback_tab_name: vocaLang.feedback,
  534. tab_label: 'Feedback',
  535. tab_color: '#ECC21B',
  536. tab_position: 'bottom-right',
  537. tab_inverted: false
  538. }]);*/
  539. /* USER REPORT API */
  540. /*var _urq = _urq || [];
  541. _urq.push(['initSite', '8f7a2bd2-67f8-4a17-b058-9790418273f7']);
  542. (function() {
  543. var ur = document.createElement('script'); ur.type = 'text/javascript'; ur.async = true;
  544. ur.src = ('https:' == document.location.protocol ? 'https://cdn.userreport.com/userreport.js' : 'http://cdn.userreport.com/userreport.js');
  545. var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ur, s);
  546. })();
  547. ;*/
  548. $(document).ready(function(){
  549. function getUrl(link){
  550. return location.protocol+'//'+location.host+'/library/'+link;
  551. }
  552. $('.search-topic').keyup(function(e){
  553. var keyWord = $(this).val();
  554. if(e.keyCode == 13 && keyWord !=""){
  555. $.ajax({
  556. url: getUrl("search-topic"),
  557. data: {
  558. keyWord: keyWord
  559. },
  560. type: "POST"
  561. }).done(function(data) {
  562. $('.tab-content').html(data);
  563. $('.search-topic').val('');
  564. });
  565. }
  566. });
  567. });;
  568. $(document).ready(function(){
  569. //rating
  570. $('.click-rating').click(function(event){
  571. var topic = $(this).attr('topic');
  572. var id = $(this).attr('id');
  573. event.preventDefault();
  574. $.ajax({
  575. url: urlConfig("rating-topic"),
  576. data: {
  577. topicId:topic,
  578. },
  579. type:"POST"
  580. }).success(function(data) {
  581. $('.is_rated').html('<a href="javascript:void(0)" class="rating" onclick="return false;" ><img src="'+urlConfig('assets/imgs/star_dark.png')+'"/></a><p>Ðánh giá</p>')
  582. });
  583. });
  584. //click to learn
  585. /*$('.learn-question').click(function(){
  586. var childrenTopic = $(this).attr('childrenTopic');
  587. var parentTopic = $(this).attr('parentTopic');
  588. $('#learn-unknow').attr('href',urlConfig('learning/'+childrenTopic+'-'+parentTopic+'-unknow'));
  589. $('#learn-all').attr('href',urlConfig('learning/'+childrenTopic+'-'+parentTopic));
  590. $('#learn-question').modal('show');
  591. });*/
  592. });
  593. ;
  594. $(document).ready(function(){
  595. $('.warning-alert').fadeIn(5000);
  596. $('.active-product-button').click(function(){
  597. $.blockUI(
  598. {
  599. message: vocaLang.pleaseWaitVoca,
  600. css: {
  601. border: 'none',
  602. padding: '15px',
  603. backgroundColor: '#000',
  604. '-webkit-border-radius': '2px',
  605. '-moz-border-radius': '2px',
  606. opacity: .5,
  607. color: '#fff'
  608. }}
  609. );
  610. });
  611. });
  612. ;
  613. $(document).ready(function(){
  614. $('.speaker').click(function(){
  615. var val = $(this).attr('attr');
  616. $('.audio-'+val).get(0).play();
  617. });
  618. });;
  619. $(document).ready(function(){
  620. //get domain url
  621. function url($ajaxlink){
  622. return location.protocol+'//'+location.host+'/'+$ajaxlink;
  623. }
  624. $('.show-more-user').click(function(){
  625. var topicId = $(this).attr('showId');
  626. var parentTopic = $(this).attr('parentTopic');
  627. var start = $(this).attr('count');
  628. var index = parseInt(start)+10;
  629. $('.show-more-user').attr('count',index);
  630. $.ajax({
  631. url: url("show-more-user-topic-child"),
  632. data: {
  633. topicId:topicId,
  634. start: start,
  635. parentTopic:parentTopic
  636. },
  637. type:"POST"
  638. }).success(function(data) {
  639. if(data!=""){
  640. $(data).insertBefore('.flag-show-more');
  641. }else{
  642. $('.show-more').html('');
  643. }
  644. });
  645. });
  646. $('.show-more-user-parent').click(function(){
  647. var topicId = $(this).attr('showId');
  648. var start = $(this).attr('count');
  649. var index = parseInt(start)+10;
  650. $('.show-more-user-parent').attr('count',index);
  651. $.ajax({
  652. url: url("show-more-user"),
  653. data: {
  654. topicId:topicId,
  655. start: start
  656. },
  657. type:"POST"
  658. }).success(function(data) {
  659. if(data!=""){
  660. $('.list-user-learn').append(data);
  661. //$(data).insertBefore('.flag-show-more');
  662. }else{
  663. $('.show-more-user-parent').css('display','none');
  664. }
  665. });
  666. });
  667. //click to learn
  668. $('.learn-question').click(function(){
  669. var childrenTopic = $(this).attr('childrenTopic');
  670. var parentTopic = $(this).attr('parentTopic');
  671. var isDontKnowWord = $(this).attr('isDontKnowWord');
  672. var isLearContext = parseInt($(this).attr('learn_context'));
  673. if(isLearContext == 1){
  674. $('.learning-context-btn').css('display','inline-block');
  675. }else{
  676. $('.learning-context-btn').css('display','none');
  677. }
  678. $('.learning-flashcard-btn').attr('url',urlConfig('learning/'+childrenTopic+'-'+parentTopic));
  679. $('.learning-writing-btn').attr('url',urlConfig('learning-writing/'+childrenTopic+'-'+parentTopic));
  680. $('.learning-speaking-btn').attr('url',urlConfig('learning-speaking/'+childrenTopic+'-'+parentTopic));
  681. $('.learning-context-btn').attr('url',urlConfig('learning-context/'+childrenTopic+'-'+parentTopic));
  682. if(isDontKnowWord == 1){
  683. $('.flashcard-unknow').attr('href',urlConfig('learning/'+childrenTopic+'-'+parentTopic+'-unknow'));
  684. $('.flashcard-unknow').html('<button type="button" class="btn-learn-new learn-unknow-word-btn" >'+vocaLang.learn_unknow+'</button>');
  685. $('.writing-unknow').attr('href',urlConfig('learning-writing/'+childrenTopic+'-'+parentTopic+'-unknow'));
  686. $('.writing-unknow').html('<button type="button" class="btn-learn-new learn-unknow-word-btn" >'+vocaLang.learn_unknow+'</button>');
  687. $('.speaking-unknow').attr('href',urlConfig('learning-speaking/'+childrenTopic+'-'+parentTopic+'-unknow'));
  688. $('.speaking-unknow').html('<button type="button" class="btn-learn-new learn-unknow-word-btn" >'+vocaLang.learn_unknow+'</button>');
  689. $('.context-unknow').attr('href',urlConfig('learning-context/'+childrenTopic+'-'+parentTopic+'-unknow'));
  690. $('.context-unknow').html('<button type="button" class="btn-learn-new learn-unknow-word-btn" >'+vocaLang.learn_unknow+'</button>');
  691. }else{
  692. $('.flashcard-unknow').attr('href','');
  693. $('.flashcard-unknow').html('');
  694. $('.writing-unknow').attr('href','');
  695. $('.writing-unknow').html('');
  696. $('.speaking-unknow').attr('href','');
  697. $('.speaking-unknow').html('');
  698. $('.context-unknow').attr('href','');
  699. $('.context-unknow').html('');
  700. }
  701. $('.flashcard-learn-all').attr('href',urlConfig('learning/'+childrenTopic+'-'+parentTopic));
  702. $('.writing-learn-all').attr('href',urlConfig('learning-writing/'+childrenTopic+'-'+parentTopic));
  703. $('.speaking-learn-all').attr('href',urlConfig('learning-speaking/'+childrenTopic+'-'+parentTopic));
  704. $('.context-learn-all').attr('href',urlConfig('learning-context/'+childrenTopic+'-'+parentTopic));
  705. $('.choose-learn-words').attr('topic',childrenTopic);
  706. $('.choose-learn-words').attr('parent',parentTopic);
  707. $('#diary-form-choose-learn-words').attr('action',urlConfig('learning/'+childrenTopic+'-'+parentTopic))
  708. $('#learn-question').modal('show');
  709. });
  710. //click to test review
  711. $('#btn-test-review').click(function(){
  712. document.cookie = "testReview=testReview;path=/";
  713. });
  714. });;
  715. $( document ).ready(function() {
  716. // open video in learning guide page
  717. $(".voca-video-features-video").click(function(){
  718. var id = $(this).attr('video');
  719. $("#voca-overlay-box-"+id+",#voca-overlay-"+id).css("display","block");
  720. });
  721. // close video and stop video in learning guide page
  722. $(".voca-overlay-wrapper .close").click(function(){
  723. var id = $(this).attr('wrapper');
  724. $("#voca-overlay-box-"+id+",#voca-overlay-"+id).css("display","none");
  725. var video = $("#player-video-"+id).attr("src");
  726. $("#player-video-"+id).attr("src","");
  727. $("#player-video-"+id).attr("src",video);
  728. });
  729. // open video in library detail page
  730. $(".voca-video-features-video-a").click(function(){
  731. $("#voca-overlay-box,#voca-overlay").css("display","block");
  732. $('#ground-span').fadeIn();
  733. });
  734. // close video and stop video in library detail page
  735. $(".voca-overlay-wrapper .close,#ground-span").click(function(){
  736. $("#voca-overlay-box,#voca-overlay").css("display","none");
  737. $('#ground-span').fadeOut();
  738. var video = $("#player-video").attr("src");
  739. $("#player-video").attr("src","");
  740. $("#player-video").attr("src",video);
  741. });
  742. });;
  743. $(document).ready(function(){
  744. /*$(function(){
  745. var discount = $("input[name='payment_method']:checked").attr('discount');
  746. var totalMoney = $('#total-money').val();
  747. var discountvalue = $('#total-money').attr('discountvalue');
  748. var discountPromotion = $('#promotion_code').attr('discount');
  749. if(discountPromotion == 0){
  750. discountPromotion = discountvalue;
  751. if($('#discount-reference').length){
  752. var domDiscountReference = $('#discount-reference')[0].outerHTML;
  753. }
  754. }
  755. if(discount){
  756. if(discount > 0){
  757. if(discountPromotion > 0){
  758. var discountMoney = parseInt(discount) + parseInt(discountPromotion);
  759. }else{
  760. var discountMoney = discount;
  761. }
  762. var payMoney = totalMoney - discountMoney;
  763. if(domDiscountReference){
  764. $('.total-value-item').html(domDiscountReference+'<div><span class="value-text">'+vocaLang.money+' </span><span class="value-number total-money">'+totalMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.discountMoney+'</span><span class="value-number discount-money">'+discountMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.paymentMoney+'</span><span class="value-number real-value-number payment-money">'+payMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div>');
  765. }else{
  766. $('.total-value-item').html('<div><span class="value-text">'+vocaLang.money+' </span><span class="value-number total-money">'+totalMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.discountMoney+'</span><span class="value-number discount-money">'+discountMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.paymentMoney+'</span><span class="value-number real-value-number payment-money">'+payMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div>');
  767. }
  768. }else{
  769. if(discountPromotion > 0){
  770. var payMoney = totalMoney - discountPromotion;
  771. if(domDiscountReference){
  772. $('.total-value-item').html(domDiscountReference+'<div><span class="value-text">'+vocaLang.money+' </span><span class="value-number total-money">'+totalMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.discountMoney+'</span><span class="value-number discount-money">'+discountPromotion.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.paymentMoney+'</span><span class="value-number real-value-number payment-money">'+payMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div>');
  773. }else{
  774. $('.total-value-item').html('<div><span class="value-text">'+vocaLang.money+' </span><span class="value-number total-money">'+totalMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.discountMoney+'</span><span class="value-number discount-money">'+discountPromotion.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.paymentMoney+'</span><span class="value-number real-value-number payment-money">'+payMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div>');
  775. }
  776. }else{
  777. $('.total-value-item').html('<div><span class="value-text">'+vocaLang.paymentMoney+'</span><span class="value-number real-value-number payment-money">'+totalMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div>');
  778. }
  779. }
  780. }
  781. });
  782. $(function(){
  783. var promotionCodeValue = $('#promotion_code').val();
  784. if(promotionCodeValue != "" && promotionCodeValue!= undefined) {
  785. $('#promotion-code').attr('checked','checked');
  786. $('.div-promotion').css('display','block');
  787. var promotionCode = $('#promotion_code').val();
  788. var productId = $('#product_id').val();
  789. if(promotionCode !=""){
  790. $.ajax({
  791. url: urlConfig("check-promotion-code"),
  792. data: {
  793. promotionCode:promotionCode,
  794. productId:productId
  795. },
  796. type:"POST"
  797. }).success(function(data) {
  798. // var discountGateway = $("input[name='payment_method']:checked").attr('discount');
  799. discountGateway = 0;
  800. var totalMoney = $('#total-money').val();
  801. if(data == "not exist"){
  802. $('#promotion_code').attr('discount',0);
  803. var discountValue = $('#total-money').attr('discountvalue');
  804. if(discountValue > 0){
  805. var payMoney = totalMoney - discountValue - discountGateway ;
  806. $('.total-value-item').html('<div><span class="value-text">'+vocaLang.money+' </span><span class="value-number total-money">'+totalMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.discountMoney+'</span><span class="value-number discount-money">'+(parseInt(discountGateway) + parseInt(discountValue)).toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.paymentMoney+'</span><span class="value-number real-value-number payment-money">'+payMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div>');
  807. }else{
  808. if(discountGateway > 0){
  809. var payMoney = totalMoney - discountGateway ;
  810. $('.total-value-item').html('<div><span class="value-text">'+vocaLang.money+' </span><span class="value-number total-money">'+totalMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.discountMoney+'</span><span class="value-number discount-money">'+discountGateway.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.paymentMoney+'</span><span class="value-number real-value-number payment-money">'+payMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div>');
  811. }else{
  812. $('.total-value-item').html('<div><span class="value-text">'+vocaLang.paymentMoney+'</span><span class="value-number real-value-number payment-money">'+totalMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div>');
  813. }
  814. }
  815. $('.apply-promotion-code-result').text(vocaLang.promotionNotExist);
  816. $('.apply-promotion-code-result').css('color','#F00');
  817. }else{
  818. var discountMoney = data;
  819. $('#promotion_code').attr('discount',discountMoney);
  820. var payMoney = totalMoney - discountMoney - discountGateway;
  821. $('.total-value-item').html('<div><span class="value-text">'+vocaLang.money+' </span><span class="value-number total-money">'+totalMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.discountMoney+'</span><span class="value-number discount-money">'+(parseInt(discountGateway) + parseInt(discountMoney )).toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.paymentMoney+'</span><span class="value-number real-value-number payment-money">'+payMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div>');
  822. }
  823. });
  824. }
  825. }
  826. });
  827. // payment method change
  828. $('#payment_method').change(function(){
  829. var method = $(this).val();
  830. if(method == 1){
  831. $('.payment_method').html('<input type="radio" name="provider_name" id="provider-name-1" value="Mobifone" checked/> MobiFone <input type="radio" name="provider_name" id="provider-name-2" value="Viettel" /> Viettel <input type="radio" name="provider_name" id="provider-name-3" value="Vinaphone" /> Vinaphone');
  832. }else{
  833. $('.payment_method').html('<input type="radio" name="provider_name" id="provider-name-1" value="Vietcombank" checked/> Vietcombank <input type="radio" name="provider_name" id="provider-name-2" value="DongA Bank" /> DongABank <input type="radio" name="provider_name" id="provider-name-3" value="Sacombank" /> Sacombank </br> <input type="radio" name="provider_name" id="provider-name-4" value="Agribank" /> Agribank <input type="radio" name="provider_name" id="provider-name-5" value="Eximbank" /> Eximbank <input type="radio" name="provider_name" id="provider-name-6" value="Viettinbank" /> Viettinbank');
  834. }
  835. });*/
  836. // check promotion code
  837. /*$('.apply-promotion-code').click(function(){
  838. var promotionCode = $('#promotion_code').val();
  839. var productId = $('#product_id').val();
  840. if(promotionCode !=""){
  841. $.ajax({
  842. url: urlConfig("check-promotion-code"),
  843. data: {
  844. promotionCode:promotionCode,
  845. productId:productId
  846. },
  847. type:"POST"
  848. }).success(function(data) {
  849. //var discountGateway = $("input[name='payment_method']:checked").attr('discount');
  850. discountGateway = 0;
  851. var totalMoney = $('#total-money').val();
  852. if(data == "not exist"){
  853. $('#promotion_code').attr('discount',0);
  854. var discountValue = $('#total-money').attr('discountvalue');
  855. if(discountValue > 0){
  856. var payMoney = totalMoney - discountValue - discountGateway ;
  857. $('.total-value-item').html('<div><span class="value-text">'+vocaLang.money+' </span><span class="value-number total-money">'+totalMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.discountMoney+'</span><span class="value-number discount-money">'+(parseInt(discountGateway) + parseInt(discountValue)).toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.paymentMoney+'</span><span class="value-number real-value-number payment-money">'+payMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div>');
  858. }else{
  859. if(discountGateway > 0){
  860. var payMoney = totalMoney - discountGateway ;
  861. $('.total-value-item').html('<div><span class="value-text">'+vocaLang.money+' </span><span class="value-number total-money">'+totalMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.discountMoney+'</span><span class="value-number discount-money">'+discountGateway.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.paymentMoney+'</span><span class="value-number real-value-number payment-money">'+payMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div>');
  862. }else{
  863. $('.total-value-item').html('<div><span class="value-text payment-money">'+vocaLang.paymentMoney+'</span><span class="value-number real-value-number ">'+totalMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div>');
  864. }
  865. }
  866. $('.apply-promotion-code-result').text(vocaLang.promotionNotExist);
  867. $('.apply-promotion-code-result').css('color','#F00');
  868. }else{
  869. var discountMoney = data;
  870. $('#promotion_code').attr('discount',discountMoney);
  871. var payMoney = totalMoney - discountMoney - discountGateway;
  872. $('.total-value-item').html('<div><span class="value-text">'+vocaLang.money+' </span><span class="value-number total-money">'+totalMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.discountMoney+'</span><span class="value-number discount-money">'+(parseInt(discountGateway) + parseInt(discountMoney )).toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.paymentMoney+'</span><span class="value-number real-value-number payment-money">'+payMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div>');
  873. $('.apply-promotion-code-result').text(vocaLang.promotionValid);
  874. $('.apply-promotion-code-result').css('color','#00F');
  875. }
  876. });
  877. }
  878. });*/
  879. /* $('.apply-promotion-code').click(function(){
  880. var promotionCode = $('#promotion_code').val();
  881. var productId = $('#product_id').val();
  882. if(promotionCode !=""){
  883. $.ajax({
  884. url: urlConfig("check-promotion-code"),
  885. data: {
  886. promotionCode:promotionCode,
  887. productId:productId
  888. },
  889. type:"POST"
  890. }).success(function(data) {
  891. console.log(data);
  892. discountGateway = 0;
  893. var totalMoney = $('#total-money').val();
  894. if(data == "not exist"){
  895. $('#promotion_code').attr('discount',0);
  896. var discountValue = $('#total-money').attr('discountvalue');
  897. if(discountValue > 0){
  898. var payMoney = totalMoney - discountValue - discountGateway ;
  899. $('.total-value-item').html('<div><span class="value-text">'+vocaLang.money+' </span><span class="value-number total-money">'+totalMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.discountMoney+'</span><span class="value-number discount-money">'+(parseInt(discountGateway) + parseInt(discountValue)).toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.paymentMoney+'</span><span class="value-number real-value-number payment-money">'+payMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div>');
  900. }else{
  901. if(discountGateway > 0){
  902. var payMoney = totalMoney - discountGateway ;
  903. $('.total-value-item').html('<div><span class="value-text">'+vocaLang.money+' </span><span class="value-number total-money">'+totalMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.discountMoney+'</span><span class="value-number discount-money">'+discountGateway.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.paymentMoney+'</span><span class="value-number real-value-number payment-money">'+payMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div>');
  904. }else{
  905. $('.total-value-item').html('<div><span class="value-text payment-money">'+vocaLang.paymentMoney+'</span><span class="value-number real-value-number ">'+totalMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div>');
  906. }
  907. }
  908. $('.apply-promotion-code-result').text(vocaLang.promotionNotExist);
  909. $('.apply-promotion-code-result').css('color','#F00');
  910. }else{
  911. var discountMoney = data;
  912. $('#promotion_code').attr('discount',discountMoney);
  913. var payMoney = totalMoney - discountMoney - discountGateway;
  914. $('.total-value-item').html('<div><span class="value-text">'+vocaLang.paymentMoney+'</span><span class="value-number real-value-number payment-money">'+payMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div>');
  915. $('.apply-promotion-code-result').text(vocaLang.promotionValid);
  916. $('.apply-promotion-code-result').css('color','#00F');
  917. }
  918. });
  919. }
  920. });
  921. // check promotion code radio button
  922. $('#promotion-code').change(
  923. function(){
  924. if ($(this).val() == "checkpromotioncode") {
  925. $('.div-promotion').fadeIn(1000);
  926. }
  927. });
  928. // click into pament button
  929. $('.payment-now').click(function(){
  930. $.blockUI(
  931. {
  932. message: vocaLang.pleaseWaitVoca,
  933. css: {
  934. border: 'none',
  935. padding: '15px',
  936. backgroundColor: '#000',
  937. '-webkit-border-radius': '2px',
  938. '-moz-border-radius': '2px',
  939. opacity: .5,
  940. color: '#fff'
  941. }}
  942. );
  943. });
  944. // change payment gateway
  945. $('input[name="select_method"]').change(function(){
  946. var discount = $(this).attr('discount');
  947. var totalMoney = $('#total-money').val();
  948. var discountvalue = $('#total-money').attr('discountvalue');
  949. var discountPromotion = $('#promotion_code').attr('discount');
  950. if(discountPromotion == 0){
  951. discountPromotion = discountvalue;
  952. if($('#discount-reference').length){
  953. var domDiscountReference = $('#discount-reference')[0].outerHTML;
  954. }
  955. }
  956. if(discount > 0){
  957. if(discountPromotion > 0){
  958. var discountMoney = parseInt(discount) + parseInt(discountPromotion);
  959. }else{
  960. var discountMoney = discount;
  961. }
  962. var payMoney = totalMoney - discountMoney;
  963. if(domDiscountReference){
  964. $('.total-value-item').html(domDiscountReference+'<div><span class="value-text">'+vocaLang.money+' </span><span class="value-number total-money">'+totalMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.discountMoney+'</span><span class="value-number discount-money">'+discountMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.paymentMoney+'</span><span class="value-number real-value-number payment-money">'+payMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div>');
  965. }else{
  966. $('.total-value-item').html('<div><span class="value-text">'+vocaLang.money+' </span><span class="value-number total-money">'+totalMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.discountMoney+'</span><span class="value-number discount-money">'+discountMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.paymentMoney+'</span><span class="value-number real-value-number payment-money">'+payMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div>');
  967. }
  968. }else{
  969. if(discountPromotion > 0){
  970. var payMoney = totalMoney - discountPromotion;
  971. if(domDiscountReference){
  972. $('.total-value-item').html(domDiscountReference+'<div><span class="value-text">'+vocaLang.money+' </span><span class="value-number total-money">'+totalMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.discountMoney+'</span><span class="value-number discount-money">'+discountPromotion.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.paymentMoney+'</span><span class="value-number real-value-number payment-money">'+payMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div>');
  973. }else{
  974. $('.total-value-item').html('<div><span class="value-text">'+vocaLang.money+' </span><span class="value-number total-money">'+totalMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.discountMoney+'</span><span class="value-number discount-money">'+discountPromotion.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div><div><span class="value-text">'+vocaLang.paymentMoney+'</span><span class="value-number real-value-number payment-money">'+payMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div>');
  975. }
  976. }else{
  977. $('.total-value-item').html('<div><span class="value-text">'+vocaLang.paymentMoney+'</span><span class="value-number real-value-number payment-money">'+totalMoney.toString().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,")+' VND</span></div>');
  978. }
  979. }
  980. });
  981. $('.tab-payment-transfer').click(function(){
  982. $('#chk-payment-transfer').prop("checked", true);
  983. $('#chk-payment-transfer').trigger('change');
  984. if($('#alert-payment-method').length){
  985. $('#alert-payment-method').fadeIn();
  986. $('#alert-payment-method').delay(15000).fadeOut();
  987. }
  988. });
  989. $('.tab-payment-banking').click(function(){
  990. $('#chk-payment-banking').prop("checked", true);
  991. $('#chk-payment-banking').trigger('change');
  992. if($('#alert-payment-method').length){
  993. $('#alert-payment-method').fadeIn();
  994. $('#alert-payment-method').delay(15000).fadeOut();
  995. }
  996. });
  997. $('.tab-payment-card').click(function(){
  998. $('#chk-payment-card').prop("checked", true);
  999. $('#chk-payment-card').trigger('change');
  1000. });
  1001. $('.tab-payment-viettel').click(function(){
  1002. $('#chk-payment-viettel').prop("checked", true);
  1003. $('#chk-payment-viettel').trigger('change');
  1004. });
  1005. $('.tab-payment-nl').click(function(){
  1006. $('#chk-payment-nl').prop("checked", true);
  1007. $('#chk-payment-nl').trigger('change');
  1008. if($('#alert-payment-method').length){
  1009. $('#alert-payment-method').fadeIn();
  1010. $('#alert-payment-method').delay(15000).fadeOut();
  1011. }
  1012. });*/
  1013. $('.choose-learn-words').click(function(){
  1014. var topic = $(this).attr('topic');
  1015. var parent = $(this).attr('parent');
  1016. $.ajax({
  1017. url: urlConfig("choose-learn-words"),
  1018. data: {
  1019. topic : topic,
  1020. parent: parent
  1021. },
  1022. type:"POST"
  1023. }).success(function(data) {
  1024. if(data[0] !=0) {
  1025. $('.show-choose-learn-words').modal();
  1026. $('.modal-dialog-choose-word').html(data);
  1027. }
  1028. });
  1029. });
  1030. //update bell notification
  1031. $('.bell-has-notification').click(function(){
  1032. var countNotification = $('.bell-has-notification .count-notification span').html();
  1033. $.ajax({
  1034. url: urlConfig("update-user-notification"),
  1035. type:"POST"
  1036. }).success(function(data){
  1037. if(data > 0){
  1038. var notifyRemain = countNotification - data;
  1039. if(notifyRemain > 0){
  1040. $('.bell-has-notification .count-notification span').html(notifyRemain);
  1041. }else{
  1042. $('.bell-has-notification .count-notification').css('background','#003366');
  1043. $('.bell-has-notification .count-notification span').css('color','#003366');
  1044. $('.bell-has-notification').addClass('bell-flag');
  1045. //$('.bell-has-notification a img').attr("src",urlConfig("assets/imgs/bell-logo-disable.png"));
  1046. }
  1047. }
  1048. });
  1049. });
  1050. //click btn review
  1051. $('.btn-remind-review').click(function(){
  1052. var topicId = $(this).attr('topic_id');
  1053. var urlRedirect = $(this).attr('url');
  1054. document.cookie='remindTopic='+topicId+';path=/';
  1055. window.location.href = urlRedirect;
  1056. return false;
  1057. });
  1058. //close learning video
  1059. $('.learning-video-modal .close').click(function(){
  1060. $('.learning-video-modal-src').attr('src','');
  1061. });
  1062. //close learning music
  1063. $('.learning-music-modal .close').click(function(){
  1064. $('.learning-music-modal-src').attr('src','');
  1065. });
  1066. //close video modal
  1067. $("#video-modal, .close").click(function(){
  1068. $('.learning-video-modal-src').attr('src','');
  1069. });
  1070. //close music modal
  1071. $("#music-modal, .close").click(function(){
  1072. $('.learning-music-modal-src').attr('src','');
  1073. });
  1074. //view full or few story content
  1075. $(document).on('click','.view-learning-content',function(){
  1076. var storyContent = $(this).attr('content');
  1077. if($(this).hasClass('view-learning-content-full')){
  1078. $('#story-modal .learning-story-content').html(storyContent);
  1079. $(this).removeClass('view-learning-content-full');
  1080. $(this).addClass('view-learning-content-few');
  1081. $(this).html(vocaLang.viewStoryShort);
  1082. }else{
  1083. $('#story-modal .learning-story-content').html(storyContent.substring(0,500)+'...');
  1084. $(this).removeClass('view-learning-content-few');
  1085. $(this).addClass('view-learning-content-full');
  1086. $(this).html(vocaLang.viewStoryFull);
  1087. }
  1088. });
  1089. //change fault content
  1090. $(".fault-content").keyup(function(){
  1091. var faultContent = $(this).val();
  1092. if(faultContent != ""){
  1093. $(".btn-send-fault").css({
  1094. 'background':'#008DF6',
  1095. 'color':'#FFF'
  1096. });
  1097. }else{
  1098. $(".btn-send-fault").css({
  1099. 'background':'#D8EEF9',
  1100. 'color':'#555'
  1101. });
  1102. }
  1103. });
  1104. //cancel send fault
  1105. $(".btn-cancel-fault").click(function(){
  1106. $(".fault-content").val("");
  1107. $('.slt-fault').get(0).selectedIndex = 0;
  1108. $('.fault-content-error').html("");
  1109. $('#feedback-modal').modal('hide');
  1110. });
  1111. //send fault
  1112. $(".btn-send-fault").click(function(){
  1113. var contentFault = $('.fault-content').val();
  1114. var fault = $('.slt-fault').val();
  1115. var topic = $(this).attr('topic');
  1116. var word = $(this).attr('word');
  1117. var synset = $(this).attr('definition');
  1118. if(contentFault == ""){
  1119. $('.fault-content-error').html(vocaLang.faultContentNotEmpty);
  1120. return false;
  1121. }else{
  1122. $('.fault-content-error').html("");
  1123. }
  1124. $(".fault-content").val("");
  1125. $('.slt-fault').get(0).selectedIndex = 0;
  1126. $('.fault-menu').slideUp();
  1127. $('.fault-content-error').html("");
  1128. $.ajax({
  1129. url: urlConfig("report-fault"),
  1130. data: {
  1131. topic: topic,
  1132. fault: fault,
  1133. synset: synset,
  1134. word: word,
  1135. faultContent: contentFault
  1136. },
  1137. type: "POST"
  1138. }).success(function(data) {
  1139. if(data[0] != 0){
  1140. $('.fault-content-error').html(data[1]);
  1141. $('.fault-content-error').css('color','green');
  1142. }else{
  1143. $('.fault-content-error').css('color','red');
  1144. $('.fault-content-error').html(data[1]);
  1145. }
  1146. /* setTimeout(function(){
  1147. $(".message-feedback-result").slideUp();
  1148. },2000);*/
  1149. });
  1150. });
  1151. //put avatar
  1152. $(document).on('click','.btn-put-avatar',function(e){
  1153. var data = new FormData();
  1154. jQuery.each(jQuery('#file-upload')[0].files, function(i, file) {
  1155. data.append('file_'+i, file);
  1156. });
  1157. $.ajax({
  1158. url: urlConfig("update-avatar"), // Url to which the request is send
  1159. type: "POST", // Type of request to be send, called as method
  1160. data: data, // Data sent to server, a set of key/value pairs (i.e. form fields and values)
  1161. contentType: false, // The content type used when sending data to the server.
  1162. cache: false, // To unable request pages to be cached
  1163. processData:false, // To send DOMDocument or non processed data file it is set to false
  1164. success: function(data) // A function to be called if request succeeds
  1165. {
  1166. if(data[0] == 1){
  1167. $('.avatar-picture').attr('src',data[1]);
  1168. $('.btn-edit-avatar.avatar-picture.avatar-picture-item').attr('src',data[1]);
  1169. $('.avatar-picture-item').attr('src',data[1]);
  1170. $('.img-avatar').attr('src',data[1]);
  1171. $('.img-student img').attr('src',data[1]);
  1172. $('.span-avatar .avatar-img').attr('src',data[1]);
  1173. $('.box-img-absolute.btn-edit-avatar img.user-img').attr('src',data[1]);
  1174. $('#change-avatar-modal').modal('hide');
  1175. }else{
  1176. $('.avt-msg').text(data[1]);
  1177. }
  1178. }
  1179. });
  1180. });
  1181. //put avatar
  1182. $(document).on('click','.btn-put-avatar-link',function(){
  1183. var avt = $(this).attr('avatar');
  1184. if(avt !=""){
  1185. $('.img-avatar').attr('src',urlConfig('assets/imgs/loading.gif'));
  1186. $.ajax({
  1187. url: urlConfig("update-avatar-link"),
  1188. data: {
  1189. url : avt
  1190. },
  1191. type: "POST"
  1192. }).success(function(data) {
  1193. $('.avatar-picture').attr('src',avt);
  1194. $('.btn-edit-avatar.avatar-picture.avatar-picture-item').attr('src',avt);
  1195. $('.img-avatar').attr('src',avt)
  1196. $('.user-img').attr('src',avt)
  1197. $('.img-student img').attr('src',avt)
  1198. $('.span-avatar .avatar-img').attr('src',avt);
  1199. $('#change-avatar-modal').modal('hide');
  1200. });
  1201. }
  1202. });
  1203. $(document).on('submit','.upload-form',function(e){
  1204. /*var avt = $(this).attr('avatar');
  1205. if(avt !=""){
  1206. $('.img-avatar').attr('src',urlConfig('assets/imgs/loading.gif'));
  1207. $.ajax({
  1208. url: urlConfig("update-avatar"),
  1209. data: {
  1210. url : avt
  1211. },
  1212. type: "POST"
  1213. }).success(function(data) {
  1214. $('.avatar-picture').attr('src',avt);
  1215. $('.btn-edit-avatar.avatar-picture.avatar-picture-item').attr('src',avt);
  1216. $('.btn-edit-avatar.avatar-picture.avatar-picture-item').addClass('srctttttt');
  1217. $('.img-avatar').attr('src',avt)
  1218. $('.img-student img').attr('src',avt)
  1219. $('.span-avatar .avatar-img').attr('src',avt);
  1220. $('#change-avatar-modal').modal('hide');
  1221. });
  1222. }*/
  1223. e.preventDefault();
  1224. $.ajax({
  1225. url: urlConfig("update-avatar"), // Url to which the request is send
  1226. type: "POST", // Type of request to be send, called as method
  1227. data: new FormData(this), // Data sent to server, a set of key/value pairs (i.e. form fields and values)
  1228. contentType: false, // The content type used when sending data to the server.
  1229. cache: false, // To unable request pages to be cached
  1230. processData:false, // To send DOMDocument or non processed data file it is set to false
  1231. success: function(data) // A function to be called if request succeeds
  1232. {
  1233. $('#loading').hide();
  1234. $("#message").html(data);
  1235. }
  1236. });
  1237. });
  1238. //cancel avatar
  1239. $(document).on('click','.btn-cancel-avatar',function(){
  1240. $('.btn-put-avatar').attr('avatar','');
  1241. $('#change-avatar-modal').modal('hide');
  1242. });
  1243. //change full name info in profile
  1244. $(".profile-full-name").keyup(function(){
  1245. var val = $(this).val();
  1246. if(val != ""){
  1247. $(".btn-update-info").css({
  1248. 'background':'rgb(0, 141, 246)',
  1249. 'color':'#FFF'
  1250. });
  1251. }else{
  1252. $(".btn-update-info").css({
  1253. 'background':'#EBEBEB',
  1254. 'color':'#AEBAC6'
  1255. });
  1256. }
  1257. });
  1258. $(document).click(function() {
  1259. $('.span-avatar .tooltip').css('display','none');
  1260. $('.avatar-picture').tooltip('hide');
  1261. });
  1262. $('.span-avatar').click(function(event){
  1263. event.stopPropagation();
  1264. $('.btn-bell.open').removeClass('open');
  1265. });
  1266. $('.span-avatar .tooltip-inner').click(function(event) {
  1267. event.stopPropagation();
  1268. });
  1269. $('.btn-bell').click(function(){
  1270. $('.span-avatar .tooltip').css('display','none');
  1271. $('.avatar-picture').tooltip('hide');
  1272. });
  1273. //hover level icon
  1274. $('.dashboard-level-link').mouseover(function() {
  1275. $('.dashboard-level-link span').css('text-decoration','underline');
  1276. $('.dashboard-level-link img').attr('src',urlConfig('assets/imgs/level-icon.png'));
  1277. });
  1278. //mouseout level icon
  1279. $('.dashboard-level-link').mouseout(function() {
  1280. $('.dashboard-level-link span').css('text-decoration','none');
  1281. $('.dashboard-level-link img').attr('src',urlConfig('assets/imgs/level-disable-icon.png'));
  1282. });
  1283. //hover invite friends icon
  1284. $('.dashboard-invite-friends').mouseover(function(){
  1285. $('.dashboard-invite-friends .fa-info-circle').css('color','#3C599B');
  1286. });
  1287. //mouseout invite friends icon
  1288. $('.dashboard-invite-friends').mouseout(function(){
  1289. $('.dashboard-invite-friends .fa-info-circle').css('color','#7b7979');
  1290. });
  1291. //hover ranking icon
  1292. $('.dashboard-ranking-link').mouseover(function() {
  1293. $('.dashboard-ranking-link span').css('text-decoration','underline');
  1294. $('.dashboard-ranking-link img').attr('src',urlConfig('assets/imgs/ranking-icon.png'));
  1295. });
  1296. //mouseout ranking icon
  1297. $('.dashboard-ranking-link').mouseout(function() {
  1298. $('.dashboard-ranking-link span').css('text-decoration','none');
  1299. $('.dashboard-ranking-link img').attr('src',urlConfig('assets/imgs/ranking-disable-icon.png'));
  1300. });
  1301. //click support items
  1302. $('.support-items').click(function(){
  1303. var id = $(this).attr('id');
  1304. var supportId = $(this).attr('support-id');
  1305. if($('#'+id+' ul .support-child-item').length){
  1306. $('#'+id+' ul .support-child-item').slideToggle();
  1307. $('#'+id).siblings().find('ul .support-child-item').slideUp();
  1308. $('#'+id).siblings().find('.flag-caret').removeClass('fa-caret-down');
  1309. $('#'+id).siblings().find('.flag-caret').addClass('fa-caret-right');
  1310. if($('#'+id +' span .flag-caret').hasClass('fa-caret-right')){
  1311. $('#'+id +' span .flag-caret').removeClass('fa-caret-right');
  1312. $('#'+id +' span .flag-caret').addClass('fa-caret-down');
  1313. }else{
  1314. $('#'+id +' span .flag-caret').removeClass('fa-caret-down');
  1315. $('#'+id +' span .flag-caret').addClass('fa-caret-right');
  1316. }
  1317. }else{
  1318. var supportLink = urlConfig('support/'+supportId);
  1319. window.location.href = supportLink;
  1320. return false;
  1321. }
  1322. });
  1323. $('.support-child-item').click(function(event) {
  1324. event.stopPropagation();
  1325. });
  1326. //
  1327. $('.support-post-item').click(function(){
  1328. var id = $(this).attr('support-post-id');
  1329. if($('.support-post-item-'+id +' .flag-caret-post').hasClass('fa-caret-right')){
  1330. $('.support-post-item-'+id +' .flag-caret-post').removeClass('fa-caret-right');
  1331. $('.support-post-item-'+id +' .flag-caret-post').addClass('fa-caret-down');
  1332. $(this).css('font-family','OpenSansBold');
  1333. }else{
  1334. $('.support-post-item-'+id +' .flag-caret-post').removeClass('fa-caret-down');
  1335. $('.support-post-item-'+id +' .flag-caret-post').addClass('fa-caret-right');
  1336. $(this).css('font-family','OpenSansRegular');
  1337. }
  1338. $(this).siblings().slideToggle();
  1339. });
  1340. /*Begin zopim chat*/
  1341. /*window.$zopim||(function(d,s){var z=$zopim=function(c){z._.push(c)},$=z.s=
  1342. d.createElement(s),e=d.getElementsByTagName(s)[0];z.set=function(o){z.set.
  1343. _.push(o)};z._=[];z.set._=[];$.async=!0;$.setAttribute('charset','utf-8');
  1344. $.src='//v2.zopim.com/?2aBFL1eRpDl1lE0Hgc3RCZeLw9Vo2Hiu';z.t=+new Date;$.
  1345. type='text/javascript';e.parentNode.insertBefore($,e)})(document,'script');
  1346. $zopim(function() {
  1347. $zopim.livechat.theme.setColor('#003366');
  1348. $zopim.livechat.prechatForm.setGreetings('Please introduce yourself.');
  1349. });*/
  1350. /*End zopim chat*/
  1351. /*Begin vchat*/
  1352. /*(function() {var _h1= document.getElementsByTagName('title')[0] || false;
  1353. var product_name = ''; if(_h1){product_name= _h1.textContent || _h1.innerText;}var ga = document.createElement('script'); ga.type = 'text/javascript';
  1354. ga.src = '//live.vnpgroup.net/js/web_client_box.php?hash=6b555e3d0733f04c8ebfa88e57d89cd8&data=eyJoYXNoIjoiMTE3M2UxODdjMjMxZTA2Y2VhNzc2OGYwMTEwMTdhNGEiLCJzc29faWQiOjI4MDc1OTd9&pname='+product_name;
  1355. var s = document.getElementsByTagName('script');s[0].parentNode.insertBefore(ga, s[0]);})();*/
  1356. /*End vchat*/
  1357. $('.library-add-vocabulary').click(function(){
  1358. event.preventDefault();
  1359. });
  1360. $('.library-share-fb').click(function(){
  1361. event.preventDefault();
  1362. });
  1363. $('.hide-vocabulary-temp').click(function(){
  1364. event.preventDefault();
  1365. });
  1366. $('.stop-receive-remind-vocabulary').click(function(){
  1367. event.preventDefault();
  1368. });
  1369. $('.receive-remind-vocabulary').click(function(){
  1370. event.preventDefault();
  1371. });
  1372. //add vocabulary to personal page
  1373. var objaddVocabulary;
  1374. $('.library-add-vocabulary').click(function(){
  1375. objaddVocabulary = $(this);
  1376. var val = $(this).attr('value');
  1377. $.ajax({
  1378. url: urlConfig("library/app-vocabulary-to-personal-page"),
  1379. data: {
  1380. vocabulary_id : val
  1381. },
  1382. type: "POST"
  1383. }).success(function(data) {
  1384. objaddVocabulary.css("display","none");
  1385. objaddVocabulary.siblings().removeClass("library-share-fb-margin-top");
  1386. $("body").append('<span class="toast-msg">'+data[1]+'</span>');
  1387. $(".toast-msg").fadeIn(400,function(){
  1388. setTimeout(function(){
  1389. $(".toast-msg").fadeOut(function(){
  1390. $(".toast-msg").remove();
  1391. });
  1392. }, 2000);
  1393. });
  1394. });
  1395. });
  1396. //click buy now in library page
  1397. $('.library-buy-now').click(function(){
  1398. var val = $(this).attr('value');
  1399. window.location.href = urlConfig("buy-product/"+val);
  1400. });
  1401. //hide vocabulary from personal page
  1402. var objHideVocabulary;
  1403. $('.hide-vocabulary-temp').click(function(){
  1404. var val = $(this).attr('value');
  1405. objHideVocabulary = $(this);
  1406. $.ajax({
  1407. url: urlConfig("hide-vocabulary"),
  1408. data: {
  1409. vocabulary_id : val
  1410. },
  1411. type: "POST"
  1412. }).success(function(data) {
  1413. if(data[0] == 0){
  1414. $("body").append('<span class="toast-msg">'+data[1]+'</span>');
  1415. $(".toast-msg").fadeIn(400,function(){
  1416. setTimeout(function(){
  1417. $(".toast-msg").fadeOut(function(){
  1418. $(".toast-msg").remove();
  1419. });
  1420. }, 2000);
  1421. });
  1422. }else{
  1423. objHideVocabulary.parents('.personal-library-product').remove();
  1424. }
  1425. });
  1426. });
  1427. //hide remind of vocabulary set
  1428. var objHideRemind;
  1429. $(document).on('click','.stop-receive-remind-vocabulary',function(){
  1430. var val = $(this).attr('value');
  1431. objHideRemind = $(this);
  1432. $.ajax({
  1433. url: urlConfig("hide-vocabulary-remind"),
  1434. data: {
  1435. vocabulary_id : val
  1436. },
  1437. type: "POST"
  1438. }).success(function(data) {
  1439. if(data[0] == 0){
  1440. $("body").append('<span class="toast-msg">'+data[1]+'</span>');
  1441. $(".toast-msg").fadeIn(400,function(){
  1442. setTimeout(function(){
  1443. $(".toast-msg").fadeOut(function(){
  1444. $(".toast-msg").remove();
  1445. });
  1446. }, 2000);
  1447. });
  1448. }else{
  1449. $("body").append('<span class="toast-msg">'+vocaLang.updateSuccess+'</span>');
  1450. $(".toast-msg").fadeIn(400,function(){
  1451. setTimeout(function(){
  1452. $(".toast-msg").fadeOut(function(){
  1453. $(".toast-msg").remove();
  1454. });
  1455. }, 2000);
  1456. });
  1457. }
  1458. });
  1459. });
  1460. //visible remind of vocabulary set
  1461. var objHideRemind;
  1462. $(document).on('click','.receive-remind-vocabulary',function(){
  1463. var val = $(this).attr('value');
  1464. objHideRemind = $(this);
  1465. $.ajax({
  1466. url: urlConfig("visible-vocabulary-remind"),
  1467. data: {
  1468. vocabulary_id : val
  1469. },
  1470. type: "POST"
  1471. }).success(function(data) {
  1472. if(data[0] == 0){
  1473. $("body").append('<span class="toast-msg">'+data[1]+'</span>');
  1474. $(".toast-msg").fadeIn(400,function(){
  1475. setTimeout(function(){
  1476. $(".toast-msg").fadeOut(function(){
  1477. $(".toast-msg").remove();
  1478. });
  1479. }, 2000);
  1480. });
  1481. }else{
  1482. $("body").append('<span class="toast-msg">'+vocaLang.updateSuccess+'</span>');
  1483. $(".toast-msg").fadeIn(400,function(){
  1484. setTimeout(function(){
  1485. $(".toast-msg").fadeOut(function(){
  1486. $(".toast-msg").remove();
  1487. });
  1488. }, 2000);
  1489. });
  1490. }
  1491. });
  1492. });
  1493. var checkBox = 1;
  1494. $(window).click(function(){
  1495. if(checkBox == 1){
  1496. $('.box-search-vocabulary-result').css('display','none');
  1497. }
  1498. });
  1499. $(document).on('click','.box-search-vocabulary-result .box-the-word-change-tab',function(){
  1500. var value = $(this).attr('link');
  1501. window.location.href = urlConfig('library#'+value);
  1502. var seg = $(location).attr('pathname');
  1503. seg.indexOf(1);
  1504. seg.toLowerCase();
  1505. seg1 = seg.split("/")[2];
  1506. seg = seg.split("/")[1];
  1507. if(seg == "library" && seg1 == undefined ){
  1508. window.location.reload(true);
  1509. }
  1510. });
  1511. //search library
  1512. $('.txt-search').click(function(){
  1513. checkBox = 0;
  1514. var value = $(this).val();
  1515. if(value.length < 1){
  1516. var content = $('.box-search-result-item').html();
  1517. if(content == ""){
  1518. $.ajax({
  1519. url: urlConfig("search-cate"),
  1520. type:"POST"
  1521. }).success(function(data) {
  1522. $('.box-search-result-item').html(data);
  1523. $('.box-search-vocabulary-result').css('display','block');
  1524. $('.box-search-result-item').css('display','block');
  1525. $('.box-search-result-item').next().remove();
  1526. });
  1527. }else{
  1528. $('.box-search-vocabulary-result').css('display','block');
  1529. $('.box-search-result-item').css('display','block');
  1530. $('.box-search-result-item').next().remove();
  1531. }
  1532. }else{
  1533. $('.box-search-vocabulary-result').css('display','block');
  1534. $('.box-search-result-item').css('display','none');
  1535. }
  1536. setTimeout(function(){
  1537. checkBox = 1;
  1538. },500);
  1539. });
  1540. $('.txt-search').keyup(function(e){
  1541. var value = $(this).val();
  1542. if(value.trim() != ""){
  1543. if(e.keyCode == 13){
  1544. window.location.href = urlConfig('library-search/'+value);
  1545. }else{
  1546. if(value.length >= 1){
  1547. $.ajax({
  1548. url: urlConfig("library-search"),
  1549. data: {
  1550. key_word : value
  1551. },
  1552. type:"POST"
  1553. }).success(function(data) {
  1554. $('.box-search-result-item').css('display','none');
  1555. $('.box-search-result-item').next().remove();
  1556. $(data).insertAfter('.box-search-result-item');
  1557. });
  1558. }
  1559. }
  1560. }else{
  1561. $('.box-search-result-item').css('display','block');
  1562. $('.box-search-result-item').next().remove();
  1563. }
  1564. });
  1565. $('.btn-search').click(function(){
  1566. var value = $('.txt-search').val();
  1567. if(value.trim() != ""){
  1568. window.location.href = urlConfig('library-search/'+value);
  1569. }
  1570. });
  1571. //suggest
  1572. //refresh-captcha
  1573. $(document).on('click','.refresh-captcha-search',function(){
  1574. $.ajax({
  1575. url: urlConfig("auth/get-captcha"),
  1576. type:"POST"
  1577. }).success(function( data) {
  1578. $(".img-captcha").attr("src",data);
  1579. });
  1580. });
  1581. $('.put-change-two').css('display',"none");
  1582. $(document).on('change','.change-cate-suggest',function(){
  1583. if($('.change-cate-suggest').val()==1)
  1584. {
  1585. $('.put-change-one').css('display',"block");
  1586. $('.put-change-two').css('display',"none");
  1587. $('.btn-keep').addClass('btn-send-suggest-home');
  1588. $('.btn-keep').removeClass('btn-send-suggest-idea');
  1589. }
  1590. else
  1591. {
  1592. $('.put-change-one').css('display',"none");
  1593. $('.put-change-two').css('display',"block");
  1594. $('.btn-keep').removeClass('btn-send-suggest-home');
  1595. $('.btn-keep').addClass('btn-send-suggest-idea');
  1596. }
  1597. });
  1598. $(document).on('click','.suggest-the-word-menu-home',function(){
  1599. jQuery('.refresh-captcha-search').click();
  1600. $('#suggest-the-word-modal-home').modal();
  1601. });
  1602. $('.btn-send-suggest-home').click(function(){
  1603. var type = $('.change-cate-suggest').val();
  1604. if(type == 1){
  1605. var vocabularyName = $('.txt-name-vocabulary').val();
  1606. var idea = $('.summary-idea-home').val();
  1607. var source = $('.source-book-home-idea').val();
  1608. var captcha = $('.txt-suggest-vocabulary-captcha').val();
  1609. if(vocabularyName.trim() != "" && idea.trim() != ""){
  1610. $('#suggest-the-word-modal-home').modal('hide');
  1611. $.ajax({
  1612. url: urlConfig("suggest-vocabulary"),
  1613. data: {
  1614. vocabulary_name : vocabularyName,
  1615. vocabulary_idea : idea,
  1616. vocabulary_document : source,
  1617. captcha : captcha
  1618. },
  1619. type:"POST"
  1620. }).success(function(data) {
  1621. $("body").append('<span class="toast-msg">'+data[1]+'</span>');
  1622. $(".toast-msg").fadeIn(400,function(){
  1623. setTimeout(function(){
  1624. $(".toast-msg").fadeOut(function(){
  1625. $(".toast-msg").remove();
  1626. });
  1627. }, 2000);
  1628. });
  1629. });
  1630. }else{
  1631. $('.suggest-msg-search').text("Please, fill full infomation!");
  1632. }
  1633. }else{
  1634. var idea = $('.summary-idea-home-tab-difference').val();
  1635. var captcha = $('.txt-suggest-vocabulary-captcha').val();
  1636. if(idea.trim() != ""){
  1637. $('#suggest-the-word-modal-home').modal('hide');
  1638. $.ajax({
  1639. url: urlConfig("suggest-idea"),
  1640. data: {
  1641. idea : idea,
  1642. captcha : captcha
  1643. },
  1644. type:"POST"
  1645. }).success(function(data) {
  1646. $("body").append('<span class="toast-msg">'+data[1]+'</span>');
  1647. $(".toast-msg").fadeIn(400,function(){
  1648. setTimeout(function(){
  1649. $(".toast-msg").fadeOut(function(){
  1650. $(".toast-msg").remove();
  1651. });
  1652. }, 2000);
  1653. });
  1654. });
  1655. }else{
  1656. $('.suggest-msg-search').text("Please, fill full infomation!");
  1657. }
  1658. }
  1659. });
  1660. //choose learning method
  1661. $('.learning-writing-btn, .learning-speaking-btn, .learning-flashcard-btn,.learning-context-btn').click(function(){
  1662. $('.show-choose-learn-words form').attr('action',$(this).attr('url'));
  1663. });
  1664. var uagent = navigator.userAgent.toLowerCase();
  1665. if (navigator.userAgent.match(/iPad|iPhone|iPod|Android|Windows Phone/i) != null ){
  1666. //var text = '<div><marquee onmouseover="this.stop();" onmouseout="this.start();">Hãy học VOCA trên <strong>Máy tính</strong> hoặc <strong>Laptop</strong> với các trình duyệt <strong>Chrome, Cốc Cốc</strong> để được hỗ trợ tốt nhất bạn nhé! ^^</marquee></div><a href="javascript:void(0)" ><span class="mobile-close-notification">&times;</span></a>';
  1667. //$('.mobile-notification').html(text);
  1668. //$('.mobile-notification').css('display','block');
  1669. $('.notification').css('display','none');
  1670. $('.close-notification').css('display','none');
  1671. }
  1672. $(document).on('click','.mobile-close-notification',function(){
  1673. $('.mobile-notification').css('display','none');
  1674. $('.mobile-close-notification').css('display','none');
  1675. document.cookie="closeMobileNotification=closenotification;path=/";
  1676. });
  1677. /**begin library community general**/
  1678. $('.library-community-back').click(function(){
  1679. window.location = urlConfig('library-community');
  1680. return;
  1681. if(history.length === 1){
  1682. window.location = urlConfig('library-community');
  1683. } else {
  1684. history.back();
  1685. }
  1686. });
  1687. /**end library community general**/
  1688. /**Begin pin word group**/
  1689. //click pin word icon
  1690. $('.pin-word').click(function(e){
  1691. e.stopPropagation();
  1692. var vocabulary = $(this).attr('vocabulary');
  1693. var word = $(this).attr('word');
  1694. var definition = $(this).attr('definition');
  1695. $.ajax({
  1696. url: urlConfig("pin-word"),
  1697. data: {
  1698. 'vocabulary' : vocabulary,
  1699. 'word' : word,
  1700. 'definition' : definition
  1701. },
  1702. type: "POST"
  1703. }).success(function(data) {
  1704. $('#pin-word-modal').html(data);
  1705. $('#pin-word-modal').modal();
  1706. });
  1707. });
  1708. //event modal select archive
  1709. $(document).on("click",".item-select-archive-word",function(){
  1710. $(".btn-acept-archive-select").removeClass("btn-acept-archive-select-active");
  1711. if($(this).hasClass("item-select-archive-word-active")){
  1712. $(this).removeClass("item-select-archive-word-active");
  1713. }
  1714. else{
  1715. $(".item-select-archive-word").removeClass("item-select-archive-word-active");
  1716. $(this).addClass("item-select-archive-word-active");
  1717. }
  1718. $('.pin-word-vocabulary-name').prop('checked', false);
  1719. $(".item-select-archive-word").each(function(){
  1720. if($(this).hasClass("item-select-archive-word-active")){
  1721. $(this).find('.pin-word-vocabulary-name').prop('checked', true);
  1722. $(".btn-acept-archive-select").addClass("btn-acept-archive-select-active");
  1723. }
  1724. });
  1725. });
  1726. //pin word button
  1727. $(document).on('click','.btn-pin-word',function(){
  1728. if ($("input[name='rad_vocabulary_name']:checked").val()) {
  1729. var name = $("input[name='rad_vocabulary_name']:checked").val();
  1730. var vocabulary = $('.pin-word-vocabulary-content').val();
  1731. var word = $('.pin-word-word-content').val();
  1732. var definition = $('.pin-word-definition-content').val();
  1733. $('.pin-word-error').text('');
  1734. $.ajax({
  1735. url: urlConfig("pin-vocabulary-word"),
  1736. data: {
  1737. 'vocabulary' : vocabulary,
  1738. 'word' : word,
  1739. 'definition' : definition,
  1740. 'name' : name
  1741. },
  1742. type: "POST"
  1743. }).success(function(data) {
  1744. if(data[0] == 0){
  1745. $('.pin-word-error').text(data[1]);
  1746. }else{
  1747. $('#pin-word-modal').modal('hide');
  1748. setTimeout(function(){
  1749. $('#pin-word-modal').html(data[1]);
  1750. $('#pin-word-modal').modal('show');
  1751. setTimeout(function(){
  1752. $('#pin-word-modal').modal('hide');
  1753. },2000);
  1754. },1000);
  1755. }
  1756. });
  1757. }
  1758. });
  1759. //pin word add vocabulary
  1760. $(document).on('click','.btn-pin-word-add-vocabulary',function(){
  1761. var vocabulary = $('.pin-word-vocabulary-content').val();
  1762. var word = $('.pin-word-word-content').val();
  1763. var definition = $('.pin-word-definition-content').val();
  1764. $.ajax({
  1765. url: urlConfig("pin-word-add-vocabulary"),
  1766. data: {
  1767. 'vocabulary' : vocabulary,
  1768. 'word' : word,
  1769. 'definition' : definition,
  1770. },
  1771. type: "POST"
  1772. }).success(function(data) {
  1773. $('#pin-word-modal').modal('hide');
  1774. setTimeout(function(){
  1775. $('#pin-word-modal').html(data);
  1776. $('#pin-word-modal').modal('show');
  1777. },1000);
  1778. });
  1779. });
  1780. $(document).on("click",".add-image-feature",function(){
  1781. $(".box-select-img-word").removeClass("animated bounceOutRight");
  1782. setTimeout(function(){
  1783. $(".box-select-img-word").css("display","block");
  1784. $(".box-select-img-word").addClass("animated bounceInRight");
  1785. setTimeout(function(){
  1786. $(".img-avatar-word").each(function() {
  1787. var width_img_avatar=$(this).width();
  1788. var height_img_avatar=width_img_avatar/2;
  1789. $( this ).css("height",height_img_avatar);
  1790. });
  1791. },300);
  1792. },500);
  1793. $(window).resize(function(){
  1794. setTimeout(function(){
  1795. $(".img-avatar-word").each(function() {
  1796. var width_img_avatar=$(this).width();
  1797. var height_img_avatar=width_img_avatar/2;
  1798. $( this ).css("height",height_img_avatar);
  1799. });
  1800. },300);
  1801. });
  1802. });
  1803. $(document).on('click','.btn-back-pin-word',function(){
  1804. $(".box-select-img-word").removeClass("animated bounceInRight");
  1805. $(".box-select-img-word").addClass("animated bounceOutRight");
  1806. setTimeout(function(){
  1807. $(".box-select-img-word").css("display","none");
  1808. },500);
  1809. });
  1810. $(document).on("click",".item-img-select.add-image-vocabulary",function(){
  1811. $(".style-btn-update-img").removeClass("style-btn-update-img-active");
  1812. if($(this).hasClass("checked-img")){
  1813. $(this).removeClass("checked-img");
  1814. }
  1815. else{
  1816. $(".item-img-select.add-image-vocabulary").each(function(){
  1817. if($(this).hasClass("checked-img")){
  1818. $(this).removeClass("checked-img");
  1819. $(this).find(".box-opacity-when-hover").css("display","none");
  1820. }
  1821. });
  1822. $(this).addClass("checked-img");
  1823. }
  1824. $(".item-img-select.add-image-vocabulary").each(function(){
  1825. if($(this).hasClass("checked-img")){
  1826. $(".style-btn-update-img").addClass("style-btn-update-img-active");
  1827. }
  1828. });
  1829. });
  1830. $(document).on("mouseenter",".item-img-select.add-image-vocabulary",function(){
  1831. if(!$(this).hasClass("checked-img")){
  1832. $(this).find(".box-opacity-when-hover").fadeIn(200);
  1833. }
  1834. });
  1835. $(document).on("mouseleave",".item-img-select.add-image-vocabulary",function(){
  1836. if(!$(this).hasClass("checked-img")){
  1837. $(this).find(".box-opacity-when-hover").fadeOut(200);
  1838. }
  1839. });
  1840. $(document).on("click","#pin-word-modal .box-input-three",function(){
  1841. if ($(this).find(".check-box-opacity").is(':checked')) {
  1842. $(this).find(".check-box-opacity").prop('checked', false);
  1843. $(this).find(".content-check-agree").css("display","inline-block");
  1844. $(this).find(".content-check-agreeed").css("display","none");
  1845. $(this).find(".box-check-style").css("background","none");
  1846. $(this).find(".box-check-style").css("border","solid 1px #c3c3c3");
  1847. }
  1848. else{
  1849. $(this).find(".check-box-opacity").prop('checked', true);
  1850. $(this).find(".content-check-agree").css("display","none");
  1851. $(this).find(".content-check-agreeed").css("display","inline-block");
  1852. $(this).find(".box-check-style").css("background","#00bdfd");
  1853. $(this).find(".box-check-style").css("border","none");
  1854. }
  1855. });
  1856. $(document).on("click",".btn-pin-update-img",function(){
  1857. if($(this).hasClass("style-btn-update-img-active")){
  1858. var srcImgSelect = "";
  1859. $(".item-img-select.add-image-vocabulary").each(function(){
  1860. if($(this).hasClass("checked-img")){
  1861. srcImgSelect = $(this).find(".img-avatar-word").attr("src");
  1862. return;
  1863. }
  1864. });
  1865. $(".pin-add-vocabulary-image-content").attr("src",srcImgSelect);
  1866. $(".box-select-img-word").removeClass("animated bounceInRight");
  1867. $(".box-select-img-word").addClass("animated bounceOutRight");
  1868. setTimeout(function(){
  1869. $(".box-select-img-word").css("display","none");
  1870. },500);
  1871. if($(".pin-word-vocabulary-name").val().length > 0 && $(".pin-word-vocabulary-name").val().length <= 35 && $(".pin-word-vocabulary-description").val().length > 0 && $(".pin-word-vocabulary-description").val().length <= 300 && $(".pin-add-vocabulary-image-content").attr("src") != ""){
  1872. $(".a-pin-word-add-vocabulary").addClass("style-btn-create-active");
  1873. }else{
  1874. $(".a-pin-word-add-vocabulary").removeClass("style-btn-create-active");
  1875. }
  1876. }
  1877. else{
  1878. alert("Vui lòng ch?n hình b? t?.");
  1879. }
  1880. });
  1881. $(document).on("keyup",".pin-word-vocabulary-name,.pin-word-vocabulary-description",function(){
  1882. if($(".pin-word-vocabulary-name").val().length > 0 && $(".pin-word-vocabulary-name").val().length <= 35 && $(".pin-word-vocabulary-description").val().length > 0 && $(".pin-word-vocabulary-description").val().length <= 300 && $(".pin-add-vocabulary-image-content").attr("src") != ""){
  1883. $(".a-pin-word-add-vocabulary").addClass("style-btn-create-active");
  1884. }else{
  1885. $(".a-pin-word-add-vocabulary").removeClass("style-btn-create-active");
  1886. }
  1887. });
  1888. var isAdded = 0;
  1889. $(document).on('click','.a-pin-word-add-vocabulary',function(){
  1890. if(isAdded == 1){
  1891. return;
  1892. }
  1893. isAdded = 1;
  1894. var vocabulary = $('.pin-word-vocabulary-content').val();
  1895. var word = $('.pin-word-word-content').val();
  1896. var definition = $('.pin-word-definition-content').val();
  1897. var name = $('.pin-word-vocabulary-name').val();
  1898. var cate = $('.pin-word-vocabulary-cate').val();
  1899. var imgLink = $('.pin-add-vocabulary-image-content').attr('src');
  1900. var description = $('.pin-word-vocabulary-description').val();
  1901. var quantity = $('.pin-word-community-quantity').val();
  1902. var isPublic = 0;
  1903. if($('.pin-word-community-public').is(':checked')){
  1904. isPublic = 1;
  1905. }
  1906. $.ajax({
  1907. url: urlConfig("pin-word-and-add-vocabulary"),
  1908. data: {
  1909. 'vocabulary' : vocabulary,
  1910. 'word' : word,
  1911. 'definition' : definition,
  1912. 'name' : name,
  1913. 'cate' : cate,
  1914. 'img_link' : imgLink,
  1915. 'description' : description,
  1916. 'quantity' : quantity,
  1917. 'is_public' : isPublic
  1918. },
  1919. type: "POST"
  1920. }).success(function(data) {
  1921. if(data[0] == 0){
  1922. $('.pin-word-error').text(data[1]);
  1923. isAdded = 0;
  1924. }else{
  1925. $('#pin-word-modal').modal('hide');
  1926. setTimeout(function(){
  1927. $('#pin-word-modal').html(data[1]);
  1928. $('#pin-word-modal').modal('show');
  1929. isAdded = 0;
  1930. },1000);
  1931. }
  1932. });
  1933. });
  1934. $(document).on('change','.slt-topic-cate',function(){
  1935. var id = $(this).val();
  1936. $('.slt-topic-cate').val(id);
  1937. $(".pin-add-vocabulary-image-content").attr("src","");
  1938. $.ajax({
  1939. url: urlConfig("get-image-by-product-cate/"+id),
  1940. type: "POST"
  1941. }).success(function(data) {
  1942. $('.image-community-group').html(data);
  1943. });
  1944. });
  1945. /**End pin word group**/
  1946. /**begin pin word search**/
  1947. $(document).on('keyup','.txt-search-pin-word',function(){
  1948. var keyword = $(this).val();
  1949. if(keyword.trim() != ""){
  1950. $('.remove-search').addClass('remove-search-active');
  1951. if(localStorage['pin_key_'+keyword] != undefined){
  1952. $('.search-pin-item').next().remove();
  1953. $(localStorage['pin_key_'+keyword]).insertAfter('.search-pin-item');
  1954. return;
  1955. }
  1956. }else{
  1957. $('.search-pin-item').next().remove();
  1958. $('.remove-search').removeClass('remove-search-active');
  1959. return;
  1960. }
  1961. clearTimeout($.data(this, 'timersearch'));
  1962. var id = $(this).attr('vocabulary');
  1963. $(this).data('timersearch', setTimeout(function(){
  1964. if(keyword.trim() != ""){
  1965. //$('.remove-search').addClass('remove-search-active');
  1966. $.ajax({
  1967. url: urlConfig("search-pin-word-key/"+id),
  1968. data: {
  1969. 'keyword' : keyword
  1970. },
  1971. type: "POST"
  1972. }).success(function(data) {
  1973. if(data[0] == 1){
  1974. $('.search-pin-item').next().remove();
  1975. $(data[1]).insertAfter('.search-pin-item');
  1976. localStorage['pin_key_'+keyword] = data[1];
  1977. }
  1978. });
  1979. }else{
  1980. $('.search-pin-item').next().remove();
  1981. $('.remove-search').removeClass('remove-search-active');
  1982. }
  1983. }, 500));
  1984. });
  1985. $(document).on('click','.remove-search-active',function(){
  1986. $('.txt-search-pin-word').val('');
  1987. $('.txt-search-pin-word').focus();
  1988. $('.search-pin-item').next().remove();
  1989. $(this).fadeOut();
  1990. });
  1991. $(document).on('click','.btn-pin-word-icon',function(){
  1992. var name = $("#search-pin-word-modal").attr('vocabulary');
  1993. var vocabulary = $(this).attr('vocabulary');
  1994. var word = $(this).attr('word');
  1995. var definition = $(this).attr('def');
  1996. $.ajax({
  1997. url: urlConfig("pin-vocabulary-word-search"),
  1998. data: {
  1999. 'vocabulary' : vocabulary,
  2000. 'word' : word,
  2001. 'definition' : definition,
  2002. 'name' : name
  2003. },
  2004. type: "POST"
  2005. }).success(function(data) {
  2006. $('#search-pin-word-modal').modal('hide');
  2007. if(data[0] == 1){
  2008. if($('.title-vocabulary-all').siblings().hasClass('box-empty-word')){
  2009. $('.box-empty-word').remove();
  2010. $('<div class="box-list-vocabulary"><div class="row">'+data[2]+'</div></div>').insertAfter('.title-vocabulary-all');
  2011. $('.add-pin-word').fadeIn();
  2012. }else{
  2013. $('.box-list-vocabulary').children('.row').prepend(data[2]);
  2014. }
  2015. var quantity = $('.title-vocabulary-all .style-badge-number-word').html();
  2016. quantity = parseInt(quantity);
  2017. if(!isNaN(quantity)){
  2018. $('.title-vocabulary-all .style-badge-number-word').html(quantity + 1);
  2019. var limit = $('.add-pin-word').attr('limit');
  2020. limit = parseInt(limit);
  2021. if(limit <= (quantity + 1)){
  2022. $('.add-pin-word').fadeOut();
  2023. setTimeout(function(){
  2024. location.reload();
  2025. },3000);
  2026. }
  2027. }
  2028. }
  2029. setTimeout(function(){
  2030. if(data[0] == 0){
  2031. $('#search-pin-word-modal').html(data[1]);
  2032. $('#search-pin-word-modal').modal('show');
  2033. }
  2034. setTimeout(function(){
  2035. $('#search-pin-word-modal').modal('hide');
  2036. setTimeout(function(){
  2037. $('.add-pin-word').trigger('click');
  2038. },500);
  2039. },1000);
  2040. },1000);
  2041. });
  2042. });
  2043. $('.msg-pin-word-btn').click(function(){
  2044. $('#learning-msg-modal').modal('hide');
  2045. setTimeout(function(){
  2046. $('.add-pin-word').trigger('click');
  2047. },500);
  2048. });
  2049. /**end pin word search**/
  2050. /**Begin rating voca community**/
  2051. var isRated = 0;
  2052. $('.star-rating').mouseover(function(){
  2053. if(isRated == 1){
  2054. return false;
  2055. }
  2056. $('.star-rating').removeClass('fa-star');
  2057. $('.star-rating').addClass('fa-star-o');
  2058. $(this).addClass('fa-star');
  2059. $(this).removeClass('fa-star-o');
  2060. $(this).prevAll('.fa').addClass('fa-star');
  2061. $(this).prevAll('.fa').removeClass('fa-star-o');
  2062. });
  2063. $('.star-rating').mouseout(function(){
  2064. $('.star-rating').removeClass('fa-star');
  2065. $('.star-rating').addClass('fa-star-o');
  2066. });
  2067. $(document).on('click','.star-rating.fa-star',function(){
  2068. var c = confirm(ratingMsg);
  2069. if(c == false){
  2070. return false;
  2071. }
  2072. // $('.star-rating').removeClass('star-rating');
  2073. var rate = $(this).index();
  2074. var vocabulary = $(this).parent().attr('vocabulary');
  2075. isRated = 1;
  2076. $('.library-community-rating').nextAll().remove();
  2077. $('<i class="fa fa-star star-rated"></i> <span>'+rate+'</span>').insertAfter($('.library-community-rating'));
  2078. $.ajax({
  2079. url: urlConfig("rating-voca-community/"+vocabulary),
  2080. data: {
  2081. 'rate' : rate
  2082. },
  2083. type: "POST"
  2084. });
  2085. });
  2086. $('.s-rate').mouseover(function(){
  2087. var i = $('.s-rate').index(this);
  2088. $('.s-rate').each(function(index){
  2089. if(index <= i){
  2090. $(this).addClass('s-rating');
  2091. }
  2092. });
  2093. });
  2094. $('.s-rate').mouseout(function(){
  2095. $('.s-rate').removeClass('s-rating');
  2096. });
  2097. $(document).on('click','.s-rate.s-rating',function(){
  2098. $('#rating-msg-modal').modal('hide');
  2099. var rate = parseInt($(this).index()) + 1;
  2100. var vocabulary = $('.btn-library-community-rating').attr('vocabulary');
  2101. $('.rating-vocabulary, .txt-library-community-rating').addClass('rated-vocabulary');
  2102. $.ajax({
  2103. url: urlConfig("rating-voca-community/"+vocabulary),
  2104. data: {
  2105. 'rate' : rate
  2106. },
  2107. type: "POST"
  2108. }).success(function(){
  2109. $('#rated-msg-modal').modal();
  2110. setTimeout(function(){
  2111. $('#rated-msg-modal').modal('hide');
  2112. },1000)
  2113. });
  2114. });
  2115. $('.rating-vocabulary, .txt-library-community-rating').click(function(){
  2116. if(!$(this).hasClass('rated-vocabulary')){
  2117. $('#rating-msg-modal').modal();
  2118. }else{
  2119. $('#rated-msg-modal').modal();
  2120. }
  2121. });
  2122. /**End rating voca community**/
  2123. /**Begin learning community**/
  2124. //choose learning method
  2125. $('.learning-community').click(function(){
  2126. $('.choose-learn-community-words form').attr('action',$(this).attr('url'));
  2127. });
  2128. $('.learning-writing-community').click(function(){
  2129. $('.choose-learn-community-words form').attr('action',$(this).attr('url'));
  2130. });
  2131. $('.learning-speaking-community').click(function(){
  2132. $('.choose-learn-community-words form').attr('action',$(this).attr('url'));
  2133. });
  2134. $('.choose-learning-community-words').click(function(){
  2135. console.log(12345);
  2136. var topic = $(this).attr('topic');
  2137. $.ajax({
  2138. url: urlConfig("choose-learning-commuinity-words/"+topic),
  2139. type:"POST"
  2140. }).success(function(data) {
  2141. console.log(data);
  2142. if(data !=0) {
  2143. $('.choose-learn-community-words .modal-dialog-choose-word').html(data);
  2144. $('.choose-learn-community-words').modal();
  2145. }
  2146. });
  2147. });
  2148. /**End learning community**/
  2149. jQuery.fn.exists = function(){return this.length>0;}
  2150. if ($('#sub-menu').exists() && $('#sub-menu').is(":visible")) {
  2151. $('#voca-wrap').css('padding','100px 0 100px');
  2152. }
  2153. $('.sub-menu-library').mouseover(function(){
  2154. $(this).addClass('open');
  2155. });
  2156. $('.sub-menu-library').mouseout(function(){
  2157. $(this).removeClass('open');
  2158. });
  2159. $('.sub-menu-blog').mouseover(function(){
  2160. $(this).addClass('open');
  2161. });
  2162. $('.sub-menu-blog').mouseout(function(){
  2163. $(this).removeClass('open');
  2164. });
  2165. $('.sub-menu-phone').mouseover(function(){
  2166. $(this).addClass('open');
  2167. });
  2168. $('.sub-menu-phone').mouseout(function(){
  2169. $(this).removeClass('open');
  2170. });
  2171. setTimeout(function(){$('.sub-menu-personal, .sub-menu-library, .sub-menu-library-community, .sub-menu-community,.sub-menu-blog ').has('.menu-active').addClass('sub-menu-item-border');},1000);
  2172. });
  2173. //show music modal
  2174. function showMusicModal(url){
  2175. $('#music-modal .learning-music-modal .learning-music-modal-src').attr('src',url);
  2176. $('#music-modal').modal('show');
  2177. }
  2178. //show video modal
  2179. function showVideoModal(url){
  2180. $('#video-modal .learning-video-modal .learning-video-modal-src').attr('src',url+'?rel=0');
  2181. $('#video-modal').modal('show');
  2182. }
  2183. //show story modal
  2184. function showStoryModal(url){
  2185. $('#story-modal').modal('show');
  2186. if(url == 0){
  2187. $('#story-modal .learning-music-modal-src').css("display","none");
  2188. }else{
  2189. $('#story-modal .learning-music-modal-src').attr('src',url+'?rel=0');
  2190. }
  2191. }
  2192. /*
  2193. $(function(){
  2194. $('.avatar-picture').tooltip({placement: 'bottom', html: true,trigger:'click'});
  2195. $('.sidebar-nav').slimScroll({
  2196. height: '100%',
  2197. color:"#555"
  2198. });
  2199. });
  2200. $(function(){
  2201. $('.bell-notification-content-items').slimScroll({
  2202. height: '500px',
  2203. color:"#efefef"
  2204. });
  2205. });
  2206. */
  2207. $(window).scroll(function(){
  2208. if($(document).scrollTop()>=600){
  2209. $('.intro-text-menu img').removeClass('hidden');
  2210. }else{
  2211. if(!$('.intro-text-menu img').hasClass('hidden')){
  2212. $('.intro-text-menu img').addClass('hidden');
  2213. }
  2214. }
  2215. });
  2216. function removeInform(){
  2217. $('.inform-bar').fadeOut('slow');
  2218. }
  2219. $(document).ready(function(){
  2220. $('.title-tooltip').tooltip({'html':true});
  2221. $('.title-tooltip').mouseover(function(){
  2222. $(this).parent().parent().next().css('text-decoration','underline');
  2223. });
  2224. $('.title-tooltip').mouseout(function(){
  2225. $(this).parent().parent().next().css('text-decoration','none');
  2226. });
  2227. var heightScreen = jQuery(window).height()-50;
  2228. //$('.main-wrapper').css('min-height',heightScreen+'px');
  2229. $(document).on('change','.choose-language',function(){
  2230. var lang = $(this).val();
  2231. $('form#choose-laguage-form').attr('action',urlConfig('set-language/'+ lang));
  2232. $('form#choose-laguage-form').submit();
  2233. });
  2234. $(document).on('mouseup','.btn-edit-avatar',function(){
  2235. $.ajax({
  2236. url: urlConfig('change-avatar'),
  2237. data: {
  2238. },
  2239. type: 'POST'
  2240. }).success(function(data) {
  2241. $('#change-avatar-modal').html(data);
  2242. $('#change-avatar-modal').modal();
  2243. });
  2244. });
  2245. $('.close-notification').click(function(){
  2246. $('.notification').css('display','none');
  2247. $('.close-notification').css('display','none');
  2248. document.cookie="closeNotification=closenotification;path=/";
  2249. });
  2250. var show = 0;
  2251. $('.hide-show-message').click(function(){
  2252. if(show == 0){
  2253. $('.message-content').css('bottom', '0px');
  2254. show = 1;
  2255. }else{
  2256. show = 0;
  2257. $('.message-content').css('bottom', '-520px');
  2258. }
  2259. });
  2260. $('.hide-message').click(function(){
  2261. show = 0;
  2262. $('.message-content').css('bottom', '-520px');
  2263. document.cookie="hideEvent=hideEvent;path=/";
  2264. });
  2265. if (document.cookie.indexOf("hideEvent") < 0) {
  2266. setTimeout(function(){
  2267. $('.message-content').css('bottom', '0px');
  2268. document.cookie="hideEvent=hideEvent;path=/";
  2269. show = 1;
  2270. }, 10000);
  2271. }
  2272. $('.voca-vip').mouseover(function(){
  2273. $(this).css('text-decoration','underline');
  2274. });
  2275. $('.voca-vip').mouseout(function(){
  2276. $(this).css('text-decoration','none');
  2277. });
  2278. $(document).on('mouseover','.avatar-picture-item',function(){
  2279. $('.btn-edit-avatar.avatar-picture.avatar-picture-item + .change-avatar').css('visibility','visible');
  2280. });
  2281. $(document).on('mouseout','.avatar-picture-item',function(){
  2282. $('.btn-edit-avatar.avatar-picture.avatar-picture-item + .change-avatar').css('visibility','hidden');
  2283. });
  2284. $(document).on('mouseover','.btn-edit-avatar.avatar-picture.avatar-picture-item + .change-avatar',function(){
  2285. $(this).css('visibility','visible');
  2286. });
  2287. $(document).on('mouseout','.btn-edit-avatar.avatar-picture.avatar-picture-item + .change-avatar',function(){
  2288. $(this).css('visibility','hidden');
  2289. });
  2290. var l = 0;
  2291. $(".learn-mobile").click(function(){
  2292. if(l == 0){
  2293. l = 1;
  2294. $('.nav-mobile').slideDown();
  2295. $('.learn-mobile-icon').removeClass('fa-chevron-down');
  2296. $('.learn-mobile-icon').addClass('fa-chevron-up');
  2297. }else{
  2298. l = 0;
  2299. $('.nav-mobile').slideUp();
  2300. $('.learn-mobile-icon').removeClass('fa-chevron-up');
  2301. $('.learn-mobile-icon').addClass('fa-chevron-down');
  2302. }
  2303. });
  2304. //setting sound type
  2305. $('.li-set-sound-type').click(function(){
  2306. $('.ul-sound-type').slideToggle();
  2307. });
  2308. });
  2309. (function(){
  2310. var _z = console;
  2311. Object.defineProperty( window, "console", {
  2312. get : function(){
  2313. if( _z._commandLineAPI ){
  2314. throw "Sorry, VOCA Can't excute YOUR scripts!!!";
  2315. }
  2316. return _z;
  2317. },
  2318. set : function(val){
  2319. _z = val;
  2320. }
  2321. });
  2322. })();