' + line.title + '
'; outputHtml += '価格 ' + line.life + '万円
'; outputHtml += '年式: ' + line.nen + '
'; outputHtml += '走行: 約 ' + line.soukou + 'km
'; outputHtml += '$(function() {
/*================================================================
情報
================================================================*/
var allList = [
{
id: "1941",
life: "86.8",
url:"index.php?act=staff&id=1941",
img:"user_data/11065.jpg",
nen:"平成28年式",
soukou:"56004",
title:"【カ単禁】ハイゼットカーゴ2シーター白576",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "1942",
life: "98.8",
url:"index.php?act=staff&id=1942",
img:"user_data/11744.jpg",
nen:"平成29年式",
soukou:"49589",
title:"【カ単禁】キャリィトラック4WD KC銀570",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "1944",
life: "128.8",
url:"index.php?act=staff&id=1944",
img:"user_data/11089.jpg",
nen:"平成19年式",
soukou:"54563",
title:"【あ単楽】バネットGL 0.85トンWタイヤ3ニン軽油323",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "1954",
life: "98.8",
url:"index.php?act=staff&id=1954",
img:"user_data/11894.jpg",
nen:"平成29年式",
soukou:"8828",
title:"【ニ単禁】ハイゼットTスタンダード白575",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "1959",
life: "118.8",
url:"index.php?act=staff&id=1959",
img:"user_data/11197.jpg",
nen:"平成26年式",
soukou:"64394",
title:"【あ単楽】ボンゴバンDXワイドロー白331",
sold:"",
new:"",
tag: ["","販売中","MT","",""],
description: "tesut"
},
{
id: "1960",
life: "138.8",
url:"index.php?act=staff&id=1960",
img:"user_data/11199.jpg",
nen:"平成27年式",
soukou:"52804",
title:"【カ単禁】トヨタライトエースV白334",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "1963",
life: "118.8",
url:"index.php?act=staff&id=1963",
img:"user_data/11131.jpg",
nen:"平成27年式",
soukou:"74052",
title:"【カ単禁】NV200バネットバンDX白324",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "1964",
life: "68.8",
url:"index.php?act=staff&id=1964",
img:"user_data/12397.jpg",
nen:"平成25年式",
soukou:"65718",
title:"【あ単楽】ニッサンAD DX白332",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "1965",
life: "118.8",
url:"index.php?act=staff&id=1965",
img:"user_data/11179.jpg",
nen:"平成29年式",
soukou:"20372",
title:"【ニ単禁】ニッサンNV150ADVE336",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "1966",
life: "83.8",
url:"index.php?act=staff&id=1966",
img:"user_data/12240.jpg",
nen:"平成29年式",
soukou:"52710",
title:"【カ単禁】ハイゼットカーゴDX銀574",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "1967",
life: "93.8",
url:"index.php?act=staff&id=1967",
img:"user_data/11766.jpg",
nen:"平成28年式",
soukou:"34014",
title:"【カ単禁】NT100クリッパーTDX白577",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "1968",
life: "118.8",
url:"index.php?act=staff&id=1968",
img:"user_data/11134.jpg",
nen:"平成24年式",
soukou:"65095",
title:"【あ単楽】トヨタダイナ平ボディガソリン333",
sold:"",
new:"",
tag: ["","販売中","MT","",""],
description: "tesut"
},
{
id: "1971",
life: "108.8",
url:"index.php?act=staff&id=1971",
img:"user_data/11091.jpg",
nen:"平成29年式",
soukou:"33747",
title:"【カ単禁】トヨタプロボックスGL白326",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "1972",
life: "148.8",
url:"index.php?act=staff&id=1972",
img:"user_data/12092.jpg",
nen:"平成29年式",
soukou:"62875",
title:"【カ単禁】トヨタタウンエースDX330 ",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "1981",
life: "79.8",
url:"index.php?act=staff&id=1981",
img:"user_data/11196.jpg",
nen:"平成26年式",
soukou:"74300",
title:"【あ単楽】ハイゼットカーゴ白578",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "1982",
life: "94.8",
url:"index.php?act=staff&id=1982",
img:"user_data/11180.jpg",
nen:"平成30年式",
soukou:"52231",
title:"【カ単禁】ハイゼットカーゴスペシャル白584",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "1984",
life: "118.8",
url:"index.php?act=staff&id=1984",
img:"user_data/11150.jpg",
nen:"平成30年式",
soukou:"58977",
title:"【ニ単禁】ニッサンNV150_AD VE白329",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "1985",
life: "84.8",
url:"index.php?act=staff&id=1985",
img:"user_data/11152.jpg",
nen:"平成30年式",
soukou:"47012",
title:"【カ単禁】ハイゼットカーゴ2シーター白587",
sold:"",
new:"",
tag: ["","販売中","MT","",""],
description: "tesut"
},
{
id: "1986",
life: "148.8",
url:"index.php?act=staff&id=1986",
img:"user_data/11151.jpg",
nen:"平成27年式",
soukou:"58866",
title:"【カ単禁】ニッサンバネットトラック白325",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "1987",
life: "83.8",
url:"index.php?act=staff&id=1987",
img:"user_data/12688.jpg",
nen:"平成29年式",
soukou:"56891",
title:"【ニ単禁】スズキエブリィPAハイルーフ白573",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "1988",
life: "84.8",
url:"index.php?act=staff&id=1988",
img:"user_data/11198.jpg",
nen:"平成28年式",
soukou:"51771",
title:"【カ単禁】ハイゼットカーゴスペシャル白586",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "1990",
life: "88.8",
url:"index.php?act=staff&id=1990",
img:"user_data/11146.jpg",
nen:"平成28年式",
soukou:"37866",
title:"【カ単禁】スズキエブリィPA白588",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "1997",
life: "98.8",
url:"index.php?act=staff&id=1997",
img:"user_data/12638.jpg",
nen:"平成29年式",
soukou:"11791",
title:"【カ単禁】ピクシスバンクルーズターボ銀585",
sold:" 価格 ' + line.life + '万円 年式: ' + line.nen + ' 走行: 約 ' + line.soukou + 'km",
new:"",
tag: ["","","","AT","売り切れ"],
description: "tesut"
},
{
id: "1999",
life: "69.8",
url:"index.php?act=staff&id=1999",
img:"user_data/11154.jpg",
nen:"平成30年式",
soukou:"107335",
title:"【一日車検】ダイハツハイゼットカーゴ銀599",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "2000",
life: "108.8",
url:"index.php?act=staff&id=2000",
img:"user_data/11161.jpg",
nen:"平成21年式",
soukou:"67331",
title:"【あ単レ】タイタンダッシュ Wキャブ",
sold:"",
new:"",
tag: ["","販売中","MT","",""],
description: "tesut"
},
{
id: "2001",
life: "69.8",
url:"index.php?act=staff&id=2001",
img:"user_data/11163.jpg",
nen:"平成29年式",
soukou:"143280",
title:"【あ単レ】トヨタサクシードUL337",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "2002",
life: "84.8",
url:"index.php?act=staff&id=2002",
img:"user_data/11781.jpg",
nen:"平成25年式",
soukou:"18550",
title:"【あ単レ】スズキキャリィトラック4WD白600",
sold:"",
new:"",
tag: ["","販売中","MT","",""],
description: "tesut"
},
{
id: "2003",
life: "94.8",
url:"index.php?act=staff&id=2003",
img:"user_data/11168.jpg",
nen:"平成29年式",
soukou:"38298",
title:"【あ単レ】マツダスクラムPA白590",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "2004",
life: "104.8",
url:"index.php?act=staff&id=2004",
img:"user_data/11204.jpg",
nen:"平成29年式",
soukou:"9618",
title:"【あ単レ】ニッサンNV100クリッパーDX銀602",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "2005",
life: "104.8",
url:"index.php?act=staff&id=2005",
img:"user_data/11194.jpg",
nen:"平成29年式",
soukou:"7337",
title:"【あ単レ】ニッサンNV100クリッパーDX銀601",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "2012",
life: "88.8",
url:"index.php?act=staff&id=2012",
img:"user_data/11206.jpg",
nen:"平成26年式",
soukou:"16890",
title:"【あ単】スズキキャリィトラック4WD",
sold:"",
new:"",
tag: ["","販売中","MT","",""],
description: "tesut"
},
{
id: "2013",
life: "78.8",
url:"index.php?act=staff&id=2013",
img:"user_data/11207.jpg",
nen:"平成26年式",
soukou:"33730",
title:"【あ単】スズキキャリィトラック4WD",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "2014",
life: "78.8",
url:"index.php?act=staff&id=2014",
img:"user_data/11208.jpg",
nen:"平成28年式",
soukou:"64303",
title:"【あ単】ハイゼットカーゴ白",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "2017",
life: "88.8",
url:"index.php?act=staff&id=2017",
img:"user_data/12844.jpg",
nen:"平成28年式",
soukou:"78803",
title:"【あ単】ダイハツハイゼットキャディD SA2",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "2018",
life: "58.8",
url:"index.php?act=staff&id=2018",
img:"user_data/12846.jpg",
nen:"平成27年式",
soukou:"73752",
title:"【あ単】ニッサンADバンVE白344",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "2020",
life: "118.8",
url:"index.php?act=staff&id=2020",
img:"user_data/12843.jpg",
nen:"平成24年式",
soukou:"62608",
title:"【あ単】NV200バネットチャキャブスロープタイプ白92",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "2037",
life: "74.8",
url:"index.php?act=staff&id=2037",
img:"user_data/12959.jpg",
nen:"平成26年式",
soukou:"58998",
title:"【あ単】ハイゼットカーゴDX4WD銀611",
sold:"",
new:"",
tag: ["","販売中","MT","",""],
description: "tesut"
},
{
id: "1515",
life: "58.8",
url:"index.php?act=staff&id=1515",
img:"user_data/10013.jpg",
nen:"平成28年式",
soukou:"69526",
title:"【カ単禁】ニッサンADバンVE白274",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "1356",
life: "148.8",
url:"index.php?act=staff&id=1356",
img:"user_data/9346.jpg",
nen:"令和3年式",
soukou:"10196",
title:"【カ】ミツビシミニキャブバン448【価格改定】",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "1187",
life: "88.8",
url:"index.php?act=staff&id=1187",
img:"user_data/7735.jpg",
nen:"平成29年式",
soukou:"23233",
title:"【カ単禁】ダイハツハイゼットTエクストラ412",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "1111",
life: "39.8",
url:"index.php?act=staff&id=1111",
img:"user_data/7598.jpg",
nen:"平成23年式",
soukou:"78000",
title:"アトレーワゴン スローパー白3252",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "1035",
life: "59.8",
url:"index.php?act=staff&id=1035",
img:"user_data/6944.jpg",
nen:"平成27年式",
soukou:"67287",
title:"【カ単禁】ニッサンADバン255VE",
sold:"",
new:"",
tag: ["","販売中","","AT",""],
description: "tesut"
},
{
id: "1882",
life: "73.8",
url:"index.php?act=staff&id=1882",
img:"./img/nophoto.png",
nen:"平成27年式",
soukou:"82,000",
title:"【カ単禁】スズキキャリィトラックKC561",
sold:"",
new:"
",
tag: ["新着","販売中","","AT",""],
description: "tesut"
},
];
/*================================================================
スクリプトはじまり
================================================================*/
function init() {
//イベント登録
$(".filter_life select").on("change", onFilterChange);
$(".filter_tag input").on("change", onFilterChange);
$(".filter_keyword button").on("click", onFilterChange);
//最初は全て出力
refleshHtml(allList);
}
/*================================================================
HTML出力
================================================================*/
function refleshHtml(list) {
var outputHtml = '';
//出力する内容をoutputHtmlに格納
if (list.length > 0) {
_.each(list, function(line, i) {
outputHtml += '
' + line.title + '
';
outputHtml += '';
outputHtml += '' + line.new + '' + line.sold + '';
outputHtml += '
条件に当てはまる車を検索できませんでした。
' + allList.length + '件中' + list.length + '件を表示しています。
'); } /*================================================================ 絞り込み条件を変更した時 ================================================================*/ function onFilterChange(e) { var filterFncs = []; var result = []; //セレクトボックスの値を引数に指定した関数filterByLifeをfilterFuncs配列に格納 filterFncs.push( function(list) { return filterByLife(list, $('.filter_life select').val()); } ); //チェックボックスの値を引数に指定した関数filterByTagをfilterFuncs配列に格納 filterFncs.push( function(list) { return filterByTag(list, $('.filter_tag input:checked')); } ); //キーワードの値を引数に指定した関数filterByKeywordをfilterFuncs配列に格納 filterFncs.push( function(list) { return filterByKeyword(list, _.escape($('.filter_keyword input').val())); } ); //FilterFuncs配列内の関数をバケツリレーみたいに1つずつ実行して結果をresult配列に格納 result = _.reduce(filterFncs, function(list, fnc) { return fnc(list); }, allList); //絞り込んだ結果を出力 refleshHtml(result); } /*================================================================ 絞り込み[1] セレクトボックス絞り込み関数 ================================================================*/ function filterByLife(list, value) { //絞り込み指定がない場合はリターン if (value == "") { return list; } //選択したセレクトボックスとlifeがマッチするかでフィルタリング return _.filter(list, function(item) { switch (value) { case '1': return item.life <= 10; case '2': return 10 < item.life && item.life <= 20; case '3': return 20 < item.life && item.life <= 30; case '4': return 30 < item.life && item.life <= 40; case '5': return 40 < item.life && item.life <= 50; case '6': return 50 < item.life; } }); } /*================================================================ 絞り込み[2] チェックボックス絞り込み関数 ================================================================*/ function filterByTag(list, value) { //絞り込み指定がない場合はリターン if (value.length == 0) { return list; } //選択した属性(チェックボックス)とtagがマッチするかでフィルタリング return _.filter(list, function(item) { var isMatch = false; //配列同士の比較 _.each(value, function(chkItem, i) { _.each(item.tag, function(tagItem, i) { if (tagItem === $(chkItem).val()) { isMatch = true; } }); }); return isMatch; }); } /*================================================================ 絞り込み[3] テキストボックス絞り込み関数 ================================================================*/ function filterByKeyword(list, value) { //絞り込み指定がない場合はリターン if (value == "") { return list; } //検索キーワードを配列に格納(スペースがある場合は複数格納) var freeAry = []; var val = value.replace(/ /g, " "); searchAry = val.split(" "); //入力したキーワードがtitleもしくdescriptionにマッチするかでフィルタリング return _.filter(list, function(item) { var isMatch = false; _.each(searchAry, function(data, i) { if (item.title.indexOf(data) != -1 || item.description.indexOf(data) != -1) { isMatch = true; } }); return isMatch; }); } /*================================================================ スクリプトはじめ ================================================================*/ init(); });