Guest Russ V Posted May 4, 2010 Share Posted May 4, 2010 Right now I am trying to figure out why its only opening a blank window and not displaying the select text that is translated into base64. It's just blank. Any help is appreciated I dont know where else to go to get help. I am currently using Google Chrome.Is there something wrong or am I using something not supported by chrome? javascript : var input = document.selection?document.selection.createRange().text : window.getSelection().toString();if (!input) { input = prompt("Input text to convert:", "");}if (input != null) { var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";}var output = "";var chr1, chr2, chr3, enc1, enc2, enc3, enc;var i = 0;input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");do{ enc1 = keyStr.indexOf(input.charAt(i++)); enc2 = keyStr.indexOf(input.charAt(i++)); enc3 = keyStr.indexOf(input.charAt(i++)); enc4 = keyStr.indexOf(input.charAt(i++)); chr1 = (enc1 << 2) | (enc2 >> 4); chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); chr3 = ((enc3 & 3) << 6) | enc4; output = output + String.fromCharCode(chr1); if (enc3 != 64) { output = output + String.fromCharCode(chr2); } if (enc4 != 64) { output = output + String.fromCharCode(chr3); }}while (i < input.length);void 0; msgWindow = window.open("", "", "location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width=547,height=442");msgWindow.document.write(output);return; This a example of what I would like it to do just cant figure this out. The example is a rot13 version that changes any text you have selected into rot13 and back w/o the popup window of course. javascript : var coding = "abcdefghijklmnopqrstuvwxyzabcdefghijklmABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLM";function rot13(t) { for (var r = "", i = 0; i < t.length; i++) { character = t.charAt(i); position = coding.indexOf(character); if (position > - 1) { character = coding.charAt(position + 13); } r += character; } return r;}S = window.getSelection();function t(N) { return N.nodeType == N.TEXT_NODE;}function r(N) { if (t(N)) { N.data = rot13(N.data); }}for (j = 0; j < S.rangeCount; ++j) { var g = S.getRangeAt(j), e = g.startContainer, f = g.endContainer, E = g.startOffset, F = g.endOffset, m = (e == f); if (!m || !t(e)) { /* rot13 each text node between e and f, not including e and f. */ q = document.createTreeWalker(g.commonAncestorContainer, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT, null, false); q.currentNode = e; for (N = q.nextNode(); N && N != f; N = q.nextNode()) { r(N); } } if (t(f)) { f.splitText(F); } if (!m) { r(f); } if (t(e)) { r(k = e.splitText(E)); if (m) { f = k; } e = k; } if (t(f)) { g.setEnd(f, f.data.length); }}void 0 Link to comment Share on other sites More sharing options...
justsomeguy Posted May 10, 2010 Share Posted May 10, 2010 If there was an error you would be seeing an error message, are you seeing anything like that in the error console? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.