Sha256: 9cd23fedb28f4934b2fe5dd8195364927c6f23ec1ef1121420083d1b84badb00

Contents?: true

Size: 778 Bytes

Versions: 17

Compression:

Stored size: 778 Bytes

Contents

//
// @brief
// @author ongaeshi
// @date   2011/08/24

function replace_query_param(url, value)
{
  var url_s = url.split("?");

  if (url_s.length <= 1) {
    return url + "?query=" + value;
  } else {
    var params = url_s[1].split("&");
    var found_query = false;

    for (var i = 0; i < params.length; i++) {
      if (params[i].search(/^query=/) != -1) {
        params[i] = params[i].replace(/^query=.*/, "query=" + value);
        found_query = true;
      }
    }

    if (!found_query)
      params.unshift("query=" + value);

    return url_s[0] + "?" + params.join("&");
  }
}

function topic_path(id)
{
  var url = document.getElementById(id).href;
  url = replace_query_param(url, document.searchform.query.value);
  document.getElementById(id).href = url;
}

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
milkode-0.8.1 lib/milkode/cdweb/public/js/milkode.js
milkode-0.8.0 lib/milkode/cdweb/public/js/milkode.js
milkode-0.7.1 lib/milkode/cdweb/public/js/milkode.js
milkode-0.7.0 lib/milkode/cdweb/public/js/milkode.js
milkode-0.6.3 lib/milkode/cdweb/public/js/milkode.js
milkode-0.6.2 lib/milkode/cdweb/public/js/milkode.js
milkode-0.6.1 lib/milkode/cdweb/public/js/milkode.js
milkode-0.6.0 lib/milkode/cdweb/public/js/milkode.js
milkode-0.5.3 lib/milkode/cdweb/public/js/milkode.js
milkode-0.5.2 lib/milkode/cdweb/public/js/milkode.js
milkode-0.5.1 lib/milkode/cdweb/public/js/milkode.js
milkode-0.5.0 lib/milkode/cdweb/public/js/milkode.js
milkode-0.4.0 lib/milkode/cdweb/public/js/milkode.js
milkode-0.3.0 lib/milkode/cdweb/public/js/milkode.js
milkode-0.2.9 lib/milkode/cdweb/public/js/milkode.js
milkode-0.2.4 lib/milkode/cdweb/public/js/milkode.js
milkode-0.2.2 lib/milkode/cdweb/public/js/milkode.js