Index: trunk/phase3/skins/common/wikibits.js |
— | — | @@ -766,6 +766,41 @@ |
767 | 767 | document.getElementById(idb).checked=false; |
768 | 768 | } |
769 | 769 | |
| 770 | +var lastFileChecked = "" ; |
| 771 | +function checkFileExists () { |
| 772 | + // Find file to upload |
| 773 | + var destFile = document.getElementById('wpDestFile'); |
| 774 | + if ( !destFile ) return ; |
| 775 | + fname = destFile.value ; |
| 776 | + |
| 777 | + if ( fname == lastFileChecked ) return ; |
| 778 | + lastFileChecked = fname ; |
| 779 | + |
| 780 | + // Delete old warning, if any |
| 781 | + var existsWarning = document.getElementById('existsWarning'); |
| 782 | + if ( existsWarning ) { |
| 783 | + var pn = existsWarning.parentNode ; |
| 784 | + pn.removeChild ( existsWarning ) ; |
| 785 | + } |
| 786 | + |
| 787 | + // Check for existence |
| 788 | + var url = wgServer + wgScriptPath + "/api.php?action=query&prop=info&format=xml&titles=Image:" + fname ; |
| 789 | + var xmlHttp = new XMLHttpRequest(); |
| 790 | + xmlHttp.open('GET', url, false); |
| 791 | + xmlHttp.send(null); |
| 792 | + var text = xmlHttp.responseText ; |
| 793 | + if ( text.split(" pageid=").length < 2 ) return ; // Page doesn'exist (test is quicker than XML parsing, so...) |
| 794 | + |
| 795 | + // Set warning |
| 796 | + var thetd = destFile.parentNode ; |
| 797 | +// thetd.innerHTML += url ; |
| 798 | + thetd.innerHTML += "<span id='existsWarning' style='color:red'> A file with this name already exists; uploading under the same name will replace it!</span>" ; |
| 799 | + |
| 800 | + // Restore the filename |
| 801 | + var destFile = document.getElementById('wpDestFile'); |
| 802 | + destFile.value = fname; |
| 803 | +} |
| 804 | + |
770 | 805 | function fillDestFilename(id) { |
771 | 806 | if (!document.getElementById) { |
772 | 807 | return; |
— | — | @@ -790,6 +825,7 @@ |
791 | 826 | var destFile = document.getElementById('wpDestFile'); |
792 | 827 | if (destFile) { |
793 | 828 | destFile.value = fname; |
| 829 | + checkFileExists () ; |
794 | 830 | } |
795 | 831 | } |
796 | 832 | |
Index: trunk/phase3/includes/SpecialUpload.php |
— | — | @@ -791,7 +791,7 @@ |
792 | 792 | <tr> |
793 | 793 | <td align='right'><label for='wpDestFile'>{$destfilename}:</label></td> |
794 | 794 | <td align='left'> |
795 | | - <input tabindex='2' type='text' name='wpDestFile' id='wpDestFile' size='40' value="$encDestName" /> |
| 795 | + <input tabindex='2' type='text' name='wpDestFile' id='wpDestFile' size='40' value="$encDestName" onkeyup="checkFileExists();" /> |
796 | 796 | </td> |
797 | 797 | </tr> |
798 | 798 | <tr> |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -114,6 +114,7 @@ |
115 | 115 | Patch by Edward Z. Yang. |
116 | 116 | * Introduce 'ShowRawCssJs' hook; see docs/hooks.txt for more information |
117 | 117 | * (bug 10404) Show rights log fragment for the selected user in Special:Userrights |
| 118 | +* New javascript for upload page that will show a warning if a file with the "destination filename" already exists. |
118 | 119 | |
119 | 120 | == Bugfixes since 1.10 == |
120 | 121 | |