⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 internetportal.luac.lua

📁 htc manila 2 sourcecode
💻 LUA
📖 第 1 页 / 共 2 页
字号:
   l_29_2:Load()
end

HandleItemCreated = function(l_30_0, l_30_1)
   if l_30_0.IsFakeItem then
      l_30_1.Focusable = false
      local fni = l_30_1.Namespace:FindName("ListItemGroup")
      if fni ~= nil then
         fni._visible = false
      end
      return 
   end
   local l_30_2 = l_30_1.Namespace
   l_30_0.IsRealized = true
   l_30_1.Tag = l_30_0
   l_30_1.Focusable = true
   l_30_1.OnSelected:connect(HandleItemSelected)
   l_30_1.OnDeselected:connect(HandleItemDeselected)
   l_30_1.onKeyDown:connect(HandleItemKeyDown)
   local l_30_3 = l_30_2:FindName("OperatorLinkGroup")
   local l_30_4 = l_30_2:FindName("UserFavoriteGroup")
   local l_30_5 = l_30_2:FindName("CheckboxComponent")
   local l_30_6, l_30_7, l_30_8 = nil, nil, nil
   if l_30_0.IsOperatorLink == true then
      l_30_3._visible = true
      l_30_3.Duration = 40
      l_30_4._visible = false
      l_30_6 = l_30_2:FindName("OperatorLinkText")
      l_30_7 = nil
      l_30_8 = l_30_2:FindName("OperatorLinkImage")
   else
      l_30_3._visible = false
      l_30_4._visible = true
      l_30_4.Duration = 40
      l_30_6 = l_30_2:FindName("FavoriteText")
      l_30_7 = l_30_2:FindName("FavoriteUrl")
      l_30_8 = l_30_2:FindName("FavoriteImage")
      local x = l_30_2:FindName("DownLoadStatus")
      l_30_0.DownLoadStatus = DownloadStatusControl(l_30_0.Instance, x)
   end
   if l_30_0.Text ~= nil and l_30_6 ~= nil then
      l_30_6.String = l_30_0.Text
   end
   if l_30_0.DisplayUrl ~= nil and l_30_7 ~= nil then
      l_30_7.String = l_30_0.DisplayUrl
   end
   if l_30_4._visible == false then
     if l_30_0.ImagePath ~= nil and l_30_0.ImagePath ~= "" and l_30_8 ~= nil then
         if ListImageLoader == nil then
            ListImageLoader = ListImageLoaderClass()
         end
         ListImageLoader:AddImage(l_30_8, l_30_0)
     end
   else 
     l_30_8:SetTextureRef("FavoriteLinkImageUp")
   end
   l_30_0.Selector = l_30_2:FindName("Selector")
   if l_30_0.Selector ~= nil then
      l_30_0.Selector._visible = false
   end
end

HandleItemDestroyed = function(l_31_0)
   if not l_31_0.Tag then
      return 
   end
   l_31_0.Tag.IsRealized = false
   if l_31_0.Tag.IsOperatorLink == false then
      l_31_0.Tag.DownLoadStatus:Destroy()
   end
   l_31_0.OnSelected:disconnect(HandleItemSelected)
   l_31_0.OnDeselected:disconnect(HandleItemDeselected)
   l_31_0.onKeyDown:disconnect(HandleItemKeyDown)
end

HandleItemSelected = function(l_32_0)
   if l_32_0.Tag.Selector ~= nil then
      l_32_0.Tag.Selector._visible = true
      trace("HandleItemSelected \n")
      DisableSelectorTimer:Stop()
      DisableSelectorTimer:Start()
   end
   local l_32_1 = l_32_0.Namespace
   if l_32_1 ~= nil then
      local l_32_2 = l_32_1:FindName("UserFavoriteGroup")
      local l_32_3 = l_32_1:FindName("FavoriteImage")
      if l_32_2._visible == false then
         l_32_1:FindName("OperatorLinkText").Color = GetMainTextSelectedColor()
      end
      if l_32_2._visible == true then
         local l4 = l_32_1:FindName("FavoriteText")
         local l5 = l_32_1:FindName("FavoriteUrl")
         l4.Color = GetMainTextSelectedColor()
         l5.Color = GetSubTextSelectedColor()
      end
      if l_32_2._visible == true and l_32_3 ~= nil then
         l_32_3:SetTextureRef("FavoriteLinkImageDn")
      end
   end
end

HandleItemDeselected = function(l_33_0)
   if l_33_0.Tag.Selector ~= nil then
      l_33_0.Tag.Selector._visible = false
   end
   local l_33_1 = l_33_0.Namespace
   if l_33_1 ~= nil then
      local l_33_2 = l_33_1:FindName("UserFavoriteGroup")
      local l_33_3 = l_33_1:FindName("FavoriteImage")
      if l_33_2._visible == false then
         l_33_1:FindName("OperatorLinkText").Color = GetMainTextUnselectedColor()
      end
      if l_33_2._visible == true then
         local l4 = l_33_1:FindName("FavoriteText")
         local l5 = l_33_1:FindName("FavoriteUrl")
         l4.Color = GetMainTextUnselectedColor()
         l5.Color = GetSubTextUnselectedColor()
      end
      if l_33_2._visible == true and l_33_3 ~= nil then
         l_33_3:SetTextureRef("FavoriteLinkImageUp")
      end
   end
end

HandleItemKeyDown = function(l_34_0, l_34_1)
   if (l_34_1.Code == KeyCode_Return or l_34_1.Code == KeyCode_Space) then 
      if l_34_0.Tag ~= nil then
        HandleLinkPressed(l_34_0.Tag)
      end        
   else
      trace("HandleItemKeyDown \n")
      DisableSelectorTimer:Stop()
      DisableSelectorTimer:Start()
   end
end

HandleListSelection = function(l_35_0)
   local l_35_1 = GizmoListView:GetGenerator()
   if l_35_1:IsRealizedItemAHeader(l_35_0) then
      if _application.Store:GetIntValue(Lifetime_Permanent, "Internet.SetOperaForeground") == 1 then
         trace("[internetportal] : Internet.SetOperaForeground == 1")
         if InternetPortalData.Banner._attribs.NavigateUrl ~= nil then
            Shell_NavigateTo(ShellLocation_SetOperaForeground, InternetPortalData.Banner._attribs.NavigateUrl)
         else
            Shell_NavigateTo(ShellLocation_SetOperaForeground, OperaLaunchHomeArg)
         end
         return          
      end
      if InternetPortalData.Banner._attribs.NavigateUrl ~= nil then
         trace("HandleListSelection banner url")
         LaunchBrowser(InternetPortalData.Banner._attribs.NavigateUrl)
      else
         trace("HandleListSelection home")
         LaunchBrowser(OperaLaunchHomeArg)
      end
   else
      trace("HandleListSelection HandleLinkPressed")
      HandleLinkPressed(l_35_1:GetDataByRealizedIndex(l_35_0))
   end
end

HandleLinkPressed = function(l_36_0)
   if l_36_0 == nil then
      return 
   end
   if l_36_0.Url ~= nil then
      if l_36_0.IsOperatorLink == false then
         l_36_0.Instance:Open()
      else
         LaunchBrowser(l_36_0.Url)
      end
   elseif l_36_0.Executable ~= nil then
      Shell_NavigateTo(l_36_0.Executable, l_36_0.CommandLine)
   end
end

HandleLeftSoftkey = function()
   _application.Navigation:Navigate(URL("Manila://internet/bookmark.page"), true)
end

HandleRightSoftkey = function()
   SettingsDialogRequest = _application.DialogManager:GetDialog(URL("Manila://internet_settings_menu.dialog"))
   SettingsDialogRequest.OnExit:connect(DialogMenu_Callback)
   SettingsDialogRequest:Show()
end

DialogMenu_Callback = function(l_39_0)
   if l_39_0.Result.ExitType ~= DialogExitType_Cancel then
      local l_39_1 = l_39_0.Result.UserValue
      if l_39_1 == "Add Favorite" then
         _application.Navigation:Navigate(URL("Manila://bookmark/bookmarkedit.page"))
      elseif l_39_1 == "Remove Favorite" then
         _application.Navigation:Navigate(URL("Manila://removefavorite/removefavorite.page"))
      elseif l_39_1 == "Frequency Settings" then
         _application.Navigation:Navigate(URL("Manila://InternetPush_FrequencySettings/frequencysettings.page"))
      elseif l_39_1 == "Advanced Settings" then
         _application.Navigation:Navigate(URL("Manila://internetPush/internetsettings.page"))
      end
   end
end

LaunchBrowser = function(l_40_0)
   if l_40_0 == nil then
      l_40_0 = ""
   end
   if InternetPortalData.BrowserExe ~= nil then
      trace(InternetPortalData.BrowserExe._value)
   else
      trace("no BrowserExe")
   end
   if DefaultBrowserIsIE then
      LaunchIEBrowser(l_40_0)
   else
      if InternetPortalData.BrowserExe == nil then
         Shell_NavigateTo(ShellLocation_Opera, l_40_0)
      else
         if InternetPortalData.BrowserExe._value == "\\Windows\\iexplore.exe" then
            LaunchIEBrowser(l_40_0)
         else
            Shell_NavigateTo(InternetPortalData.BrowserExe._value, l_40_0)
         end
      end
   end
end

LaunchIEBrowser = function(l_41_0)
   if l_41_0 == OperaLaunchHomeArg then
      Shell_NavigateTo(ShellLocation_IEHome)
      return 
   elseif l_41_0 == OperaLaunchFavoriteUIArg then
      Shell_NavigateTo(ShellLocation_IEFavorites)
      return 
   else
      Shell_NavigateTo("\\Windows\\iexplore.exe", l_41_0)
      return 
   end
end

RebuildFavoriteList = function()
   if CountOfFavorites ~= nil and CountOfFavorites > 0 then
      for i = 1, CountOfFavorites do
         GizmoListCollection:pop_back()
      end
   end
   CountOfFavorites = 0
   local l0 = FavoriteLoader:LoadbyReg(0)
   if l0 ~= nil then
      CountOfFavorites = l0:GetCount()
      trace("Got " .. tostring(CountOfFavorites) .. " Favs.\n")
      for i = 0, CountOfFavorites - 1 do
         local item = l0:GetItem(i)
         if item ~= nil then
            local wu = WebURL(item.Url):GetServer()
            local list = {IsOperatorLink = false, 
              Instance = item,
              Text = item.Name, 
              Url = item.Url,
              DisplayUrl = wu,
              ImagePath = OperaImagesRoot .. "\\" .. wu .. ".ico"}
            GizmoListCollection:push_back(list)
         end
      end
   end
end

LoadPortalXml = function()
   trace("LoadPortalXml()\n")
   local l_43_0 = MachineStatus()
   local l_43_1 = {}
   local l_43_2 = nil
   if l_43_0.Locale.Exists then
      l_43_2 = l_43_0.Locale.Value
   end
   for i_1,i_2 in ipairs(InternetPortalSearchLocations) do
      local l_43_8 = nil
      if i_2.Locale == false then
         l_43_8 = i_2.Path
      elseif l_43_2 ~= nil then
         l_43_8 = string.format(i_2.Path, l_43_2)
      end
      if l_43_8 ~= nil then
        trace("Attempting to load " .. l_43_8 .. "\n")
        XmlDocument_ToLuaTable(URL(l_43_8), l_43_1)
        if l_43_1.InternetPortal ~= nil then
          break
        end
      end
   end
   if l_43_1.InternetPortal == nil then
      trace("Unable to load valid Internet portal XML file\n")
      return false
   end
   InternetPortalData = l_43_1.InternetPortal
   if InternetPortalData.Banner ~= nil then
      local l_43_3 = InternetPortalData.Banner._attribs
      l_43_3.Width = tonumber(l_43_3.Width)
      l_43_3.Height = tonumber(l_43_3.Height)
   end
   return true
end

InitializeList = function()
   GizmoListCollection = VectorNotifyLuaObject()
   local l_44_0 = InternetPortalData.OperatorLinks
   if l_44_0 ~= nil and l_44_0.Link ~= nil then
      trace("Got some operator links...\n")
      local l_44_1 = l_44_0.Link
      if l_44_1._count == nil then
         l_44_1 = {}
         l_44_1._count = 1
         l_44_1[1] = l_44_0.Link
      end
      local l_44_2 = 1
      while l_44_1[l_44_2] ~= nil do
         local l_44_3 = l_44_1[l_44_2]
         local list = {IsOperatorLink = true, Text = l_44_3._attribs.Text, Url = l_44_3._attribs.NavigateUrl, DisplayUrl = WebURL(l_44_3._attribs.NavigateUrl):GetServer(), Executable = l_44_3._attribs.Executable, CommandLine = l_44_3._attribs.CommandLine, ImagePath = l_44_3._attribs.ImagePath}
         GizmoListCollection:push_back(list)
         l_44_2 = l_44_2 + 1
      end
   end
   if InternetPortalData.IncludeUserFavorites == nil or string.lower(InternetPortalData.IncludeUserFavorites._value) == "true" or
        GizmoListCollection:GetCount() == 0 and InternetPortalData.Banner == nil then
      RebuildFavoriteList()
   end
   trace("InternetPush_RegisterEventCallbacks\n")
   InternetPush_RegisterEventCallbacks()
   if GizmoListCollection:GetCount() == 0 then
      GizmoListCollection:push_back({IsFakeItem = true})
   end
   local sl = SequentialLayout()
   sl:SetItemSize(MainCamera.Viewport.width, 80, 0)
   local l_44_2 = SequentialLibraryGeneratorLuaObject(GizmoListCollection, GizmoListView:GetMovie(), GizmoListView.ComponentLibraryName, GizmoListView.ComponentLibraryID)
   if InternetPortalData.Banner ~= nil then
      sl:SetHeaderSize(MainCamera.Viewport.width, BaseHeaderHeight + InternetPortalData.Banner._attribs.Height, 0)
      l_44_2:SetHeaderComponent(GizmoListView:GetMovie(), GizmoListView.ComponentLibraryName, "BannerComponent")
      l_44_2.HeaderCreated:connect(HandleHeaderCreated)
      l_44_2.RecycleHeaders = true
   end
   GizmoListView:SetLayout(sl)
   GizmoListScrollPhysics = ScrollPhysics(GizmoListView, GizmoListView, HandleListSelection)
   GizmoListScrollPhysics:ConnectMouseEvents()
   l_44_2.ItemCreated:connect(HandleItemCreated)
   l_44_2.ItemDestroyed:connect(HandleItemDestroyed)
   l_44_2.GroupFunction:connect(function()
      return 0
   end)
   l_44_2.RecycleItems = true
   GizmoListView:SetGenerator(l_44_2)
   GizmoListView:ForceLayout()
   GizmoListView:Focus()
end

if _application.Store:GetIntValue(Lifetime_Permanent, "DefaultBrowserIsIE") == 1 then
  DefaultBrowserIsIE = true
else
  DefaultBrowserIsIE = false
end

_InternetSetUtil = InternetSetUtil()
GizmoListView.Viewport.y = 544
if LoadPortalXml() then
   InitializeList()
end
_application:SetLeftSoftkey(Softkey(Locale:GetString("IDS_ALLFAVORITES"), HandleLeftSoftkey))
_application:SetRightSoftkey(Softkey(Locale:GetString("IDS_SETTS"), HandleRightSoftkey))
DisableSelector = function()
   DisableSelectorTimer:Stop()
   GizmoListView:GetGenerator().SelectedIndex = -1
   trace("Set GizmoListView.selectedIndex = -1\n")
end

DisableSelectorTimer = timer(5)
DisableSelectorTimer:Stop()
DisableSelectorTimer.OnElapsed:connect(DisableSelector)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -