1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-05 19:42:01 +02:00

Added native auto-fill support for URL input in Chrome.

This commit is contained in:
Gunther Brunner 2014-07-31 16:54:09 +09:00
parent e6465fe8cc
commit 8696f833c2
8 changed files with 254 additions and 190 deletions

View file

@ -2,49 +2,20 @@ var _ = require('lodash')
module.exports = function NavigationCtrl($scope, $rootScope) {
$scope.urlHistory = []
function addToHistory() {
var HISTORY_LIMIT = 20
var history = $scope.urlHistory
history.unshift($scope.textURL)
if (history.length > HISTORY_LIMIT) {
history.pop()
}
$scope.urlHistory = _.uniq(history)
}
function addHttp() {
if ($scope.textURL.indexOf(':') === -1) {
$scope.textURL = 'http://' + $scope.textURL
function addHttp(textUrl) {
if (textUrl.indexOf(':') === -1 && textUrl.indexOf('.') !== -1) {
return 'http://' + textUrl
}
return textUrl
}
$scope.openURL = function () {
addHttp()
addToHistory()
return $scope.control.openBrowser(
$scope.textURL,
addHttp($scope.textURL),
$scope.browser
)
}
$scope.clearHistory = function () {
$scope.urlHistory = []
}
$scope.hasHistory = function () {
return $scope.urlHistory.length > 0
}
$scope.insertURL = function ($url) {
$scope.textURL = $url
$scope.openURL()
}
function setCurrentBrowser(browser) {
if (browser && browser.apps) {
var currentBrowser = {}