• forked:近くの公衆無線LAN設置施設@十日町市
Import an externally hosted application
Check style

  • JavaScript
  • CSS
  • HTML
  • Images
  • Input Data
  • ReadMe
  • forked:近くの公衆無線LAN設置施設@十日町市
  • jquery-1.7.1.min.js  
  •  
  • history

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
 
/*
This is a Example program to retrieve and display the list of the data. Press the play/reload button on the right of the upper screen, and the program is executed. The program first displayes the subjects that match the keyword completely. The program highlights the list fragments that match the keyword. The keyword is retrieved from the query following "subject=" in the URL, where the keyword must be encoded. Please create a new application by rewriting this program work. The following is the same content in Japanese.
このサンプルプログラムはデータを取得してリスト表示します。画面右上のplay又はreloadボタンを押すとプログラムが実行されます。プログラムはキーワードに完全一致するサブジェクトを最初に表示します。またプログラムはキーワードに部分一致するリスト中の部分をハイライトします。キーワードはURLの中で"subject="に続くクエリーから取得されます。ただし、キーワードはURIエンコードされている必要があります。このプログラムを書き変えて新しいアプリケーションを作成してください。
*/
 
window.onload = function() {
    var keyword = getParameterFromURL("subject"); // obtain keyword from the URL "?subject="
    var list = ""; // list to be displayed
    var ruteToHitPoint = "";
    var prefs = new Array();
    // Work loop
    $.each(LinkData.getWorks(), function(workKey, workValue) {
        list += "<h3>" + LinkData.getWorkName(workValue) + "</h3>";
        // File loop
        $.each(LinkData.getFiles(workValue), function(fileKey, fileValue) {
            var hit = ""; // list of subjects whose URI matches keyword
            var nHit = 0; // number of subjects whose URI matches keyword
            // Subject loop
            $.each(LinkData.getSubjects(workValue, fileValue), function(subjKey, subjValue) {
                var longitude = null;
                var latitude = null;
                var s = ""; // subject to be displayed
                s += "<a href=\"" + subjValue + "\" target=\"_top\"><span class=\"subject\">" + highlight(decodeURIComponent(subjValue), keyword) + "</span></a>";
                $.each( LinkData.getTriplesBySubject(workValue, fileValue, subjValue), function( tripleKey, tripleValue ) {
                    var prop = tripleValue.property;
                    var obj = tripleValue.object;
                    if ( prop == "http://www.w3.org/2003/01/geo/wgs84_pos#long" ) longitude = obj;// longitude found
                    if ( prop == "http://www.w3.org/2003/01/geo/wgs84_pos#lat" ) latitude = obj;// latitude found
                    if ( obj.indexOf("://www.youtube.com") != -1 && obj.indexOf("v=") != -1 ) { // Insert YouTube Thumbnail
                        videoId = (obj.split("v=")[1]).split("&")[0]; // get video id
                        obj = "<a href=\"" + obj + "\" target=\"_blank\"><span class=\"object\">" + highlight(decodeURIComponent(obj), keyword) + "<br><img src=\"http://img.youtube.com/vi/" + videoId + "/mqdefault.jpg\" alt=\"YouTube video\" /><br></span></a>";
                        }
                        else if ( obj.indexOf("http") == 0 ) {
                            if ((obj.indexOf(".jpg" )>0 || obj.indexOf(".gif" )>0 || obj.indexOf(".png" )>0) || (obj.indexOf(".JPG" )>0 || obj.indexOf(".GIF" )>0 || obj.indexOf(".PNG" )>0)) // insert image
                                 obj = "<a href=\"" + obj + "\" target=\"_blank\"><span class=\"object\">" +shortenURL(obj) + "<br><img src=\"" + obj + "\" alt=\"image\" /><br></span></a>";
                            else
                                obj = "<a href=\"" + obj + "\" target=\"_blank\"><span class=\"object\">" + shortenURL(obj) + "</span></a>"; // Make it clicable if it starts from http
                    }
                    else
                        obj = "<span class=\"object\">" + highlight(obj, keyword) + "</span>";
                    s += "<br><span class=\"propertyName\">" + getLastName(prop) + ":\t</span>" +  obj;
                });
                if ( latitude != null && longitude != null ) s += addLinkToMap( latitude, longitude );
//              list += s; //add to the list to be displayed
                prefs.push(["<hr>"+s,latitude,longitude]);
                if ( decodeURIComponent(subjValue) == keyword ) { // found subject whose URI matches keyword
                    hit += s;
                    ruteToHitPoint = "http://www.google.com/maps/?daddr=" + latitude + "," + longitude;
                    nHit++;
                }
                //link to map display if coordinates exist
            });
            if ( nHit > 0 ) {
                list += "<hr><h4>指定されたサブジェクトが "+nHit+" 件見つかりました。</h4>";
                list += hit + "<br><br>";
            }
        });
    });
    $("#result").append( list + "この端末からの位置情報の取得を許可してからもう一度アクセスしてください。" );
 
    navigator.geolocation.getCurrentPosition(function(pos) {
        var lat = pos.coords.latitude;
        var long = pos.coords.longitude;
        if ( ruteToHitPoint != "" )
        {
            $('#result').empty();
            $('#result').append( list + "<hr><h4>現在地から目的地までのルートを表示します。</h4>");
            parent.location.href = ruteToHitPoint + "&saddr=" + lat + "," + long; // リダイレクト
        }
        else
        {
            $('#result').empty();
            $('#result').append( list + "<hr><h4>現在地から近い順にリスト表示します。</h4>");
            $.each(prefs, function(i, p) {
                p[3] = (lat - p[1]) * (lat - p[1]) + (long - p[2]) * (long - p[2]);
            });
            prefs.sort(function(p1, p2) {
                return p1[3] - p2[3];
            });
            $.each(prefs, function(i, p) {
                $('#result').append(p[0]);
                $('#result').append(" <a target=\"_top\" href=\"http://www.google.com/maps/?saddr=" + lat + "," + long + "&daddr=" + p[1] + "," + p[2] + "\">【ここから目的地へのルートを表示】</a>");
            });
        }
    }, function(error) {
        $('#result').empty();
        $('#result').append( list + "<hr><h4>現在地情報が取得できないため、登録順にリスト表示します。</h4>");
        $.each(prefs, function(i, p) {
            $('#result').append(p[0]);
        });
    });
};
 
// Get a parameter value in URL (e.g. ?paramString=value )
function getParameterFromURL( paramString )
{           
    var value = "";
    var topWindow = top.window.location.search;
    if( topWindow ){
        var q = decodeURIComponent(topWindow.substring(1,topWindow.length)).split("&");
jquery-1.7.1.min.js
Playing...

jquery-1.7.1.min.js