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