81 <span id="switcher">' + switcher + '</span><br />\ |
81 <span id="switcher">' + switcher + '</span><br />\ |
82 <form name="mdgAjaxEditor" method="get" action="#" onsubmit="ajaxSavePage(); return false;">\ |
82 <form name="mdgAjaxEditor" method="get" action="#" onsubmit="ajaxSavePage(); return false;">\ |
83 <textarea id="ajaxEditArea" rows="20" cols="60" style="display: block; margin: 1em 0 1em 1em; width: 96.5%;">'+ajax.responseText+'</textarea><br />\ |
83 <textarea id="ajaxEditArea" rows="20" cols="60" style="display: block; margin: 1em 0 1em 1em; width: 96.5%;">'+ajax.responseText+'</textarea><br />\ |
84 Edit summary: <input id="ajaxEditSummary" size="40" /><br />\ |
84 Edit summary: <input id="ajaxEditSummary" size="40" /><br />\ |
85 <input id="ajaxEditMinor" name="minor" type="checkbox" /> <label for="ajaxEditMinor">This is a minor edit</label><br />\ |
85 <input id="ajaxEditMinor" name="minor" type="checkbox" /> <label for="ajaxEditMinor">This is a minor edit</label><br />\ |
86 <a href="#" onclick="void(ajaxSavePage()); return false;">save changes</a> | <a href="#" onclick="void(ajaxShowPreview()); return false;">preview changes</a> | <a href="#" onclick="void(ajaxEditor()); return false;">revert changes</a> | <a href="#" onclick="void(ajaxDiscard()); return false;">discard changes</a> | <a href="#" onclick="ajaxWikiEditHelp(); return false;">formatting help</a>\ |
86 <a href="#" onclick="void(ajaxSavePage()); return false;">save changes</a> | <a href="#" onclick="void(ajaxShowPreview()); return false;">preview changes</a> | <a href="#" onclick="void(ajaxEditor()); return false;">revert changes</a> | <a href="#" onclick="void(ajaxDiscard()); return false;">discard changes</a>\ |
87 <br />\ |
87 <br />\ |
88 '+editNotice+'\ |
88 '+editNotice+'\ |
89 </form>'; |
89 </form>'; |
90 // initTextareas(); |
90 // initTextareas(); |
91 if(readCookie('enano_editor_mode') == 'tinymce') |
91 if(readCookie('enano_editor_mode') == 'tinymce') |
865 } |
849 } |
866 } |
850 } |
867 }); |
851 }); |
868 } |
852 } |
869 |
853 |
|
854 var catHTMLBuf = false; |
|
855 |
|
856 function ajaxCatToTag() |
|
857 { |
|
858 if ( KILL_SWITCH ) |
|
859 return false; |
|
860 setAjaxLoading(); |
|
861 ajaxGet(stdAjaxPrefix + '&_mode=get_tags', function() |
|
862 { |
|
863 if ( ajax.readyState == 4 ) |
|
864 { |
|
865 unsetAjaxLoading(); |
|
866 var resptext = String(ajax.responseText + ' '); |
|
867 resptext = resptext.substr(0, resptext.length-1); |
|
868 if ( resptext.substr(0, 1) != '{' ) |
|
869 { |
|
870 alert('Invalid JSON response from server:\n' + resptext); |
|
871 return false; |
|
872 } |
|
873 var json = parseJSON(resptext); |
|
874 var catbox = document.getElementById('mdgCatBox'); |
|
875 if ( !catbox ) |
|
876 return false; |
|
877 var linkbox = catbox.parentNode.firstChild.firstChild.nextSibling; |
|
878 linkbox.firstChild.nodeValue = 'show page categorization'; |
|
879 linkbox.onclick = function() { ajaxTagToCat(); return false; }; |
|
880 catHTMLBuf = catbox.innerHTML; |
|
881 catbox.innerHTML = ''; |
|
882 catbox.appendChild(document.createTextNode('Page tags: ')); |
|
883 if ( json.tags.length < 1 ) |
|
884 { |
|
885 catbox.appendChild(document.createTextNode('No tags on this page')); |
|
886 } |
|
887 for ( var i = 0; i < json.tags.length; i++ ) |
|
888 { |
|
889 catbox.appendChild(document.createTextNode(json.tags[i].name)); |
|
890 if ( json.tags[i].can_del ) |
|
891 { |
|
892 catbox.appendChild(document.createTextNode(' ')); |
|
893 var a = document.createElement('a'); |
|
894 a.appendChild(document.createTextNode('[X]')); |
|
895 a.href = '#'; |
|
896 a.onclick = function() { return false; } |
|
897 catbox.appendChild(a); |
|
898 } |
|
899 if ( ( i + 1 ) < json.tags.length ) |
|
900 catbox.appendChild(document.createTextNode(', ')); |
|
901 } |
|
902 if ( json.can_add ) |
|
903 { |
|
904 catbox.appendChild(document.createTextNode(' ')); |
|
905 var addlink = document.createElement('a'); |
|
906 addlink.href = '#'; |
|
907 addlink.onclick = function() { try { ajaxAddTagStage1(); } catch(e) { }; return false; }; |
|
908 addlink.appendChild(document.createTextNode('(add a tag)')); |
|
909 catbox.appendChild(addlink); |
|
910 } |
|
911 } |
|
912 }); |
|
913 } |
|
914 |
|
915 function ajaxAddTagStage1() |
|
916 { |
|
917 var catbox = document.getElementById('mdgCatBox'); |
|
918 var adddiv = document.createElement('div'); |
|
919 var text = document.createElement('input'); |
|
920 var addlink = document.createElement('a'); |
|
921 addlink.href = '#'; |
|
922 addlink.onclick = function() { return false; }; |
|
923 addlink.appendChild(document.createTextNode('+ Add')); |
|
924 text.type = 'text'; |
|
925 text.size = '15'; |
|
926 |
|
927 adddiv.style.margin = '5px 0 0 0'; |
|
928 adddiv.appendChild(document.createTextNode('Add a tag: ')); |
|
929 adddiv.appendChild(text); |
|
930 adddiv.appendChild(document.createTextNode(' ')); |
|
931 adddiv.appendChild(addlink); |
|
932 catbox.appendChild(adddiv); |
|
933 } |
|
934 |
|
935 function ajaxTagToCat() |
|
936 { |
|
937 if ( !catHTMLBuf ) |
|
938 return false; |
|
939 var catbox = document.getElementById('mdgCatBox'); |
|
940 if ( !catbox ) |
|
941 return false; |
|
942 var linkbox = catbox.parentNode.firstChild.firstChild.nextSibling; |
|
943 linkbox.firstChild.nodeValue = 'show page tags'; |
|
944 linkbox.onclick = function() { ajaxCatToTag(); return false; }; |
|
945 catbox.innerHTML = catHTMLBuf; |
|
946 catHTMLBuf = false; |
|
947 } |
|
948 |