2 * Arthrology for Elxis CMS 2008.x and 2009.x+
8 * @author Apostolos Koutsoulelos <akoutsoulelos@yahoo.gr>
9 * @authorurl http://www.bitcraft-labs.gr
10 * @copyright Copyright (C) 2009-2011 Apostolos Koutsoulelos. All rights reserved.
11 * @license GNU/GPL (http://www.gnu.org/copyleft/gpl.html)
13 * @link http://www.elxis-downloads.com/downloads/miscellaneous/204.html
15 * ======================= NOTE =======================
17 * Based on Ioannis Sannos (datahell) code
23 if(window
.XMLHttpRequest
){ // Non-IE browsers
24 ro
= new XMLHttpRequest();
25 } else if (window
.ActiveXObject
){ // IE
26 ro
=new ActiveXObject("Msxml2.XMLHTTP");
28 ro
=new ActiveXObject("Microsoft.XMLHTTP");
36 var cajax
= new sack();
38 /* GENERAL FUNCTIONS */
39 function whenLoadingcon(){
40 var e
= document
.getElementById(cajax
.element
);
41 e
.innerHTML
= "<img src='images/loading.gif' border='0'>";
44 function whenLoadedcon(){
45 var e
= document
.getElementById(cajax
.element
);
46 e
.innerHTML
= "<img src='images/loading.gif' border='0'>";
49 function whenInteractivecon(){
50 var e
= document
.getElementById(cajax
.element
);
51 e
.innerHTML
= "<img src='images/loading.gif' border='0'>";
54 /* CHANGE PUBLISHING STATE */
55 function changeContentState(elem
, id
, state
){
56 ajelem
= 'constatus'+elem
;
57 var e
= document
.getElementById(ajelem
);
60 cajax
.setVar("option", 'com_arthrology');
61 cajax
.setVar("task", 'ajaxpub');
62 cajax
.setVar("elem", elem
);
63 cajax
.setVar("id", id
);
64 cajax
.setVar("state", state
);
66 cajax
.requestFile
= "index3.php";
68 cajax
.method
= 'POST';
69 cajax
.element
= ajelem
;
70 cajax
.onLoading
= whenLoadingcon
;
71 cajax
.onLoaded
= whenLoadedcon
;
72 cajax
.onInteractive
= whenInteractivecon
;
76 /* VALIDATE SEO TITLE */
77 function validateSEO() {
78 var seotitle
= document
.adminForm
.seotitle
.value
;
79 var coid
= document
.adminForm
.id
.value
;
80 var cocatid
= document
.adminForm
.catid
.options
[document
.adminForm
.catid
.selectedIndex
].value
;
82 cajax
.setVar("option", 'com_arthrology');
83 cajax
.setVar("task", 'validate');
84 cajax
.setVar("coid", coid
);
85 cajax
.setVar("cocatid", cocatid
);
86 cajax
.setVar("seotitle", seotitle
);
88 cajax
.requestFile
= "index3.php";
90 cajax
.method
= 'POST';
91 cajax
.element
= 'valseo';
92 cajax
.onLoading
= whenLoadingcon
;
93 cajax
.onLoaded
= whenLoadedcon
;
94 cajax
.onInteractive
= whenInteractivecon
;
98 /* SUGGEST SEO TITLE */
99 function suggestSEO() {
100 var cotitle
= document
.adminForm
.title
.value
;
101 var coid
= document
.adminForm
.id
.value
;
102 var cocatid
= document
.adminForm
.catid
.options
[document
.adminForm
.catid
.selectedIndex
].value
;
105 alert('Please write a title!');
107 var rnd
= Math
.random();
109 http
.open('POST', 'index3.php');
110 http
.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
111 http
.setRequestHeader('charset', 'utf-8');
112 http
.onreadystatechange
= showresultsug
;
113 http
.send('option=com_arthrology&task=suggest&cotitle='+cotitle
+'&coid='+coid
+'&cocatid='+cocatid
+'&rnd='+rnd
);
120 /* SHOW SUGGESTION RESULTS */
121 function showresultsug() {
122 var stitle
= document
.getElementById('seotitle');
123 if(http
.readyState
== 4) {
124 if(http
.status
!=200) {
125 alert('Error, please retry');
127 var reply
= http
.responseText
;
128 var update
= new Array();
129 update
= reply
.split('|');
131 stitle
.value
= update
[2];