Editing test This edit will create a new revision. Your details (optional) Name Email (won’t be displayed; might be used for Gravatar) URL Test case details Title * Published (uncheck if you want to fiddle around before making the page public) Description (in case you feel further explanation is needed)(Markdown syntax is allowed) Are you a spammer? (just answer the question) Preparation code Preparation code HTML (this will be inserted in the <body> of a valid HTML5 document in standards mode) (useful when testing DOM operations or including libraries) <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"> </script> Include JavaScript libraries as follows: <script src="//cdn.ext/library.js"></script> Define setup for all tests (variables, functions, arrays or other objects that will be used in the tests) (runs before each clocked test loop, outside of the timed code region) (e.g. define local test variables, reset global variables, clear canvas, etc.) (see FAQ) Define teardown for all tests (runs after each clocked test loop, outside of the timed code region) (see FAQ) Code snippets to compare Test 1 Title Async (check if this is an asynchronous test) Code //jquery.upload (function(b){function m(e){return b.map(n(e),function(d){return'<input type="hidden" name="'+d.name+'" value="'+d.value+'"/>'}).join("")}function n(e){function d(c,f){a.push({name:c,value:f})}if(b.isArray(e))return e;var a=[];if(typeof e==="object")b.each(e,function(c){b.isArray(this)?b.each(this,function(){d(c,this)}):d(c,b.isFunction(this)?this():this)});else typeof e==="string"&&b.each(e.split("&"),function(){var c=b.map(this.split("="),function(f){return decodeURIComponent(f.replace(/\+/g," "))}); d(c[0],c[1])});return a}function o(e,d){var a;a=b(e).contents().get(0);if(b.isXMLDoc(a)||a.XMLDocument)return a.XMLDocument||a;a=b(a).find("body").html();switch(d){case "xml":a=a;if(window.DOMParser)a=(new DOMParser).parseFromString(a,"application/xml");else{var c=new ActiveXObject("Microsoft.XMLDOM");c.async=false;c.loadXML(a);a=c}break;case "json":a=window.eval("("+a+")");break}return a}var p=0;b.fn.upload=function(e,d,a,c){var f=this,g,j,h;h="jquery_upload"+ ++p;var k=b('<iframe name="'+h+'" style="position:absolute;top:-9999px" />').appendTo("body"), i='<form target="'+h+'" method="post" enctype="multipart/form-data" />';if(b.isFunction(d)){c=a;a=d;d={}}j=b("input:checkbox",this);h=b("input:checked",this);i=f.wrapAll(i).parent("form").attr("action",e);j.removeAttr("checked");h.attr("checked",true);g=(g=m(d))?b(g).appendTo(i):null;i.submit(function(){k.load(function(){var l=o(this,c),q=b("input:checked",f);i.after(f).remove();j.removeAttr("checked");q.attr("checked",true);g&&g.remove();setTimeout(function(){k.remove();c==="script"&&b.globalEval(l); a&&a.call(f,l)},0)})}).submit();return this}})(jQuery); //CodeIgniter Profiler var ciProfiler = function() { if ($('#codeigniter_profiler').length > 0) { var prof = $('<div>', { id: 'profiler', html: $('<img>', { height: 43, width: 154, alt: 'Toggle Profiler', title: 'Toggle Profiler', src: 'http://' + baseUrl + '/files/img/nav_toggle_darker.jpg' }), click: function() { $('#codeigniter_profiler').slideToggle(); } }); $('body').prepend(prof); $('body').prepend($('#codeigniter_profiler')); $('#codeigniter_profiler').css('display', 'none'); $('#codeigniter_profiler').css('font-size', '80%'); } } jQuery(function($) { //ログ収集用のトラッキングデータ var repTrack = repTrack || {}; repTrack = { ua: $('#ua').val(), ip: $('#ip').val() } baseUrl = location.host; ajax = $('#ajax').text(); //CodeIgniter Profiler ciProfiler(); //Object Cache //estate_edit_navigation var estate_edit_nav = $('div#estate_edit_nav li').find('a'); var estate_edit_areas = $('div#estate_edit_area ul'); //address var zip1 = $('#standard_zip1'); var zip2 = $('#standard_zip2'); var pref_list = $('#standard_pref'); var area_list = $('#standard_target_area_id'); var address1_list = $('#standard_address1'); var address2_list = $('#standard_address2'); //プラグイン完成まで暫定対応 //select traffic $('input[name^="data\[traffic\]\[access_type"]').change(function() { var target = $('#' + $(this).attr('target')); var n = $(target).siblings(); if (!target.hasClass('show')) { target.removeClass('hide').addClass('show'); n.removeClass('show').addClass('hide'); } else { target.removeClass('show').addClass('hide'); n.removeClass('hide').addClass('show'); } }); //estate_edit Default Value Setting //address //管理画面で使う操作をプラグイン化する //jQuery(function($){ つまり document.readyで始めてインスタンス化されるようにする (function($) { //estate_edit_navigation estate_edit_nav.click(function() { var estate_edit_nav_selected = $('div#estate_edit_nav li').find('a.selected'); var estate_edit_nav_old_target = $(estate_edit_areas).find('li#' + estate_edit_nav_selected.attr('target_area')); var estate_edit_nav_new_target = $(estate_edit_areas).find('li#' + $(this).attr('target_area')); if ($(this) != estate_edit_nav_selected) { estate_edit_nav_selected.removeClass('selected'); estate_edit_nav_old_target.css('display', 'none'); $(this).addClass('selected'); estate_edit_nav_new_target.fadeIn('fast'); } }); //loading var loading = { start: function(ele) { $(ele).after('<img src="http://' + baseUrl + '/files/img/loading.gif" />'); }, stop: function(ele) { $(ele).next().remove(); } } //物件登録イベント //zipcode $('#ajax_zipaddress').click(function() { var zipcode = zip1.val() + zip2.val(); if (zipcode.length != 7) { alert('郵便番号は7桁で入力してください') } else { var pref, area; $.post( ajax + 'get_pref_area_with_zipcode/', {zipcode: zipcode}, function(data) { var json = JSON.parse(data); pref = json[0].pref; area = json[0].area_id; //set pref $(pref_list).find('option[value="' + pref + '"]').attr('selected', 'selected'); $.post( ajax + 'get_area_list_with_zipcode/', {zipcode: zipcode}, function(data) { var json = JSON.parse(data); var optionItems = ''; for (i in json) { if (json[i].id != area) { optionItems += '<option value="' + json[i].id + '">' + json[i].name + '</option>'; } else { optionItems += '<option value="' + json[i].id + '" selected="selected">' + json[i].name + '</option>'; } } //set area $(area_list).html(optionItems); } ); $.post( ajax + 'get_address1_with_areaid/', {area_id: area}, function(data) { var json = JSON.parse(data); var optionItems = ''; for (i in json) { if (json[i].cd3 != zipcode) { optionItems += '<option value="' + json[i].address1 + '">' + json[i].address1 + '</option>'; } else { optionItems += '<option value="' + json[i].address1 + '" selected="selected">' + json[i].address1 + '</option>'; } } //set address1 $(address1_list).html(optionItems); $.post( ajax + 'get_address2_with_area_address1/', { area: $(area_list).find('option:selected').text(), address1: $(address1_list).find('option:selected').val() }, function(data) { var json = JSON.parse(data); var optionItems = ''; for (i in json) { if (json[i].cd3 != zipcode) { optionItems += '<option value="' + json[i].address2 + '">' + json[i].address2 + '</option>'; } else { optionItems += '<option value="' + json[i].address2 + '" selected="selected">' + json[i].address1 + '</option>'; } } //set address2 $(address2_list).html(optionItems); } ); } ); } ); } }); //bind event for select pref $(pref_list).live('change', function() { var pref = $(this).val(); $.post( ajax + 'get_area_list_with_pref/', {pref: pref}, function(data) { var json = JSON.parse(data); //var optionItems = new Array(); var optionItems = ''; for (i in json) { optionItems += '<option value="' + json[i].id + '">' + json[i].name + '</option>'; } //set area $(area_list).html(optionItems); $(zip1).val(''); $(zip2).val(''); $(address1_list).html(''); $(address2_list).html(''); } ); }); //bind event for select area $(area_list).live('change', function() { var area = $(this).val(); $.post( ajax + 'get_address1_with_areaid/', {area_id: area}, function(data) { var json = JSON.parse(data); var optionItems = ''; for (i in json) { optionItems += '<option value="' + json[i].address1 + '">' + json[i].address1 + '</option>'; } //set address1 $(address1_list).html(optionItems); $(zip1).val(''); $(zip2).val(''); $(address2_list).html(''); } ); }); //bind event for select address1 $(address1_list).live('change', function() { var area = $(this).val(); $.post( ajax + 'get_address2_with_area_address1/', { area: $(area_list).find('option:selected').text(), address1: $(address1_list).find('option:selected').val() }, function(data) { var json = JSON.parse(data); var optionItems = ''; for (i in json) { optionItems += '<option value="' + json[i].address2 + '">' + json[i].address2 + '</option>'; } //set address2 $(address2_list).html(optionItems); $(zip1).val(''); $(zip2).val(''); } ); }); })(jQuery); }); Test 2 Title Async (check if this is an asynchronous test) Code <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"> </script>