Added quick and dirty URL param source loader
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@979 eee81c28-f429-11dd-99c0-75d572ba1dddmaster
parent
2653ebdaad
commit
ac19a9fe15
|
@ -2092,7 +2092,12 @@ function svg_edit_setup() {
|
|||
// var revnums = "svg-editor.js ($Rev$) ";
|
||||
// revnums += svgCanvas.getVersion();
|
||||
// $('#copyright')[0].setAttribute("title", revnums);
|
||||
|
||||
var loc = document.location.href;
|
||||
if(loc.indexOf('?source=') != -1) {
|
||||
var pre = '?source=data:image/svg+xml;base64,';
|
||||
var src = loc.substring(loc.indexOf(pre) + pre.length);
|
||||
svgCanvas.setSvgString(Utils.decode64(src));
|
||||
}
|
||||
return svgCanvas;
|
||||
};
|
||||
|
||||
|
|
|
@ -5994,6 +5994,39 @@ var Utils = {
|
|||
return output.join('');
|
||||
},
|
||||
|
||||
"decode64" : function(input) {
|
||||
if(window.atob) return window.atob(input);
|
||||
var output = new StringMaker();
|
||||
var chr1, chr2, chr3;
|
||||
var enc1, enc2, enc3, enc4;
|
||||
var i = 0;
|
||||
|
||||
// remove all characters that are not A-Z, a-z, 0-9, +, /, or =
|
||||
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
|
||||
|
||||
while (i < input.length) {
|
||||
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.append(String.fromCharCode(chr1));
|
||||
|
||||
if (enc3 != 64) {
|
||||
output.append(String.fromCharCode(chr2));
|
||||
}
|
||||
if (enc4 != 64) {
|
||||
output.append(String.fromCharCode(chr3));
|
||||
}
|
||||
}
|
||||
|
||||
return output.toString();
|
||||
},
|
||||
|
||||
// based on http://phpjs.org/functions/utf8_encode:577
|
||||
// codedread:does not seem to work with webkit-based browsers on OSX
|
||||
"encodeUTF8": function(input) {
|
||||
|
|
Loading…
Reference in New Issue