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