PageRenderTime 39ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/NukeViet3.2/modules/shops/js/user.js

http://nuke-viet.googlecode.com/
JavaScript | 208 lines | 178 code | 12 blank | 18 comment | 56 complexity | b7f9eceef6333461d92c4851b1095ea8 MD5 | raw file
Possible License(s): BSD-3-Clause, LGPL-2.1, GPL-2.0
  1. /**
  2. * @Project NUKEVIET 3.0
  3. * @Author VINADES.,JSC (contact@vinades.vn)
  4. * @Copyright (C) 2010 VINADES.,JSC. All rights reserved
  5. * @Createdate 1 - 31 - 2010 5 : 12
  6. */
  7. function sendrating(id, point, newscheckss) {
  8. if(point==1 || point==2 || point==3 || point==4 || point==5){
  9. nv_ajax('post', nv_siteroot + 'index.php', nv_lang_variable + '=' + nv_sitelang + '&' + nv_name_variable + '=' + nv_module_name + '&' + nv_fc_variable + '=rating&id=' + id + '&checkss=' + newscheckss + '&point=' + point, 'stringrating', '');
  10. }
  11. }
  12. function sendcommment(id, newscheckss, gfx_count) {
  13. var commentname = document.getElementById('commentname');
  14. var commentemail = document.getElementById('commentemail_iavim');
  15. var commentseccode = document.getElementById('commentseccode_iavim');
  16. var commentcontent = strip_tags(document.getElementById('commentcontent').value);
  17. if (commentname.value == "") {
  18. alert(nv_fullname);
  19. commentname.focus();
  20. } else if (!nv_email_check(commentemail)) {
  21. alert(nv_error_email);
  22. commentemail.focus();
  23. } else if (!nv_name_check(commentseccode)) {
  24. error = nv_error_seccode.replace( /\[num\]/g, gfx_count );
  25. alert(error);
  26. commentseccode.focus();
  27. } else if (commentcontent == "") {
  28. alert(nv_content);
  29. document.getElementById('commentcontent').focus();
  30. } else {
  31. var sd = document.getElementById('buttoncontent');
  32. sd.disabled = true;
  33. nv_ajax('post', nv_siteroot + 'index.php', nv_lang_variable + '=' + nv_sitelang + '&' + nv_name_variable + '=' + nv_module_name + '&' + nv_fc_variable + '=postcomment&id=' + id + '&checkss=' + newscheckss + '&name=' + commentname.value + '&email=' + commentemail.value + '&code=' + commentseccode.value + '&content=' + encodeURIComponent(commentcontent), '', 'nv_commment_result');
  34. }
  35. return;
  36. }
  37. function nv_commment_result(res) {
  38. nv_change_captcha('vimg', 'commentseccode_iavim');
  39. var r_split = res.split("_");
  40. if (r_split[0] == 'OK') {
  41. document.getElementById('commentcontent').value = "";
  42. nv_show_hidden('showcomment', 1);
  43. nv_show_comment(r_split[1], r_split[2], r_split[3]);
  44. alert(r_split[4]);
  45. } else if (r_split[0] == 'ERR') {
  46. alert(r_split[1]);
  47. } else {
  48. alert(nv_content_failed);
  49. }
  50. nv_set_disable_false('buttoncontent');
  51. return false;
  52. }
  53. function nv_show_comment(id, checkss, page) {
  54. nv_ajax('get', nv_siteroot + 'index.php', nv_lang_variable + '=' + nv_sitelang + '&' + nv_name_variable + '=' + nv_module_name + '&' + nv_fc_variable + '=comment&id=' + id + '&checkss=' + checkss + '&page=' + page, 'showcomment', '');
  55. }
  56. function remove_text() {
  57. document.getElementById('to_date').value = "";
  58. document.getElementById('from_date').value = "";
  59. }
  60. function nv_del_content(id, checkss, base_adminurl) {
  61. if (confirm(nv_is_del_confirm[0])) {
  62. nv_ajax('post', base_adminurl + 'index.php', nv_name_variable + '=' + nv_module_name + '&' + nv_fc_variable + '=del_content&id=' + id + '&checkss=' + checkss, '', 'nv_del_content_result');
  63. }
  64. return false;
  65. }
  66. function nv_del_content_result(res) {
  67. var r_split = res.split("_");
  68. if (r_split[0] == 'OK') {
  69. window.location.href = strHref;
  70. } else if (r_split[0] == 'ERR') {
  71. alert(r_split[1]);
  72. } else {
  73. alert(nv_is_del_confirm[2]);
  74. }
  75. return false;
  76. }
  77. function share_twitter(){u=location.href;t=document.title;window.open("http://twitter.com/home?status="+encodeURIComponent(u))}
  78. function share_facebook(){u=location.href;t=document.title;window.open("http://www.facebook.com/share.php?u="+encodeURIComponent(u)+"&t="+encodeURIComponent(t))}function share_google(){u=location.href;t=document.title;window.open("http://www.google.com/bookmarks/mark?op=edit&bkmk="+encodeURIComponent(u)+"&title="+t+"&annotation="+t)}
  79. function share_buzz(){u=location.href;t=document.title;window.open("http://buzz.yahoo.com/buzz?publisherurn=DanTri&targetUrl="+encodeURIComponent(u))}
  80. //JavaScript Document
  81. //Copyright (C) 2005 Ilya S. Lyubinskiy. All rights reserved.
  82. //Technical support: http://www.php-development.ru/
  83. //----- Auxiliary -------------------------------------------------------------
  84. function tabview_aux(TabViewId, id)
  85. {
  86. var TabView = document.getElementById(TabViewId);
  87. // ----- Tabs -----
  88. var Tabs = TabView.firstChild;
  89. while (Tabs.className != "Tabs" ) Tabs = Tabs.nextSibling;
  90. var Tab = Tabs.firstChild;
  91. var i = 0;
  92. do
  93. {
  94. if (Tab.tagName == "A")
  95. {
  96. i++;
  97. Tab.href = "javascript:tabview_switch('"+TabViewId+"', "+i+");";
  98. Tab.className = (i == id) ? "Active" : "";
  99. Tab.blur();
  100. }
  101. }
  102. while (Tab = Tab.nextSibling);
  103. // ----- Pages -----
  104. var Pages = TabView.firstChild;
  105. while (Pages.className != 'Pages') Pages = Pages.nextSibling;
  106. var Page = Pages.firstChild;
  107. var i = 0;
  108. do
  109. {
  110. if (Page.className == 'Page')
  111. {
  112. i++;
  113. //if (Pages.offsetHeight) Page.style.height = (Pages.offsetHeight-2)+"px";
  114. //Page.style.overflow = "auto";
  115. Page.style.display = (i == id) ? 'block' : 'none';
  116. }
  117. }
  118. while (Page = Page.nextSibling);
  119. }
  120. //----- Functions ------
  121. function SetCookieForTabView(cookieName,cookieValue,nDays) {
  122. var today = new Date();
  123. var expire = new Date();
  124. if (nDays==null || nDays==0) nDays=1;
  125. expire.setTime(today.getTime() + 3600000*24*nDays);
  126. document.cookie = cookieName+"="+escape(cookieValue)+ ";expires="+expire.toGMTString();
  127. }
  128. function ReadCookie(cookieName) {
  129. var theCookie=""+document.cookie;
  130. var ind=theCookie.indexOf(cookieName);
  131. if (ind==-1 || cookieName=="") return "";
  132. var ind1=theCookie.indexOf(';',ind);
  133. if (ind1==-1) ind1=theCookie.length;
  134. return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
  135. }
  136. function tabview_switch(TabViewId, id) { tabview_aux(TabViewId, id); SetCookieForTabView('tvID',id,36) }
  137. function tabview_initialize(TabViewId)
  138. {
  139. tvID2 = ReadCookie('tvID')
  140. if (tvID2==-1 || tvID2=="") { SetCookieForTabView('tvID',1,36); tabview_aux(TabViewId, 1); }
  141. else {tabview_aux(TabViewId, tvID2); }
  142. }
  143. /*javascript user*/
  144. function cartorder(a_ob){
  145. var id = $(a_ob).attr("id");
  146. $.ajax({
  147. type: "GET",
  148. url: nv_siteroot + 'index.php?' + nv_lang_variable + '=' + nv_sitelang + '&' + nv_name_variable + '=' + nv_module_name + '&' + nv_fc_variable + '=setcart' + '&id=' + id + "&nocache=" + new Date().getTime(),
  149. data:'',
  150. success: function(data){
  151. var s = data.split('_');
  152. var strText = s[1];
  153. if ( strText != null )
  154. {
  155. var intIndexOfMatch = strText.indexOf('#@#');
  156. while (intIndexOfMatch != -1) {
  157. strText = strText.replace('#@#', '_');
  158. intIndexOfMatch = strText.indexOf('#@#');
  159. }
  160. //alert(strText);
  161. alert_msg(strText);
  162. linkloadcart = nv_siteroot + 'index.php?' + nv_lang_variable + '=' + nv_sitelang + '&' + nv_name_variable + '=' + nv_module_name + '&' + nv_fc_variable + '=loadcart';
  163. $("#cart_"+ nv_module_name).load(linkloadcart);
  164. }
  165. }
  166. });
  167. }
  168. /**/
  169. function cartorder_detail(a_ob){
  170. var num = $('#pnum').val();
  171. var id = $(a_ob).attr("id");
  172. $.ajax({
  173. type: "POST",
  174. url: nv_siteroot + 'index.php?' + nv_lang_variable + '=' + nv_sitelang + '&' + nv_name_variable + '=' + nv_module_name + '&' + nv_fc_variable + '=setcart' + '&id=' + id + "&nocache=" + new Date().getTime(),
  175. data: 'num=' + num,
  176. success: function(data){
  177. var s = data.split('_');
  178. var strText = s[1];
  179. if ( strText != null )
  180. {
  181. var intIndexOfMatch = strText.indexOf('#@#');
  182. while (intIndexOfMatch != -1) {
  183. strText = strText.replace('#@#', '_');
  184. intIndexOfMatch = strText.indexOf('#@#');
  185. }
  186. alert_msg(strText);
  187. linkloadcart = nv_siteroot + 'index.php?' + nv_lang_variable + '=' + nv_sitelang + '&' + nv_name_variable + '=' + nv_module_name + '&' + nv_fc_variable + '=loadcart';
  188. $("#cart_"+ nv_module_name).load(linkloadcart);
  189. }
  190. }
  191. });
  192. }
  193. function alert_msg(msg) {
  194. $('#msgshow').html(msg);
  195. $('#msgshow').show('slide').delay(3000).hide('slow');
  196. }