Hormold

VK Change (#1388504704)

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