Index: trunk/extensions/Wikidata/App.php |
— | — | @@ -127,6 +127,7 @@ |
128 | 128 | function addWikidataHeader( &$out, &$skin ) { |
129 | 129 | global $wgScriptPath; |
130 | 130 | $out->addScript( "<script type='text/javascript' src='$wgScriptPath/extensions/Wikidata/OmegaWiki/suggest.js'></script>" ); |
| 131 | + $out->addScript( "<script type='text/javascript' src='$wgScriptPath/extensions/Wikidata/OmegaWiki/omegawiki-ajax.js'></script>" ); |
131 | 132 | |
132 | 133 | global $wgLang; |
133 | 134 | if ( $wgLang->isRTL() ) { |
Index: trunk/extensions/Wikidata/OmegaWiki/suggest.js |
— | — | @@ -924,58 +924,3 @@ |
925 | 925 | return ""; |
926 | 926 | } |
927 | 927 | |
928 | | - |
929 | | -// add a new row for translation or definition |
930 | | -function addEmptyRow(elementId) { |
931 | | - var element = document.getElementById( elementId ); |
932 | | - |
933 | | - var container = element.parentNode ; |
934 | | - |
935 | | - // create a clone to work on |
936 | | - var new_element = element.cloneNode(true); |
937 | | - |
938 | | - // removes the green button for the old row |
939 | | - element.firstChild.removeChild ( element.firstChild.firstChild ) ; |
940 | | - |
941 | | - // all new textareas field should be set empty |
942 | | - var textAreaList = new_element.getElementsByTagName('textarea'); |
943 | | - for (i=0; i<textAreaList.length ; i++) |
944 | | - { |
945 | | - if ( textAreaList[i].type == 'text' ) { |
946 | | - textAreaList[i].value = '' ; |
947 | | - } |
948 | | - } |
949 | | - |
950 | | -// for the spelling, it is not a textarea but an input type=text. |
951 | | -// (some other input fields, hidden, are needed, so we should not clear all <input> ) |
952 | | - var inputList = new_element.getElementsByTagName('input'); |
953 | | - for (i=0; i<inputList.length ; i++) |
954 | | - { |
955 | | - if ( inputList[i].type == 'text' ) { |
956 | | - inputList[i].value = '' ; |
957 | | - } |
958 | | - if ( inputList[i].name == 'onUpdate' ) { |
959 | | - inputList[i].value = inputList[i].value.replace("add-", "add-X-") ; |
960 | | - } |
961 | | - } |
962 | | - |
963 | | - recursiveChangeId( new_element ) ; |
964 | | - |
965 | | - // add the element as the last one (null) |
966 | | - container.appendChild(new_element ); |
967 | | -} |
968 | | - |
969 | | -function recursiveChangeId(element) { |
970 | | - if (element == null) return; |
971 | | - if ( element.hasChildNodes() ) { |
972 | | - var children = element.childNodes ; |
973 | | - for (var i=0; i<children.length ; i++) |
974 | | - { |
975 | | - recursiveChangeId ( children[i] ) ; |
976 | | - } |
977 | | - } |
978 | | - |
979 | | - if ( element.id ) element.id = element.id.replace("add-", "add-X-") ; |
980 | | - if ( element.name ) element.name = element.name.replace("add-", "add-X-") ; |
981 | | - return ; |
982 | | -} |
Index: trunk/extensions/Wikidata/OmegaWiki/omegawiki-ajax.js |
— | — | @@ -0,0 +1,242 @@ |
| 2 | +// add a new row for translation or definition |
| 3 | +function addEmptyRow(elementId) { |
| 4 | + var element = document.getElementById( elementId ); |
| 5 | + var container = element.parentNode ; |
| 6 | + |
| 7 | + // create a clone to work on |
| 8 | + var new_element = element.cloneNode(true); |
| 9 | + // removes the green button for the old row |
| 10 | + element.firstChild.removeChild ( element.firstChild.firstChild ); |
| 11 | + // all new textareas field should be set empty |
| 12 | + var textAreaList = new_element.getElementsByTagName('textarea'); |
| 13 | + for (i=0; i<textAreaList.length ; i++) |
| 14 | + { |
| 15 | + if (textAreaList[i].type == 'text') textAreaList[i].value = ''; |
| 16 | + } |
| 17 | + |
| 18 | +// for the spelling, it is not a textarea but an input type=text. |
| 19 | +// (some other input fields, hidden, are needed, so we should not clear all <input> ) |
| 20 | + var inputList = new_element.getElementsByTagName('input'); |
| 21 | + for (i=0; i<inputList.length ; i++) |
| 22 | + { |
| 23 | + if (inputList[i].type == 'text') inputList[i].value = '' ; |
| 24 | + if (inputList[i].name == 'onUpdate') inputList[i].value = inputList[i].value.replace("add-","add-X-"); |
| 25 | + } |
| 26 | + recursiveChangeId(new_element); |
| 27 | + // add the element as the last one (null) |
| 28 | + container.appendChild(new_element ); |
| 29 | +} |
| 30 | + |
| 31 | +function recursiveChangeId(element) { |
| 32 | + if (element == null) return; |
| 33 | + if (element.hasChildNodes()) { |
| 34 | + var children = element.childNodes ; |
| 35 | + for (var i=0; i<children.length ; i++) recursiveChangeId (children[i]); |
| 36 | + } |
| 37 | + if (element.id) element.id = element.id.replace("add-","add-X-"); |
| 38 | + if (element.name) element.name = element.name.replace("add-","add-X-"); |
| 39 | + return ; |
| 40 | +} |
| 41 | + |
| 42 | + |
| 43 | +var MD5 = function (string) { |
| 44 | + |
| 45 | + function RotateLeft(lValue, iShiftBits) { |
| 46 | + return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits)); |
| 47 | + } |
| 48 | + |
| 49 | + function AddUnsigned(lX,lY) { |
| 50 | + var lX4,lY4,lX8,lY8,lResult; |
| 51 | + lX8 = (lX & 0x80000000); |
| 52 | + lY8 = (lY & 0x80000000); |
| 53 | + lX4 = (lX & 0x40000000); |
| 54 | + lY4 = (lY & 0x40000000); |
| 55 | + lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF); |
| 56 | + if (lX4 & lY4) { |
| 57 | + return (lResult ^ 0x80000000 ^ lX8 ^ lY8); |
| 58 | + } |
| 59 | + if (lX4 | lY4) { |
| 60 | + if (lResult & 0x40000000) { |
| 61 | + return (lResult ^ 0xC0000000 ^ lX8 ^ lY8); |
| 62 | + } else { |
| 63 | + return (lResult ^ 0x40000000 ^ lX8 ^ lY8); |
| 64 | + } |
| 65 | + } else { |
| 66 | + return (lResult ^ lX8 ^ lY8); |
| 67 | + } |
| 68 | + } |
| 69 | + |
| 70 | + function F(x,y,z) { return (x & y) | ((~x) & z); } |
| 71 | + function G(x,y,z) { return (x & z) | (y & (~z)); } |
| 72 | + function H(x,y,z) { return (x ^ y ^ z); } |
| 73 | + function I(x,y,z) { return (y ^ (x | (~z))); } |
| 74 | + |
| 75 | + function FF(a,b,c,d,x,s,ac) { |
| 76 | + a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac)); |
| 77 | + return AddUnsigned(RotateLeft(a, s), b); |
| 78 | + }; |
| 79 | + |
| 80 | + function GG(a,b,c,d,x,s,ac) { |
| 81 | + a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac)); |
| 82 | + return AddUnsigned(RotateLeft(a, s), b); |
| 83 | + }; |
| 84 | + |
| 85 | + function HH(a,b,c,d,x,s,ac) { |
| 86 | + a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac)); |
| 87 | + return AddUnsigned(RotateLeft(a, s), b); |
| 88 | + }; |
| 89 | + |
| 90 | + function II(a,b,c,d,x,s,ac) { |
| 91 | + a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac)); |
| 92 | + return AddUnsigned(RotateLeft(a, s), b); |
| 93 | + }; |
| 94 | + |
| 95 | + function ConvertToWordArray(string) { |
| 96 | + var lWordCount; |
| 97 | + var lMessageLength = string.length; |
| 98 | + var lNumberOfWords_temp1=lMessageLength + 8; |
| 99 | + var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64; |
| 100 | + var lNumberOfWords = (lNumberOfWords_temp2+1)*16; |
| 101 | + var lWordArray=Array(lNumberOfWords-1); |
| 102 | + var lBytePosition = 0; |
| 103 | + var lByteCount = 0; |
| 104 | + while ( lByteCount < lMessageLength ) { |
| 105 | + lWordCount = (lByteCount-(lByteCount % 4))/4; |
| 106 | + lBytePosition = (lByteCount % 4)*8; |
| 107 | + lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount)<<lBytePosition)); |
| 108 | + lByteCount++; |
| 109 | + } |
| 110 | + lWordCount = (lByteCount-(lByteCount % 4))/4; |
| 111 | + lBytePosition = (lByteCount % 4)*8; |
| 112 | + lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80<<lBytePosition); |
| 113 | + lWordArray[lNumberOfWords-2] = lMessageLength<<3; |
| 114 | + lWordArray[lNumberOfWords-1] = lMessageLength>>>29; |
| 115 | + return lWordArray; |
| 116 | + }; |
| 117 | + |
| 118 | + function WordToHex(lValue) { |
| 119 | + var WordToHexValue="",WordToHexValue_temp="",lByte,lCount; |
| 120 | + for (lCount = 0;lCount<=3;lCount++) { |
| 121 | + lByte = (lValue>>>(lCount*8)) & 255; |
| 122 | + WordToHexValue_temp = "0" + lByte.toString(16); |
| 123 | + WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2); |
| 124 | + } |
| 125 | + return WordToHexValue; |
| 126 | + }; |
| 127 | + |
| 128 | + function Utf8Encode(string) { |
| 129 | + string = string.replace(/\r\n/g,"\n"); |
| 130 | + var utftext = ""; |
| 131 | + |
| 132 | + for (var n = 0; n < string.length; n++) { |
| 133 | + |
| 134 | + var c = string.charCodeAt(n); |
| 135 | + |
| 136 | + if (c < 128) { |
| 137 | + utftext += String.fromCharCode(c); |
| 138 | + } |
| 139 | + else if((c > 127) && (c < 2048)) { |
| 140 | + utftext += String.fromCharCode((c >> 6) | 192); |
| 141 | + utftext += String.fromCharCode((c & 63) | 128); |
| 142 | + } |
| 143 | + else { |
| 144 | + utftext += String.fromCharCode((c >> 12) | 224); |
| 145 | + utftext += String.fromCharCode(((c >> 6) & 63) | 128); |
| 146 | + utftext += String.fromCharCode((c & 63) | 128); |
| 147 | + } |
| 148 | + |
| 149 | + } |
| 150 | + |
| 151 | + return utftext; |
| 152 | + }; |
| 153 | + |
| 154 | + var x=Array(); |
| 155 | + var k,AA,BB,CC,DD,a,b,c,d; |
| 156 | + var S11=7, S12=12, S13=17, S14=22; |
| 157 | + var S21=5, S22=9 , S23=14, S24=20; |
| 158 | + var S31=4, S32=11, S33=16, S34=23; |
| 159 | + var S41=6, S42=10, S43=15, S44=21; |
| 160 | + |
| 161 | + string = Utf8Encode(string); |
| 162 | + |
| 163 | + x = ConvertToWordArray(string); |
| 164 | + |
| 165 | + a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476; |
| 166 | + |
| 167 | + for (k=0;k<x.length;k+=16) { |
| 168 | + AA=a; BB=b; CC=c; DD=d; |
| 169 | + a=FF(a,b,c,d,x[k+0], S11,0xD76AA478); |
| 170 | + d=FF(d,a,b,c,x[k+1], S12,0xE8C7B756); |
| 171 | + c=FF(c,d,a,b,x[k+2], S13,0x242070DB); |
| 172 | + b=FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE); |
| 173 | + a=FF(a,b,c,d,x[k+4], S11,0xF57C0FAF); |
| 174 | + d=FF(d,a,b,c,x[k+5], S12,0x4787C62A); |
| 175 | + c=FF(c,d,a,b,x[k+6], S13,0xA8304613); |
| 176 | + b=FF(b,c,d,a,x[k+7], S14,0xFD469501); |
| 177 | + a=FF(a,b,c,d,x[k+8], S11,0x698098D8); |
| 178 | + d=FF(d,a,b,c,x[k+9], S12,0x8B44F7AF); |
| 179 | + c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1); |
| 180 | + b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE); |
| 181 | + a=FF(a,b,c,d,x[k+12],S11,0x6B901122); |
| 182 | + d=FF(d,a,b,c,x[k+13],S12,0xFD987193); |
| 183 | + c=FF(c,d,a,b,x[k+14],S13,0xA679438E); |
| 184 | + b=FF(b,c,d,a,x[k+15],S14,0x49B40821); |
| 185 | + a=GG(a,b,c,d,x[k+1], S21,0xF61E2562); |
| 186 | + d=GG(d,a,b,c,x[k+6], S22,0xC040B340); |
| 187 | + c=GG(c,d,a,b,x[k+11],S23,0x265E5A51); |
| 188 | + b=GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA); |
| 189 | + a=GG(a,b,c,d,x[k+5], S21,0xD62F105D); |
| 190 | + d=GG(d,a,b,c,x[k+10],S22,0x2441453); |
| 191 | + c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681); |
| 192 | + b=GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8); |
| 193 | + a=GG(a,b,c,d,x[k+9], S21,0x21E1CDE6); |
| 194 | + d=GG(d,a,b,c,x[k+14],S22,0xC33707D6); |
| 195 | + c=GG(c,d,a,b,x[k+3], S23,0xF4D50D87); |
| 196 | + b=GG(b,c,d,a,x[k+8], S24,0x455A14ED); |
| 197 | + a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905); |
| 198 | + d=GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8); |
| 199 | + c=GG(c,d,a,b,x[k+7], S23,0x676F02D9); |
| 200 | + b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A); |
| 201 | + a=HH(a,b,c,d,x[k+5], S31,0xFFFA3942); |
| 202 | + d=HH(d,a,b,c,x[k+8], S32,0x8771F681); |
| 203 | + c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122); |
| 204 | + b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C); |
| 205 | + a=HH(a,b,c,d,x[k+1], S31,0xA4BEEA44); |
| 206 | + d=HH(d,a,b,c,x[k+4], S32,0x4BDECFA9); |
| 207 | + c=HH(c,d,a,b,x[k+7], S33,0xF6BB4B60); |
| 208 | + b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70); |
| 209 | + a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6); |
| 210 | + d=HH(d,a,b,c,x[k+0], S32,0xEAA127FA); |
| 211 | + c=HH(c,d,a,b,x[k+3], S33,0xD4EF3085); |
| 212 | + b=HH(b,c,d,a,x[k+6], S34,0x4881D05); |
| 213 | + a=HH(a,b,c,d,x[k+9], S31,0xD9D4D039); |
| 214 | + d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5); |
| 215 | + c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8); |
| 216 | + b=HH(b,c,d,a,x[k+2], S34,0xC4AC5665); |
| 217 | + a=II(a,b,c,d,x[k+0], S41,0xF4292244); |
| 218 | + d=II(d,a,b,c,x[k+7], S42,0x432AFF97); |
| 219 | + c=II(c,d,a,b,x[k+14],S43,0xAB9423A7); |
| 220 | + b=II(b,c,d,a,x[k+5], S44,0xFC93A039); |
| 221 | + a=II(a,b,c,d,x[k+12],S41,0x655B59C3); |
| 222 | + d=II(d,a,b,c,x[k+3], S42,0x8F0CCC92); |
| 223 | + c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D); |
| 224 | + b=II(b,c,d,a,x[k+1], S44,0x85845DD1); |
| 225 | + a=II(a,b,c,d,x[k+8], S41,0x6FA87E4F); |
| 226 | + d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0); |
| 227 | + c=II(c,d,a,b,x[k+6], S43,0xA3014314); |
| 228 | + b=II(b,c,d,a,x[k+13],S44,0x4E0811A1); |
| 229 | + a=II(a,b,c,d,x[k+4], S41,0xF7537E82); |
| 230 | + d=II(d,a,b,c,x[k+11],S42,0xBD3AF235); |
| 231 | + c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB); |
| 232 | + b=II(b,c,d,a,x[k+9], S44,0xEB86D391); |
| 233 | + a=AddUnsigned(a,AA); |
| 234 | + b=AddUnsigned(b,BB); |
| 235 | + c=AddUnsigned(c,CC); |
| 236 | + d=AddUnsigned(d,DD); |
| 237 | + } |
| 238 | + |
| 239 | + var temp = WordToHex(a)+WordToHex(b)+WordToHex(c)+WordToHex(d); |
| 240 | + |
| 241 | + return temp.toLowerCase(); |
| 242 | +} |
| 243 | + |
Property changes on: trunk/extensions/Wikidata/OmegaWiki/omegawiki-ajax.js |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 244 | + native |
Index: trunk/extensions/Wikidata/OmegaWiki/Editor.php |
— | — | @@ -983,7 +983,7 @@ |
984 | 984 | } |
985 | 985 | |
986 | 986 | // tries to get multiple "add" values e.g. adding multiple translations at once |
987 | | - // the "X-" corresponds to what is in suggest.js, function recursiveChangeId |
| 987 | + // the "X-" corresponds to what is in omegawiki-ajax.js, function recursiveChangeId |
988 | 988 | public function getAddValues( IdStack $idPath ) { |
989 | 989 | $addValues = array(); |
990 | 990 | $prefix = "add-" ; |