object 複製 テスト negotoy Follow 2017-10-06 17:10:20 License: MIT License Fork0 Fav0 View321 Play Stop Reload Fullscreen Smart Phone Readme JavaScript 81 lines HTML 6 lines CSS 41 lines object 複製 テスト object 複製 テスト (function(win,doc){ var assasin = function(a){ function copy(o, p){ for(var prop in o){ if(o[prop] !== null && (typeof o[prop] == 'object')){ copy(o[prop], p[prop] = ((o[prop] instanceof Array) === true) ? [] : {}); } else{ p[prop] = o[prop]; } } return p; } return copy(a, ((a instanceof Array) === true) ? [] : {}); }; var check = function(a){ function copy(o){ for(var prop in o){ if(o[prop] !== null && (typeof o[prop] == 'object')){ copy(o[prop]); } else{ o[prop] = 0; } } return o; } return copy(a); }; win.addEventListener("load",function(){ var data = [ [undefined,1,{aa:undefined,bb:20},[10,23],{ cc:30,dd:[0,1,2]},[100,200,[1000,2000]]], {aa :100,bb : 200, cc : [1,2,3,{dd : 'd0', ee : 'e0', ff : [10,20,{gg : 'g0', hh : 'h0'},30], ii : 'i0'}, 4]}, [{"display":true,"name":"layer-00","item":[{"fill":"rgb(0, 0, 0)","fill-rule":"nonzero","stroke":"rgb(255, 255, 255)","stroke-width":2,"stroke-miterlimit":4,"stroke-linecap":"butt","stroke-linejoin":"miter","stroke-dasharray":"","z":false,"fill-active":false,"fill-display":false,"stroke-active":true,"stroke-display":true,"d":[125.5,-102,197.5,-126,195.5,1,170.5,-27]},{"fill":"rgb(0, 0, 0)","fill-rule":"nonzero","stroke":"rgb(255, 255, 255)","stroke-width":2,"stroke-miterlimit":4,"stroke-linecap":"butt","stroke-linejoin":"miter","stroke-dasharray":"","z":false,"fill-active":false,"fill-display":false,"stroke-active":true,"stroke-display":true,"d":[237.5,-98,268.5,-59,225.5,20,282.5,-97]},{"fill":"rgb(0, 0, 0)","fill-rule":"nonzero","stroke":"rgb(255, 255, 255)","stroke-width":2,"stroke-miterlimit":4,"stroke-linecap":"butt","stroke-linejoin":"miter","stroke-dasharray":"","z":false,"fill-active":false,"fill-display":false,"stroke-active":true,"stroke-display":true,"d":[237.5,-98,268.5,-59,225.5,20,282.5,-97]},{"fill":"rgb(0, 0, 0)","fill-rule":"nonzero","stroke":"rgb(255, 255, 255)","stroke-width":2,"stroke-miterlimit":4,"stroke-linecap":"butt","stroke-linejoin":"miter","stroke-dasharray":"","z":false,"fill-active":false,"fill-display":false,"stroke-active":true,"stroke-display":true,"d":[244.5,-202,155.5,-202,61.5,-167,93.5,-138]},{"fill":"rgb(0, 0, 0)","fill-rule":"nonzero","stroke":"rgb(255, 255, 255)","stroke-width":2,"stroke-miterlimit":4,"stroke-linecap":"butt","stroke-linejoin":"miter","stroke-dasharray":"","z":false,"fill-active":false,"fill-display":false,"stroke-active":true,"stroke-display":true,"d":[-108.5,-54,-79.5,-127,14.5,-57,-88.5,33]}]},{"display":true,"name":"layer-00","item":[{"fill":"rgb(0, 0, 0)","fill-rule":"nonzero","stroke":"rgb(255, 255, 255)","stroke-width":2,"stroke-miterlimit":4,"stroke-linecap":"butt","stroke-linejoin":"miter","stroke-dasharray":"","z":false,"fill-active":false,"fill-display":false,"stroke-active":true,"stroke-display":true,"d":[125.5,-102,197.5,-126,195.5,1,170.5,-27]},{"fill":"rgb(0, 0, 0)","fill-rule":"nonzero","stroke":"rgb(255, 255, 255)","stroke-width":2,"stroke-miterlimit":4,"stroke-linecap":"butt","stroke-linejoin":"miter","stroke-dasharray":"","z":false,"fill-active":false,"fill-display":false,"stroke-active":true,"stroke-display":true,"d":[237.5,-98,268.5,-59,225.5,20,282.5,-97]},{"fill":"rgb(0, 0, 0)","fill-rule":"nonzero","stroke":"rgb(255, 255, 255)","stroke-width":2,"stroke-miterlimit":4,"stroke-linecap":"butt","stroke-linejoin":"miter","stroke-dasharray":"","z":false,"fill-active":false,"fill-display":false,"stroke-active":true,"stroke-display":true,"d":[237.5,-98,268.5,-59,225.5,20,282.5,-97]}]}] ]; var textarea = doc.getElementsByTagName('textarea')[0]; var input = doc.getElementsByTagName('input'); var select = doc.getElementsByTagName('select')[0]; select.addEventListener('change', function(){ var j = JSON.stringify(data[this.selectedIndex]); var a = assasin(data[this.selectedIndex]); var r = '[ JSON.stringify ]\n' + j + '\n\n\n[ asassin ]\n' + JSON.stringify(a); textarea.value = r; console.log(a); }, false); input[1].addEventListener('click', function(){ var val = input[0].value; var k, b, s; try{ val = JSON.parse(val); } catch(e){ console.log(e); return; } k = JSON.stringify(val); b = assasin(val); s = JSON.stringify(b); s= '[ JSON.stringify ]\n' + k + '\n\n\n[ asassin ]\n' + s; textarea.value = s; console.log('check[1]=',val); val = check(val); console.log('check[2]=',val); console.log('check[3]=',b); }, false); input[0].addEventListener('focus', function(){ textarea.value = ''; }, false); }, false);//onload })(window,document); <div> <p> object 複製 テスト</p> data : <select><option>1</option><option>2</option><option>3</option></select> <input type="text" style=""><input type="button" value="try"><br> <textarea style=""></textarea> </div> object 複製 テスト body{ background-color:white; } *{ padding:0; margin:0; box-sizing:border-box; font-family:Consolas; } div{ width:400px; height:auto; padding:10px; margin:auto; color:white; background-color:black; } p{ font-size:16px; color:white; } input[type="text"]{ width:300px; font-family:Consolas; } input[type="button"]{ wdith:50px; padding:2px 5px; margin:0px 0px 0px 10px; font-family:Consolas; } textarea{ width:100%; height:250px; display:block; font-family:Consolas; font-size:12px; margin:10px 0px 0px 0px; min-height:100px; resize:vertical; } object 複製 テスト (function(win,doc){ var assasin = function(a){ function copy(o, p){ for(var prop in o){ if(o[prop] !== null && (typeof o[prop] == 'object')){ copy(o[prop], p[prop] = ((o[prop] instanceof Array) === true) ? [] : {}); } else{ p[prop] = o[prop]; } } return p; } return copy(a, ((a instanceof Array) === true) ? [] : {}); }; var check = function(a){ function copy(o){ for(var prop in o){ if(o[prop] !== null && (typeof o[prop] == 'object')){ copy(o[prop]); } else{ o[prop] = 0; } } return o; } return copy(a); }; win.addEventListener("load",function(){ var data = [ [undefined,1,{aa:undefined,bb:20},[10,23],{ cc:30,dd:[0,1,2]},[100,200,[1000,2000]]], {aa :100,bb : 200, cc : [1,2,3,{dd : 'd0', ee : 'e0', ff : [10,20,{gg : 'g0', hh : 'h0'},30], ii : 'i0'}, 4]}, [{"display":true,"name":"layer-00","item":[{"fill":"rgb(0, 0, 0)","fill-rule":"nonzero","stroke":"rgb(255, 255, 255)","stroke-width":2,"stroke-miterlimit":4,"stroke-linecap":"butt","stroke-linejoin":"miter","stroke-dasharray":"","z":false,"fill-active":false,"fill-display":false,"stroke-active":true,"stroke-display":true,"d":[125.5,-102,197.5,-126,195.5,1,170.5,-27]},{"fill":"rgb(0, 0, 0)","fill-rule":"nonzero","stroke":"rgb(255, 255, 255)","stroke-width":2,"stroke-miterlimit":4,"stroke-linecap":"butt","stroke-linejoin":"miter","stroke-dasharray":"","z":false,"fill-active":false,"fill-display":false,"stroke-active":true,"stroke-display":true,"d":[237.5,-98,268.5,-59,225.5,20,282.5,-97]},{"fill":"rgb(0, 0, 0)","fill-rule":"nonzero","stroke":"rgb(255, 255, 255)","stroke-width":2,"stroke-miterlimit":4,"stroke-linecap":"butt","stroke-linejoin":"miter","stroke-dasharray":"","z":false,"fill-active":false,"fill-display":false,"stroke-active":true,"stroke-display":true,"d":[237.5,-98,268.5,-59,225.5,20,282.5,-97]},{"fill":"rgb(0, 0, 0)","fill-rule":"nonzero","stroke":"rgb(255, 255, 255)","stroke-width":2,"stroke-miterlimit":4,"stroke-linecap":"butt","stroke-linejoin":"miter","stroke-dasharray":"","z":false,"fill-active":false,"fill-display":false,"stroke-active":true,"stroke-display":true,"d":[244.5,-202,155.5,-202,61.5,-167,93.5,-138]},{"fill":"rgb(0, 0, 0)","fill-rule":"nonzero","stroke":"rgb(255, 255, 255)","stroke-width":2,"stroke-miterlimit":4,"stroke-linecap":"butt","stroke-linejoin":"miter","stroke-dasharray":"","z":false,"fill-active":false,"fill-display":false,"stroke-active":true,"stroke-display":true,"d":[-108.5,-54,-79.5,-127,14.5,-57,-88.5,33]}]},{"display":true,"name":"layer-00","item":[{"fill":"rgb(0, 0, 0)","fill-rule":"nonzero","stroke":"rgb(255, 255, 255)","stroke-width":2,"stroke-miterlimit":4,"stroke-linecap":"butt","stroke-linejoin":"miter","stroke-dasharray":"","z":false,"fill-active":false,"fill-display":false,"stroke-active":true,"stroke-display":true,"d":[125.5,-102,197.5,-126,195.5,1,170.5,-27]},{"fill":"rgb(0, 0, 0)","fill-rule":"nonzero","stroke":"rgb(255, 255, 255)","stroke-width":2,"stroke-miterlimit":4,"stroke-linecap":"butt","stroke-linejoin":"miter","stroke-dasharray":"","z":false,"fill-active":false,"fill-display":false,"stroke-active":true,"stroke-display":true,"d":[237.5,-98,268.5,-59,225.5,20,282.5,-97]},{"fill":"rgb(0, 0, 0)","fill-rule":"nonzero","stroke":"rgb(255, 255, 255)","stroke-width":2,"stroke-miterlimit":4,"stroke-linecap":"butt","stroke-linejoin":"miter","stroke-dasharray":"","z":false,"fill-active":false,"fill-display":false,"stroke-active":true,"stroke-display":true,"d":[237.5,-98,268.5,-59,225.5,20,282.5,-97]}]}] ]; var textarea = doc.getElementsByTagName('textarea')[0]; var input = doc.getElementsByTagName('input'); var select = doc.getElementsByTagName('select')[0]; select.addEventListener('change', function(){ var j = JSON.stringify(data[this.selectedIndex]); var a = assasin(data[this.selectedIndex]); var r = '[ JSON.stringify ]\n' + j + '\n\n\n[ asassin ]\n' + JSON.stringify(a); textarea.value = r; console.log(a); }, false); input[1].addEventListener('click', function(){ var val = input[0].value; var k, b, s; try{ val = JSON.parse(val); } catch(e){ console.log(e); return; } k = JSON.stringify(val); b = assasin(val); s = JSON.stringify(b); s= '[ JSON.stringify ]\n' + k + '\n\n\n[ asassin ]\n' + s; textarea.value = s; console.log('check[1]=',val); val = check(val); console.log('check[2]=',val); console.log('check[3]=',b); }, false); input[0].addEventListener('focus', function(){ textarea.value = ''; }, false); }, false);//onload })(window,document); <div> <p> object 複製 テスト</p> data : <select><option>1</option><option>2</option><option>3</option></select> <input type="text" style=""><input type="button" value="try"><br> <textarea style=""></textarea> </div> body{ background-color:white; } *{ padding:0; margin:0; box-sizing:border-box; font-family:Consolas; } div{ width:400px; height:auto; padding:10px; margin:auto; color:white; background-color:black; } p{ font-size:16px; color:white; } input[type="text"]{ width:300px; font-family:Consolas; } input[type="button"]{ wdith:50px; padding:2px 5px; margin:0px 0px 0px 10px; font-family:Consolas; } textarea{ width:100%; height:250px; display:block; font-family:Consolas; font-size:12px; margin:10px 0px 0px 0px; min-height:100px; resize:vertical; } use an iframe compat browser, deer Play on jsdo.it games Author Share ブログに埋め込む QR Tag Download Complete! Description What kind of game? object 複製 テスト Control Device Smartphone Controllerjsdo.it WebSocket Controller» Mouse Keyboard Touch Device Fullscreen Activated Inactivated jsdo.it games から削除する Submit Author negotoy URLhttp://mathematics.namekuji.jp/index.html Tweet Default Panel Auto play Screenshot Readme JavaScript HTML CSS Size Width: px Height: px code <script type="text/javascript" src="http://jsdo.it/blogparts/0v6B/js"></script> clone copy javascript library&test object test Discussion Questions on this code? Tags clone copy javascript library&test object test