Hormold

VK Change (#1394221503)

Mar 7th, 2014
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 34.54 KB | None | 0 0
  1. Файл - ads_moder.js (Старый размер - 28343 | Новый - 0):
  2. 0.  - var AdsModer = {};
  3. 1.  -
  4. 2.  - AdsModer.init = function() {
  5. 3.  -   AdsModer.initDelayedImages();
  6. 4.  - }
  7. 5.  -
  8. 6.  - AdsModer.initDelayedImages = function() {
  9. 7.  -   var imagesIndex;
  10. 8.  -   var indexStep = 500;
  11. 9.  -   var lastImage;
  12. 10.  -   var lastImageY;
  13. 11.  -
  14. 12.  -   buildIndex();
  15. 13.  -   if (isEmpty(imagesIndex)) {
  16. 14.  -     return;
  17. 15.  -   }
  18. 16.  -
  19. 17.  -   var scrolledNode = (browser.msie6 ? pageNode : window);
  20. 18.  -   var handler = checkImages.pbind(false);
  21. 19.  -   function deinit() {
  22. 20.  -     removeEvent(scrolledNode, 'scroll', handler);
  23. 21.  -   }
  24. 22.  -   cur.destroy.push(deinit);
  25. 23.  -   addEvent(scrolledNode, 'scroll', handler);
  26. 24.  -   handler();
  27. 25.  -
  28. 26.  -   function buildIndex() {
  29. 27.  -     if (lastImage && lastImage.hasAttribute('src_') && lastImageY == getXY(lastImage)[1]) {
  30. 28.  -       return;
  31. 29.  -     }
  32. 30.  -
  33. 31.  -     var imagesAll = geByTag('img');
  34. 32.  -     var image;
  35. 33.  -     var indexKey;
  36. 34.  -
  37. 35.  -     imagesIndex = {};
  38. 36.  -
  39. 37.  -     if (!imagesAll.length) {
  40. 38.  -       return;
  41. 39.  -     }
  42. 40.  -
  43. 41.  -     for (var i = 0, image; image = imagesAll[i]; i++) {
  44. 42.  -       if (!image.hasAttribute('src_')) {
  45. 43.  -         continue;
  46. 44.  -       }
  47. 45.  -       indexKey = intval(getXY(image)[1] / indexStep);
  48. 46.  -       if (!(indexKey in imagesIndex)) {
  49. 47.  -         imagesIndex[indexKey] = [];
  50. 48.  -       }
  51. 49.  -       imagesIndex[indexKey].push(image);
  52. 50.  -       lastImage = image;
  53. 51.  -     }
  54. 52.  -
  55. 53.  -     lastImageY = getXY(lastImage)[1];
  56. 54.  -   }
  57. 55.  -
  58. 56.  -   function checkIndex() {
  59. 57.  -     buildIndex();
  60. 58.  -     if (isEmpty(imagesIndex)) {
  61. 59.  -       deinit();
  62. 60.  -     }
  63. 61.  -   }
  64. 62.  -
  65. 63.  -   function checkImages(delayed) {
  66. 64.  -     var yTop        = scrollGetY()
  67. 65.  -     var yBottom     = yTop + lastWindowHeight;
  68. 66.  -     var indexTop    = intval(yTop / indexStep);
  69. 67.  -     var indexBottom = intval(yBottom / indexStep);
  70. 68.  -     var image;
  71. 69.  -     for (var i = indexTop; i <= indexBottom; i++) {
  72. 70.  -       if (!(i in imagesIndex)) {
  73. 71.  -         continue;
  74. 72.  -       }
  75. 73.  -       for (var j = 0, len = imagesIndex[i].length; j < len; j++) {
  76. 74.  -         image = imagesIndex[i][j];
  77. 75.  -         image.src = image.getAttribute('src_');
  78. 76.  -         image.removeAttribute('src_')
  79. 77.  -       }
  80. 78.  -       delete imagesIndex[i];
  81. 79.  -     }
  82. 80.  -     checkIndex();
  83. 81.  -     setTimeout(checkIndex, 1000);
  84. 82.  -   }
  85. 83.  - }
  86. 84.  -
  87. 85.  - AdsModer.showObjectInfo = function(objectType, objectId) {
  88. 86.  -   var ajaxParams = {};
  89. 87.  -   ajaxParams.object_type = objectType;
  90. 88.  -   ajaxParams.object_id   = objectId;
  91. 89.  -
  92. 90.  -   var showOptions = {params: {}};
  93. 91.  -
  94. 92.  -   showBox('/adsmoder?act=object_info', ajaxParams, showOptions);
  95. 93.  - }
  96. 94.  -
  97. 95.  - AdsModer.openFeaturesEditBox = function(unionId, hash, featuresInfo, featuresEditHtml) {
  98. 96.  -   var editBox = showFastBox({title: '�����������', width: 550}, featuresEditHtml);
  99. 97.  -   var saveFeaturesHandler = AdsModer.saveFeatures.pbind(unionId, hash, featuresInfo, editBox);
  100. 98.  -   editBox.removeButtons();
  101. 99.  -   editBox.addButton(getLang('box_cancel'), false, 'no');
  102. 100.  -   editBox.addButton('��������', saveFeaturesHandler, 'yes');
  103. 101.  -
  104. 102.  -   var checkboxes = {};
  105. 103.  -   for (var i in featuresInfo) {
  106. 104.  -     var featureInfo = featuresInfo[i];
  107. 105.  -     checkboxes[featureInfo.key] = new Checkbox(ge('ads_moder_feature_' + featureInfo.key), {
  108. 106.  -       label: featureInfo.name,
  109. 107.  -       checked: intval(featureInfo.value),
  110. 108.  -       width: 500,
  111. 109.  -       onChange: (function(featureInfo, value) {
  112. 110.  -         if (!value || !featureInfo.unset_keys) {
  113. 111.  -           return;
  114. 112.  -         }
  115. 113.  -         for (var j in featureInfo.unset_keys) {
  116. 114.  -           var unsetKey = featureInfo.unset_keys[j];
  117. 115.  -           if (!checkboxes[unsetKey]) {
  118. 116.  -             continue;
  119. 117.  -           }
  120. 118.  -           checkboxes[unsetKey].checked(0);
  121. 119.  -         }
  122. 120.  -       }).pbind(featureInfo)
  123. 121.  -     });
  124. 122.  -   }
  125. 123.  - }
  126. 124.  -
  127. 125.  - AdsModer.saveFeatures = function(unionId, hash, featuresInfo, editBox) {
  128. 126.  -   if (!Ads.lock('saveFeatures', onLock, onUnlock)) {
  129. 127.  -     return;
  130. 128.  -   }
  131. 129.  -
  132. 130.  -   var ajaxParams = {};
  133. 131.  -   ajaxParams.union_id = unionId;
  134. 132.  -   ajaxParams.hash = hash;
  135. 133.  -   ajaxParams.features = [];
  136. 134.  -   for (var i in featuresInfo) {
  137. 135.  -     var featureInfo = featuresInfo[i];
  138. 136.  -     ajaxParams.features.push(featureInfo.key + ':' + intval(ge('ads_moder_feature_' + featureInfo.key).value));
  139. 137.  -   }
  140. 138.  -   ajaxParams.features = ajaxParams.features.join(',');
  141. 139.  -
  142. 140.  -   ajax.post('/adsmoder?act=a_edit_features', ajaxParams, {onDone: onComplete, onFail: onComplete});
  143. 141.  -
  144. 142.  -   function onComplete(response) {
  145. 143.  -     Ads.unlock('saveFeatures');
  146. 144.  -     if (response && response.ok) {
  147. 145.  -       nav.reload();
  148. 146.  -     } else {
  149. 147.  -       showFastBox('������', '������');
  150. 148.  -     }
  151. 149.  -     return true;
  152. 150.  -   }
  153. 151.  -   function onLock() {
  154. 152.  -     editBox.showProgress();
  155. 153.  -   }
  156. 154.  -   function onUnlock() {
  157. 155.  -     editBox.hide();
  158. 156.  -   }
  159. 157.  - }
  160. 158.  -
  161. 159.  - AdsModer.openNoteEditBox = function(ajaxParams, noteText, noteTextParams, boxTitle, editActionText, isEdit, isOtherUser) {
  162. 160.  -   function onBoxHide() {
  163. 161.  -     delete cur.noteEditBox;
  164. 162.  -     delete cur.noteEditAjaxParams;
  165. 163.  -   }
  166. 164.  -
  167. 165.  -   cur.noteEditAjaxParams = ajaxParams;
  168. 166.  -
  169. 167.  -   var boxHtml = '<div class="ads_note_edit_wrap"><div><textarea id="ads_note_edit" ' + noteTextParams + '>' + noteText + '</textarea></div></div>';
  170. 168.  -
  171. 169.  -   cur.noteEditBox = showFastBox({title: boxTitle, width: 400, onHide: onBoxHide}, boxHtml);
  172. 170.  -   cur.noteEditBox.removeButtons();
  173. 171.  -   if (isOtherUser) {
  174. 172.  -     cur.noteEditBox.addButton(getLang('box_cancel'), false, 'yes');
  175. 173.  -   } else {
  176. 174.  -     cur.noteEditBox.addButton(getLang('box_cancel'), false, 'no');
  177. 175.  -     cur.noteEditBox.addButton(editActionText, AdsModer.saveNote.pbind(false), 'yes');
  178. 176.  -   }
  179. 177.  -   if (isEdit) {
  180. 178.  -     cur.noteEditBox.setControlsText('<a href="#" onclick="AdsModer.saveNote(true); return false;">�������</a>');
  181. 179.  -   }
  182. 180.  - }
  183. 181.  -
  184. 182.  - AdsModer.saveNote = function(isDelete) {
  185. 183.  -   if (!Ads.lock('save_note', onLock, onUnlock)) {
  186. 184.  -     return;
  187. 185.  -   }
  188. 186.  -
  189. 187.  -   var ajaxParams = {};
  190. 188.  -   ajaxParams = extend({}, ajaxParams, cur.noteEditAjaxParams);
  191. 189.  -   ajaxParams.note_text = (isDelete ? '' : ge('ads_note_edit').value);
  192. 190.  -   ajax.post('/adsmoder?act=a_edit_notes', ajaxParams, {onDone: onComplete, onFail: onComplete});
  193. 191.  -
  194. 192.  -   function onComplete(response) {
  195. 193.  -     Ads.unlock('save_note');
  196. 194.  -     if (response && response.ok) {
  197. 195.  -       nav.reload();
  198. 196.  -     } else {
  199. 197.  -       showFastBox({title: '������', onHide: function() { nav.reload(); }}, '������');
  200. 198.  -     }
  201. 199.  -     return true;
  202. 200.  -   }
  203. 201.  -   function onLock() {
  204. 202.  -     cur.noteEditBox.showProgress();
  205. 203.  -   }
  206. 204.  -   function onUnlock() {
  207. 205.  -     cur.noteEditBox.hide();
  208. 206.  -   }
  209. 207.  - }
  210. 208.  -
  211. 209.  - AdsModer.openCategoriesEditBox = function(requestKey, linkElem) {
  212. 210.  -   var editBox = showFastBox({title: '��������� �������� ����������', width: 440}, cur.categoriesEditBoxHtml);
  213. 211.  -   editBox.removeButtons();
  214. 212.  -   editBox.addButton(getLang('box_cancel'), false, 'no');
  215. 213.  -   editBox.addButton('��������', applyChanges, 'yes');
  216. 214.  -
  217. 215.  -   var requestParams = cur.requestsParams[requestKey];
  218. 216.  -
  219. 217.  -   var category1_id    = requestParams.ui_category1_id;
  220. 218.  -   var category2_id    = requestParams.ui_category2_id;
  221. 219.  -   var subcategory1_id = requestParams.ui_subcategory1_id;
  222. 220.  -   var subcategory2_id = requestParams.ui_subcategory2_id;
  223. 221.  -
  224. 222.  -   var uiCategory1 = new Dropdown(ge('ads_moder_category1'), cur.categoriesData, {
  225. 223.  -     selectedItems: category1_id,
  226. 224.  -     width:         250,
  227. 225.  -     height:        400,
  228. 226.  -     onChange:      onChangeCategory1
  229. 227.  -   });
  230. 228.  -   var uiCategory2 = new Dropdown(ge('ads_moder_category2'), cur.categoriesData, {
  231. 229.  -     selectedItems: category2_id,
  232. 230.  -     width:         250,
  233. 231.  -     height:        400,
  234. 232.  -     onChange:      onChangeCategory2
  235. 233.  -   });
  236. 234.  -   var uiSubcategory1 = new Dropdown(ge('ads_moder_subcategory1'), [], {
  237. 235.  -     width:    250,
  238. 236.  -     height:   400,
  239. 237.  -     onChange: function(value) {
  240. 238.  -       subcategory1_id = intval(value);
  241. 239.  -     }
  242. 240.  -   });
  243. 241.  -   var uiSubcategory2 = new Dropdown(ge('ads_moder_subcategory2'), [], {
  244. 242.  -     width:    250,
  245. 243.  -     height:   400,
  246. 244.  -     onChange: function(value) {
  247. 245.  -       subcategory2_id = intval(value);
  248. 246.  -     }
  249. 247.  -   });
  250. 248.  -
  251. 249.  -   onChangeCategory1(category1_id);
  252. 250.  -   onChangeCategory2(category2_id);
  253. 251.  -
  254. 252.  -   var boxOptions = {};
  255. 253.  -   boxOptions.onClean = function() {
  256. 254.  -     uiCategory1.destroy();
  257. 255.  -     uiCategory2.destroy();
  258. 256.  -     uiSubcategory1.destroy();
  259. 257.  -     uiSubcategory2.destroy();
  260. 258.  -   };
  261. 259.  -   editBox.setOptions(boxOptions);
  262. 260.  -
  263. 261.  -   function onChangeCategory1(value) {
  264. 262.  -     value = intval(value);
  265. 263.  -     if (value != category1_id) {
  266. 264.  -       subcategory1_id = 0;
  267. 265.  -     }
  268. 266.  -     category1_id = value;
  269. 267.  -     var data = cur.subcategoriesData[value] || [];
  270. 268.  -     var disabledText = (value ? getLang('ads_no_subcategories') : getLang('ads_first_select_category1'));
  271. 269.  -     uiSubcategory1.setOptions({disabledText: disabledText});
  272. 270.  -     uiSubcategory1.setData(data);
  273. 271.  -     if (subcategory1_id) {
  274. 272.  -       uiSubcategory1.val(subcategory1_id);
  275. 273.  -     } else {
  276. 274.  -       uiSubcategory1.clear();
  277. 275.  -     }
  278. 276.  -     uiSubcategory1.disable(data.length == 0);
  279. 277.  -   }
  280. 278.  -   function onChangeCategory2(value) {
  281. 279.  -     value = intval(value);
  282. 280.  -     if (value != category2_id) {
  283. 281.  -       subcategory2_id = 0;
  284. 282.  -     }
  285. 283.  -     category2_id = value;
  286. 284.  -     var data = cur.subcategoriesData[value] || [];
  287. 285.  -     var disabledText = (value ? getLang('ads_no_subcategories') : getLang('ads_first_select_category2'));
  288. 286.  -     uiSubcategory2.setOptions({disabledText: disabledText});
  289. 287.  -     uiSubcategory2.setData(data);
  290. 288.  -     if (subcategory2_id) {
  291. 289.  -       uiSubcategory2.val(subcategory2_id);
  292. 290.  -     } else {
  293. 291.  -       uiSubcategory2.clear();
  294. 292.  -     }
  295. 293.  -     uiSubcategory2.disable(data.length == 0);
  296. 294.  -   }
  297. 295.  -   function applyChanges() {
  298. 296.  -     if (!category1_id && !category2_id) {
  299. 297.  -       showFastBox('������', '�� ������ ��������.');
  300. 298.  -       return;
  301. 299.  -     }
  302. 300.  -
  303. 301.  -     cur.requestsParams[requestKey].category1_id       = (subcategory1_id || category1_id);
  304. 302.  -     cur.requestsParams[requestKey].category2_id       = (subcategory2_id || category2_id);
  305. 303.  -     cur.requestsParams[requestKey].ui_category1_id    = category1_id;
  306. 304.  -     cur.requestsParams[requestKey].ui_category2_id    = category2_id;
  307. 305.  -     cur.requestsParams[requestKey].ui_subcategory1_id = subcategory1_id;
  308. 306.  -     cur.requestsParams[requestKey].ui_subcategory2_id = subcategory2_id;
  309. 307.  -     cur.requestsParams[requestKey].categories_changed = true;
  310. 308.  -
  311. 309.  -     var category1Elem       = geByClass1('ads_category1', linkElem);
  312. 310.  -     var category1ParentElem = geByClass1('ads_category1_parent', linkElem);
  313. 311.  -     if (subcategory1_id) {
  314. 312.  -       replaceClass(category1Elem, 'ads_category', 'ads_subcategory');
  315. 313.  -       category1Elem.innerHTML = uiSubcategory1.val_full()[1];
  316. 314.  -       category1ParentElem.innerHTML = ' (' + uiCategory1.val_full()[1] + ')';
  317. 315.  -     } else {
  318. 316.  -       replaceClass(category1Elem, 'ads_subcategory', 'ads_category');
  319. 317.  -       category1Elem.innerHTML = (category1_id ? uiCategory1.val_full()[1] : '');
  320. 318.  -       category1ParentElem.innerHTML = '';
  321. 319.  -     }
  322. 320.  -
  323. 321.  -     var category2Elem       = geByClass1('ads_category2', linkElem);
  324. 322.  -     var category2ParentElem = geByClass1('ads_category2_parent', linkElem);
  325. 323.  -     if (subcategory2_id) {
  326. 324.  -       replaceClass(category2Elem, 'ads_category', 'ads_subcategory');
  327. 325.  -       category2Elem.innerHTML = uiSubcategory2.val_full()[1];
  328. 326.  -       category2ParentElem.innerHTML = ' (' + uiCategory2.val_full()[1] + ')';
  329. 327.  -     } else {
  330. 328.  -       replaceClass(category2Elem, 'ads_subcategory', 'ads_category');
  331. 329.  -       category2Elem.innerHTML = (category2_id ? uiCategory2.val_full()[1] : '');
  332. 330.  -       category2ParentElem.innerHTML = '';
  333. 331.  -     }
  334. 332.  -
  335. 333.  -     editBox.hide();
  336. 334.  -   }
  337. 335.  - }
  338. 336.  -
  339. 337.  - AdsModer.premoderationProcessRequest = function(action, requestKey, requestKeyModer, onCompleteExternal) {
  340. 338.  -
  341. 339.  -   var requestParams      = cur.requestsParams[requestKey];
  342. 340.  -   var requestParamsModer = cur.requestsParams[requestKeyModer];
  343. 341.  -
  344. 342.  -   if (!requestKey || !requestKeyModer || !requestParams || !requestParamsModer) {
  345. 343.  -     return;
  346. 344.  -   }
  347. 345.  -
  348. 346.  -   var result = AdsModer.premoderationProcessRequestsMassCheck(action, requestKey);
  349. 347.  -   if (result) {
  350. 348.  -     return;
  351. 349.  -   }
  352. 350.  -
  353. 351.  -   var moderComment = ge('moder_comment_' + requestKeyModer);
  354. 352.  -   var resultArea   = ge('request_result_area_' + requestKey);
  355. 353.  -
  356. 354.  -   var ajaxParams = {};
  357. 355.  -   ajaxParams.action       = action;
  358. 356.  -   ajaxParams.request_id   = requestParams.request_id;
  359. 357.  -   ajaxParams.ad_id        = requestParams.ad_id;
  360. 358.  -   ajaxParams.hash         = requestParams.hash;
  361. 359.  -   ajaxParams.checksum     = requestParams.checksum_all;
  362. 360.  -
  363. 361.  -   if (action === 'approve') {
  364. 362.  -     if (requestParamsModer.categories_changed) {
  365. 363.  -       ajaxParams.category1_id = requestParamsModer.category1_id;
  366. 364.  -       ajaxParams.category2_id = requestParamsModer.category2_id;
  367. 365.  -     } else {
  368. 366.  -       ajaxParams.category1_id = requestParams.category1_id;
  369. 367.  -       ajaxParams.category2_id = requestParams.category2_id;
  370. 368.  -     }
  371. 369.  -   }
  372. 370.  -
  373. 371.  -   ajaxParams.moder_comment = moderComment.getValue();
  374. 372.  -   if (action === 'disapprove') {
  375. 373.  -     ajaxParams.moder_rules = cur.uiReasonsControls[requestKeyModer].getSelectedItems().join(',');
  376. 374.  -   }
  377. 375.  -
  378. 376.  -   resultArea.innerHTML = '<img src="/images/upload.gif" />';
  379. 377.  -
  380. 378.  -   ajax.post('/adsmoder?act=a_premoderation_process', ajaxParams, {onDone: onComplete, onFail: onComplete});
  381. 379.  -
  382. 380.  -   function onComplete(response) {
  383. 381.  -     var responseText = ((response && response.text) ? response.text : '������!');
  384. 382.  -     resultArea.innerHTML = responseText;
  385. 383.  -     if (isFunction(onCompleteExternal)) {
  386. 384.  -       onCompleteExternal(response, requestKey, responseText);
  387. 385.  -     }
  388. 386.  -     return true;
  389. 387.  -   };
  390. 388.  - }
  391. 389.  -
  392. 390.  - AdsModer.premoderationProcessRequestsMassCheck = function(action, requestKey) {
  393. 391.  -
  394. 392.  -   var requestParams = cur.requestsParams[requestKey];
  395. 393.  -
  396. 394.  -   var requestsKeys = [];
  397. 395.  -
  398. 396.  -   if (action === 'approve') {
  399. 397.  -     if (requestParams.categories_changed) {
  400. 398.  -       if (cur.requestsChecksumsApproveWithoutCategories[requestParams.checksum_approve_without_categories].length < 5) {
  401. 399.  -         return false;
  402. 400.  -       }
  403. 401.  -       requestsKeys = cur.requestsChecksumsApproveWithoutCategories[requestParams.checksum_approve_without_categories];
  404. 402.  -     } else {
  405. 403.  -       if (cur.requestsChecksumsApproveWithCategories[requestParams.checksum_approve_with_categories].length < 5) {
  406. 404.  -         return false;
  407. 405.  -       }
  408. 406.  -       requestsKeys = cur.requestsChecksumsApproveWithCategories[requestParams.checksum_approve_with_categories];
  409. 407.  -     }
  410. 408.  -   } else if (action === 'disapprove') {
  411. 409.  -     if (cur.requestsChecksumsDisapprove[requestParams.checksum_disapprove].length < 5) {
  412. 410.  -       return false;
  413. 411.  -     }
  414. 412.  -     requestsKeys = cur.requestsChecksumsDisapprove[requestParams.checksum_disapprove];
  415. 413.  -   }
  416. 414.  -
  417. 415.  -   var confirmTitle   = ((action === 'approve') ? '�������� ���������' : '�������� ����������');
  418. 416.  -   var confirmText    = '������� ���������� �� ������� ��������: '+requestsKeys.length;
  419. 417.  -   var processAllText = ((action === 'approve') ? '�������� ���' : '��������� ���');
  420. 418.  -   var processOneText = ((action === 'approve') ? '�������� ����' : '��������� ����');
  421. 419.  -
  422. 420.  -   var box = showFastBox(confirmTitle, cur.massBoxHtml, processAllText, processAll, processOneText, processOne);
  423. 421.  -   geByClass1('ads_premoderation_mass_confirm_text', box.bodyNode).innerHTML = confirmText;
  424. 422.  -
  425. 423.  -   return true;
  426. 424.  -
  427. 425.  -   function processAll() {
  428. 426.  -     cleanChecksums();
  429. 427.  -     AdsModer.premoderationProcessRequestsMass(action, requestKey, requestsKeys, box);
  430. 428.  -   }
  431. 429.  -   function processOne() {
  432. 430.  -     cleanChecksums();
  433. 431.  -     box.hide();
  434. 432.  -     AdsModer.premoderationProcessRequest(action, requestKey, requestKey);
  435. 433.  -   }
  436. 434.  -   function cleanChecksums() {
  437. 435.  -     cur.requestsChecksumsApproveWithCategories[requestParams.checksum_approve_with_categories] = [];
  438. 436.  -     cur.requestsChecksumsApproveWithoutCategories[requestParams.checksum_approve_without_categories] = [];
  439. 437.  -     cur.requestsChecksumsDisapprove[requestParams.checksum_disapprove] = [];
  440. 438.  -   }
  441. 439.  - }
  442. 440.  -
  443. 441.  - AdsModer.premoderationProcessRequestsMass = function(action, requestKeyModer, requestsKeys, box) {
  444. 442.  -   var requestParams = cur.requestsParams[requestKeyModer];
  445. 443.  -
  446. 444.  -   var totalCount       = requestsKeys.length;
  447. 445.  -   var completeCount    = 0;
  448. 446.  -   var approvedCount    = 0;
  449. 447.  -   var disapprovedCount = 0;
  450. 448.  -   var errorCount       = 0;
  451. 449.  -   var responseInfos    = [];
  452. 450.  -
  453. 451.  -   box.removeButtons();
  454. 452.  -   box.addButton(getLang('box_close'), false, 'yes');
  455. 453.  -
  456. 454.  -   var progressWrapElem = geByClass1('ads_premoderation_mass_progress_wrap2', box.bodyNode);
  457. 455.  -   var progressElem     = geByClass1('ads_gradient_progress', box.bodyNode);
  458. 456.  -   var resultElem       = geByClass1('ads_premoderation_mass_result', box.bodyNode);
  459. 457.  -   var resultTextElem   = geByClass1('ads_premoderation_mass_result_text', box.bodyNode);
  460. 458.  -   var resultMoreElem   = geByClass1('ads_premoderation_mass_result_more', box.bodyNode);
  461. 459.  -   drawProgress();
  462. 460.  -   show(progressWrapElem);
  463. 461.  -
  464. 462.  -   for (var i = 0; requestKey = requestsKeys[i]; i++) {
  465. 463.  -     setTimeout(AdsModer.premoderationProcessRequest.pbind(action, requestKey, requestKeyModer, onComplete), 200 * i);
  466. 464.  -   }
  467. 465.  -
  468. 466.  -   function onComplete(response, responseRequestKey, responseText) {
  469. 467.  -     var responseAdId = cur.requestsParams[responseRequestKey].ad_id;
  470. 468.  -     responseInfos.push('<a href="/ads?act=office&union_id='+responseAdId+'" target="_blank">'+responseAdId+' - '+responseText+'</a>');
  471. 469.  -
  472. 470.  -     if (response && (response.approved || response.disapproved)) {
  473. 471.  -       if (response.approved) {
  474. 472.  -         approvedCount++;
  475. 473.  -       }
  476. 474.  -       if (response.disapproved) {
  477. 475.  -         disapprovedCount++;
  478. 476.  -       }
  479. 477.  -     } else {
  480. 478.  -       errorCount++;
  481. 479.  -     }
  482. 480.  -     completeCount++;
  483. 481.  -
  484. 482.  -     drawProgress();
  485. 483.  -     if (completeCount == totalCount) {
  486. 484.  -       setTimeout(drawResults, 1000);
  487. 485.  -     }
  488. 486.  -   }
  489. 487.  -   function drawProgress() {
  490. 488.  -     var percent = intval(completeCount / totalCount * 100);
  491. 489.  -     setStyle(progressElem, {width: percent + '%'});
  492. 490.  -   }
  493. 491.  -   function drawResults() {
  494. 492.  -     hide(progressWrapElem);
  495. 493.  -
  496. 494.  -     var resultText = '';
  497. 495.  -     if (approvedCount) {
  498. 496.  -       resultText += '��������: '+approvedCount+'<br>';
  499. 497.  -     }
  500. 498.  -     if (disapprovedCount) {
  501. 499.  -       resultText += '���������: '+disapprovedCount+'<br>';
  502. 500.  -     }
  503. 501.  -     resultText += '������: '+errorCount+'<br>';
  504. 502.  -
  505. 503.  -     resultTextElem.innerHTML = resultText;
  506. 504.  -     resultMoreElem.innerHTML = responseInfos.join('<br>');
  507. 505.  -     show(resultElem);
  508. 506.  -   }
  509. 507.  - }
  510. 508.  -
  511. 509.  - AdsModer.premoderationTakeUnion = function(unionId, hash) {
  512. 510.  -   var ajaxParams = {};
  513. 511.  -   ajaxParams.hash     = hash;
  514. 512.  -   ajaxParams.union_id = unionId;
  515. 513.  -   ajaxParams.action   = 'take_union';
  516. 514.  -   ajax.post('/adsmoder?act=a_premoderation_manage_work', ajaxParams, {onDone: onComplete, onFail: onComplete});
  517. 515.  -
  518. 516.  -   function onComplete(response) {
  519. 517.  -     if (response && response.ok) {
  520. 518.  -       if (response.redirect) {
  521. 519.  -         nav.go(response.redirect);
  522. 520.  -       }
  523. 521.  -     } else {
  524. 522.  -       var message = ((response && response.error) ? response.error : '������');
  525. 523.  -       showFastBox({title: '������', onHide: function() { nav.reload(); }}, message);
  526. 524.  -     }
  527. 525.  -     return true;
  528. 526.  -   }
  529. 527.  - }
  530. 528.  -
  531. 529.  - AdsModer.premoderationTakeBackUnion = function(unionId, hash) {
  532. 530.  -   var ajaxParams = {};
  533. 531.  -   ajaxParams.hash     = hash;
  534. 532.  -   ajaxParams.union_id = unionId;
  535. 533.  -   ajaxParams.action   = 'take_back_union';
  536. 534.  -   ajax.post('/adsmoder?act=a_premoderation_manage_work', ajaxParams, {onDone: onComplete, onFail: onComplete});
  537. 535.  -
  538. 536.  -   function onComplete(response) {
  539. 537.  -     if (response && response.ok) {
  540. 538.  -       nav.reload();
  541. 539.  -     } else {
  542. 540.  -       var message = ((response && response.error) ? response.error : '������');
  543. 541.  -       showFastBox({title: '������', onHide: function() { nav.reload(); }}, message);
  544. 542.  -     }
  545. 543.  -     return true;
  546. 544.  -   }
  547. 545.  - }
  548. 546.  -
  549. 547.  - AdsModer.premoderationStopWork = function(hash) {
  550. 548.  -   var ajaxParams = {};
  551. 549.  -   ajaxParams.hash   = hash;
  552. 550.  -   ajaxParams.action = 'stop_work';
  553. 551.  -   ajax.post('/adsmoder?act=a_premoderation_manage_work', ajaxParams, {onDone: onComplete, onFail: onComplete});
  554. 552.  -
  555. 553.  -   function onComplete(response) {
  556. 554.  -     if (response && response.ok) {
  557. 555.  -       nav.reload();
  558. 556.  -     } else {
  559. 557.  -       var message = ((response && response.error) ? response.error : '������');
  560. 558.  -       showFastBox({title: '������', onHide: function() { nav.reload(); }}, message);
  561. 559.  -     }
  562. 560.  -     return true;
  563. 561.  -   }
  564. 562.  - }
  565. 563.  -
  566. 564.  - AdsModer.premoderationFixRequest = function(wrapElemId, requestId, action, hash) {
  567. 565.  -   if (!Ads.lock(wrapElemId, onLock, onUnlock)) {
  568. 566.  -     return;
  569. 567.  -   }
  570. 568.  -
  571. 569.  -   var ajaxParams = {}
  572. 570.  -   ajaxParams.request_id = requestId;
  573. 571.  -   ajaxParams.action     = action;
  574. 572.  -   ajaxParams.hash       = hash;
  575. 573.  -
  576. 574.  -   ajax.post('/adsmoder?act=premoderation_fix_request', ajaxParams, {onDone: onComplete, onFail: onComplete});
  577. 575.  -
  578. 576.  -   function onComplete(response) {
  579. 577.  -     Ads.unlock(wrapElemId);
  580. 578.  -     if (response && response.text_new) {
  581. 579.  -       var wrapElem = ge(wrapElemId);
  582. 580.  -       if (wrapElem) {
  583. 581.  -         wrapElem.parentNode.replaceChild(se(response.text_new), wrapElem);
  584. 582.  -       }
  585. 583.  -     }
  586. 584.  -     return true;
  587. 585.  -   }
  588. 586.  -   function onLock() {
  589. 587.  -     show(geByTag1('img', ge(wrapElemId)));
  590. 588.  -   }
  591. 589.  -   function onUnlock() {
  592. 590.  -     var wrapElem = ge(wrapElemId);
  593. 591.  -     if (wrapElem) {
  594. 592.  -       hide(geByTag1('img', wrapElem));
  595. 593.  -     }
  596. 594.  -   }
  597. 595.  - }
  598. 596.  -
  599. 597.  - AdsModer.switchOfficeBlock = function(actionLocation, confirmTitle, confirmText, actionText) {
  600. 598.  -   function switchBlocked() {
  601. 599.  -     Ads.simpleAjax(actionLocation);
  602. 600.  -   }
  603. 601.  -   showFastBox(confirmTitle, confirmText, actionText, switchBlocked, getLang('box_cancel'));
  604. 602.  - }
  605. 603.  -
  606. 604.  - AdsModer.openCancelClicksBox = function(ajaxParams) {
  607. 605.  -   var showOptions = {params: {}};
  608. 606.  -   showBox('/adsweb?act=log_cancel_box', ajaxParams, showOptions);
  609. 607.  - }
  610. 608.  -
  611. 609.  - AdsModer.initCancelClicksBox = function(box, ajaxParams) {
  612. 610.  -   var handler = AdsModer.cancelClicks.pbind(box, ajaxParams);
  613. 611.  -   box.removeButtons();
  614. 612.  -   box.addButton(getLang('box_cancel'), false, 'no');
  615. 613.  -   box.addButton('�������� �����', handler, 'yes');
  616. 614.  - }
  617. 615.  -
  618. 616.  - AdsModer.cancelClicks = function(box, ajaxParams) {
  619. 617.  -   if (!Ads.lock('cancelClicks', onLock, onUnlock)) {
  620. 618.  -     return;
  621. 619.  -   }
  622. 620.  -
  623. 621.  -   ajax.post('/adsweb?act=log_cancel', ajaxParams, {onDone: onComplete, onFail: onComplete});
  624. 622.  -
  625. 623.  -   function onComplete(response) {
  626. 624.  -     Ads.unlock('cancelClicks');
  627. 625.  -     if (response && response.ok) {
  628. 626.  -       nav.reload();
  629. 627.  -     } else {
  630. 628.  -       showFastBox('������', '������');
  631. 629.  -     }
  632. 630.  -     return true;
  633. 631.  -   }
  634. 632.  -   function onLock() {
  635. 633.  -     box.showProgress();
  636. 634.  -   }
  637. 635.  -   function onUnlock() {
  638. 636.  -     box.hide();
  639. 637.  -   }
  640. 638.  - }
  641. 639.  -
  642. 640.  - AdsModer.openClickfraudersPrepareBanBox = function(usersIds, day) {
  643. 641.  -   var ajaxParams = {};
  644. 642.  -   ajaxParams.users_ids = usersIds;
  645. 643.  -   ajaxParams.day       = day;
  646. 644.  -
  647. 645.  -   var showOptions = {params: {}};
  648. 646.  -   showOptions.params.width = 650;
  649. 647.  -
  650. 648.  -   showBox('/adsweb?act=clickfrauders_prepare_ban_box', ajaxParams, showOptions);
  651. 649.  - }
  652. 650.  -
  653. 651.  - AdsModer.initClickfraudersPrepareBanBox = function(box, hash, usersIds, day) {
  654. 652.  -   var prepareBanHandler = AdsModer.clickfraudersPrepareBan.pbind(box, hash, usersIds, day);
  655. 653.  -   box.removeButtons();
  656. 654.  -   box.addButton(getLang('box_cancel'), false, 'no');
  657. 655.  -   box.addButton('��������', prepareBanHandler, 'yes');
  658. 656.  - }
  659. 657.  -
  660. 658.  - AdsModer.clickfraudersPrepareBan = function(box, hash, usersIds, day) {
  661. 659.  -   if (!Ads.lock('clickfraudersPrepareBan', onLock, onUnlock)) {
  662. 660.  -     return;
  663. 661.  -   }
  664. 662.  -
  665. 663.  -   var ajaxParams = {};
  666. 664.  -   ajaxParams.hash      = hash;
  667. 665.  -   ajaxParams.users_ids = usersIds;
  668. 666.  -   ajaxParams.day       = day;
  669. 667.  -
  670. 668.  -   ajax.post('/adsweb?act=clickfrauders_prepare_ban', ajaxParams, {onDone: onComplete, onFail: onComplete});
  671. 669.  -
  672. 670.  -   function onComplete(response) {
  673. 671.  -     Ads.unlock('clickfraudersPrepareBan');
  674. 672.  -     if (response && response.message) {
  675. 673.  -       showFastBox('��', response.message);
  676. 674.  -     } else {
  677. 675.  -       showFastBox('������', '������');
  678. 676.  -     }
  679. 677.  -     return true;
  680. 678.  -   }
  681. 679.  -   function onLock() {
  682. 680.  -     box.showProgress();
  683. 681.  -   }
  684. 682.  -   function onUnlock() {
  685. 683.  -     box.hide();
  686. 684.  -   }
  687. 685.  - }
  688. 686.  -
  689. 687.  - AdsModer.historyGet = function(elem, notNavigationParam) {
  690. 688.  -   while (elem && elem.nodeName.toLowerCase() !== 'form') {
  691. 689.  -     elem = elem.parentNode;
  692. 690.  -   }
  693. 691.  -   if (!elem) {
  694. 692.  -     return;
  695. 693.  -   }
  696. 694.  -   var values = serializeForm(elem);
  697. 695.  -   var params = values.other_params;
  698. 696.  -   delete values.other_params;
  699. 697.  -   for (var i in values) {
  700. 698.  -     if (values[i]) {
  701. 699.  -       params = '&' + i + '=' + values[i] + params;
  702. 700.  -     }
  703. 701.  -   }
  704. 702.  -   nav.go('/adsmoder?act=history' + params);
  705. 703.  - }
  706. 704.  -
  707. 705.  - AdsModer.historyToggleFilters = function() {
  708. 706.  -   var filtersContainerElem = ge('ads_moder_history');
  709. 707.  -   var filtersElems = geByClass('ads_navigation_link', filtersContainerElem);
  710. 708.  -   for (var i = 0; elem = filtersElems[i]; i++) {
  711. 709.  -       if (hasClass(elem, 'current')) {
  712. 710.  -           continue
  713. 711.  -       }
  714. 712.  -       elem = elem.parentNode;
  715. 713.  -       if (elem.nodeName.toLowerCase() !== 'span') {
  716. 714.  -           continue
  717. 715.  -       }
  718. 716.  -       toggleClass(elem, 'unshown');
  719. 717.  -   }
  720. 718.  - }
  721. 719.  -
  722. 720.  - AdsModer.statSummaryInit = function(periodType, fromYear, fromMonth, fromDay, toYear, toMonth, toDay) {
  723. 721.  -   var datePickerOptionsFrom = {
  724. 722.  -     mode: (periodType === 'month') ? 'm' : 'd',
  725. 723.  -     year:  fromYear,
  726. 724.  -     month: fromMonth,
  727. 725.  -     day:   fromDay,
  728. 726.  -     width: 130,
  729. 727.  -     pastActive: true,
  730. 728.  -     onUpdate: function(date, mode) {
  731. 729.  -       fromYear  = date.y;
  732. 730.  -       fromMonth = date.m;
  733. 731.  -       fromDay   = date.d;
  734. 732.  -       updateLink();
  735. 733.  -     }
  736. 734.  -   };
  737. 735.  -   var datePickerOptionsTo = {
  738. 736.  -     mode: (periodType === 'month') ? 'm' : 'd',
  739. 737.  -     year:  toYear,
  740. 738.  -     month: toMonth,
  741. 739.  -     day:   toDay,
  742. 740.  -     width: 130,
  743. 741.  -     pastActive: true,
  744. 742.  -     onUpdate: function(date, mode) {
  745. 743.  -       toYear  = date.y;
  746. 744.  -       toMonth = date.m;
  747. 745.  -       toDay   = date.d;
  748. 746.  -       updateLink();
  749. 747.  -     }
  750. 748.  -   };
  751. 749.  -   new Datepicker(ge('ads_moder_stat_summary_from'), datePickerOptionsFrom);
  752. 750.  -   new Datepicker(ge('ads_moder_stat_summary_to'), datePickerOptionsTo);
  753. 751.  -
  754. 752.  -   function updateLink() {
  755. 753.  -     var fromPeriod = fromYear * 100 + fromMonth;
  756. 754.  -     var toPeriod   = toYear   * 100 + toMonth;
  757. 755.  -     if (periodType !== 'month') {
  758. 756.  -       fromPeriod = fromPeriod * 100 + fromDay;
  759. 757.  -       toPeriod   = toPeriod   * 100 + toDay;
  760. 758.  -     }
  761. 759.  -     var linkElem = ge('ads_moder_stat_summary_range_link');
  762. 760.  -     linkElem.href = linkElem.href.replace(/&period=\d+-\d+/, '&period=' + fromPeriod + '-' + toPeriod);
  763. 761.  -     linkElem.style.opacity = 1;
  764. 762.  -   }
  765. 763.  - }
  766. 764.  -
  767. 765.  - AdsModer.statSummaryShowAllProperties = function() {
  768. 766.  -   var propertiesElem = ge('ads_moder_stat_summary_filter_properties');
  769. 767.  -   var elems = geByClass('ads_moder_stat_summary_filter_property', propertiesElem);
  770. 768.  -   each(elems, show);
  771. 769.  -   hide('ads_moder_stat_summary_filter_properties_shower_wrap');
  772. 770.  - }
  773. 771.  -
  774. 772.  - AdsModer.statSummaryDistrShowCountLabel = function(id, i, val) {
  775. 773.  -   var contXy = getXY(ge(id+'_stats_graph_wrap'));
  776. 774.  -   var colXy  = getXY(ge(id+'_distr_col_'+i));
  777. 775.  -
  778. 776.  -   setStyle(ge(id+'_max_label'), {
  779. 777.  -     left: colXy[0] - contXy[0] + 14,
  780. 778.  -     top:  colXy[1] - contXy[1] - 11
  781. 779.  -   });
  782. 780.  -   ge(id+'_max_label').innerHTML = val;
  783. 781.  -   show(id+'_max_label');
  784. 782.  -   setStyle(ge(id+'_max_label_out'), {
  785. 783.  -     width:  ge(id+'_max_label').offsetWidth + 2,
  786. 784.  -     height: ge(id+'_max_label').offsetHeight + 2,
  787. 785.  -     left:   colXy[0] - contXy[0] + 13,
  788. 786.  -     top:    colXy[1] - contXy[1] - 12
  789. 787.  -   });
  790. 788.  -   show(id+'_max_label_out');
  791. 789.  -   setStyle(ge(id+'_max_label_out2'), {
  792. 790.  -     width:  ge(id+'_max_label').offsetWidth + 4,
  793. 791.  -     height: ge(id+'_max_label').offsetHeight + 4,
  794. 792.  -     left:   colXy[0] - contXy[0] + 12,
  795. 793.  -     top:    colXy[1] - contXy[1] - 13
  796. 794.  -   });
  797. 795.  -   show(id+'_max_label_out2');
  798. 796.  - }
  799. 797.  -
  800. 798.  - AdsModer.statSummaryDistrHideCountLabel = function(id) {
  801. 799.  -   hide(id+'_max_label');
  802. 800.  -   hide(id+'_max_label_out');
  803. 801.  -   hide(id+'_max_label_out2');
  804. 802.  - }
  805. 803.  -
  806. 804.  - AdsModer.statSummaryShowVotesBox = function(periodType, period) {
  807. 805.  -   var ajaxParams = {};
  808. 806.  -   ajaxParams.period_type = periodType;
  809. 807.  -   ajaxParams.period      = period;
  810. 808.  -
  811. 809.  -   var showOptions = {params: {}};
  812. 810.  -
  813. 811.  -   showBox('/adsmoder?act=stat_summary_votes', ajaxParams, showOptions);
  814. 812.  - }
  815. 813.  -
  816. 814.  - AdsModer.increaseBudget = function() {
  817. 815.  -   if (!Ads.lock('increaseBudget', onLock, onUnlock)) {
  818. 816.  -     return;
  819. 817.  -   }
  820. 818.  -
  821. 819.  -   var ajaxParams = {};
  822. 820.  -   ajaxParams.union_id     = val('ads_increase_budget_union_id');
  823. 821.  -   ajaxParams.money_amount = val('ads_increase_budget_amount');
  824. 822.  -   ajaxParams.hash         = val('ads_increase_budget_hash');
  825. 823.  -
  826. 824.  -   ajax.post('/adsmoder?act=increase_budget', ajaxParams, {onDone: onComplete, onFail: onComplete});
  827. 825.  -
  828. 826.  -   function onComplete(response) {
  829. 827.  -     Ads.unlock('increaseBudget');
  830. 828.  -     if (response && response.redirect) {
  831. 829.  -       nav.go(response.redirect);
  832. 830.  -     } else {
  833. 831.  -       var msg = ((response && response.error) ? response.error : '������');
  834. 832.  -       showFastBox('������', msg);
  835. 833.  -     }
  836. 834.  -     return true;
  837. 835.  -   }
  838. 836.  -   function onLock() {
  839. 837.  -     lockButton('ads_increase_budget_button');
  840. 838.  -   }
  841. 839.  -   function onUnlock() {
  842. 840.  -     unlockButton('ads_increase_budget_button');
  843. 841.  -   }
  844. 842.  - }
  845. 843.  -
  846. 844.  - AdsModer.openDisableOfficeBox = function(ajaxParams, isCompany) {
  847. 845.  -   cur.lang.ads_disable_office_box_title               = '�������� ���������� ��������';
  848. 846.  -   cur.lang.ads_disable_office_box_button              = '������� �������';
  849. 847.  -   cur.lang.ads_disable_office_confirm_message         = '�� ������� ��� ������ ������� ��������� �������?<br><br>����� �������� �������� ��������� ������ � ����������, �� ����� �������� �������� ����� ����������.';
  850. 848.  -   cur.lang.ads_disable_office_company_confirm_message = '������ ����� �������� �������� �������� �������� ������ ���������� ����� � ����� ��������.';
  851. 849.  -   var message = getLang('ads_disable_office_confirm_message');
  852. 850.  -   if (isCompany) {
  853. 851.  -     message += '<br><br>' + getLang('ads_disable_office_company_confirm_message');
  854. 852.  -   }
  855. 853.  -   var messageBox = showFastBox(getLang('ads_disable_office_box_title'), message, getLang('ads_disable_office_box_button'), function(){ AdsModer.disableOffice(ajaxParams, messageBox); }, getLang('box_cancel'));
  856. 854.  - }
  857. 855.  -
  858. 856.  - AdsModer.disableOffice = function(ajaxParams, box) {
  859. 857.  -   if (!Ads.lock('disableOffice', onLock, onUnlock)) {
  860. 858.  -     return;
  861. 859.  -   }
  862. 860.  -
  863. 861.  -   ajax.post('/adsmoder?act=a_disable_office', ajaxParams, {onDone: onComplete, onFail: onComplete});
  864. 862.  -
  865. 863.  -   function onComplete(response) {
  866. 864.  -     Ads.unlock('disableOffice');
  867. 865.  -     if (response && response.redirect) {
  868. 866.  -       nav.reload();
  869. 867.  -     } else {
  870. 868.  -       box.hide();
  871. 869.  -       showFastBox(getLang('ads_error_box_title'), getLang('ads_error_text'));
  872. 870.  -     }
  873. 871.  -     return true;
  874. 872.  -   }
  875. 873.  -   function onLock() {
  876. 874.  -     box.showProgress();
  877. 875.  -   }
  878. 876.  -   function onUnlock() {
  879. 877.  -     box.hideProgress();
  880. 878.  -   }
  881. 879.  - }
  882. 880.  -
  883. 881.  - try{stManager.done('ads_moder.js');}catch(e){}
  884. ------
Advertisement
Add Comment
Please, Sign In to add comment