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